marienz committed 808e233

Make bpython.urwid work better without Twisted installed.

  • Participants
  • Parent commits 9da118b

Comments (0)

Files changed (1)

             return EvalProtocol(self.repl)
-if urwid.VERSION < (1, 0, 0):
+# If Twisted is not available urwid has no TwistedEventLoop attribute.
+# Code below will try to import reactor before using TwistedEventLoop.
+# I assume TwistedEventLoop will be available if that import succeeds.
+if urwid.VERSION < (1, 0, 0) and hasattr(urwid, 'TwistedEventLoop'):
     class TwistedEventLoop(urwid.TwistedEventLoop):
         """TwistedEventLoop modified to properly stop the reactor.
             return wrapper
-    TwistedEventLoop = urwid.TwistedEventLoop
+    TwistedEventLoop = getattr(urwid, 'TwistedEventLoop', None)
 class StatusbarEdit(urwid.Edit):