From: Ben Darnell Date: Mon, 3 Aug 2015 03:56:22 +0000 (-0400) Subject: Lazy-load StopAsyncIteration in a more future-proof way. X-Git-Tag: v4.3.0b1~63^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7cddd3d88ed87debaae4cd06edb1c245b60895d;p=thirdparty%2Ftornado.git Lazy-load StopAsyncIteration in a more future-proof way. Fixes the test on nightly cpython. --- diff --git a/tornado/gen.py b/tornado/gen.py index 56c5f3737..78ddce75c 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -108,6 +108,11 @@ try: except ImportError: def isawaitable(x): return False +try: + import builtins # py3 +except ImportError: + import __builtin__ as builtins + class KeyReuseError(Exception): pass @@ -412,7 +417,7 @@ class WaitIterator(object): def __anext__(self): if self.done(): # Lookup by name to silence pyflakes on older versions. - raise globals()['StopAsyncIteration']() + raise getattr(builtins, 'StopAsyncIteration')() return self.next()