Skip to content

Commit eb710ff

Browse files
committed
Fix the import_object ImportError on Python 3.
Python 3 also changed exception messages slightly so remove one case from the doctest.
1 parent 55d3394 commit eb710ff

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

tornado/util.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import zlib
1818

1919

20-
import sys
21-
2220
class ObjectDict(dict):
2321
"""Makes a dictionary behave like an object, with attribute-style access.
2422
"""
@@ -75,10 +73,6 @@ def import_object(name):
7573
True
7674
>>> import_object('tornado') is tornado
7775
True
78-
>>> import_object('missing_module')
79-
Traceback (most recent call last):
80-
...
81-
ImportError: No module named missing_module
8276
>>> import_object('tornado.missing_module')
8377
Traceback (most recent call last):
8478
...
@@ -92,8 +86,8 @@ def import_object(name):
9286
try:
9387
return getattr(obj, parts[-1])
9488
except AttributeError:
95-
exc_info = sys.exc_info()
96-
raise ImportError, "No module named %s" % parts[-1], exc_info[2]
89+
raise ImportError("No module named %s" % parts[-1])
90+
9791

9892
# Fake unicode literal support: Python 3.2 doesn't have the u'' marker for
9993
# literal strings, and alternative solutions like "from __future__ import

0 commit comments

Comments
 (0)