diff options
author | Brett Cannon <brett@python.org> | 2012-04-17 23:05:11 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-17 23:05:11 (GMT) |
commit | 273323cf68e8d55c67622412ecf531e359a54e11 (patch) | |
tree | ddac9de01083d9e7a165c83455493ee31d32ce21 /Lib/importlib/test | |
parent | 09b86d1196427f2028d7e072b106847d8c693815 (diff) | |
download | cpython-273323cf68e8d55c67622412ecf531e359a54e11.zip cpython-273323cf68e8d55c67622412ecf531e359a54e11.tar.gz cpython-273323cf68e8d55c67622412ecf531e359a54e11.tar.bz2 |
Issue #14592: A relative import will raise a KeyError if __package__
or __name__ are not set in globals.
Thanks to Stefan Behnel for the bug report.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r-- | Lib/importlib/test/import_/test_relative_imports.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/importlib/test/import_/test_relative_imports.py b/Lib/importlib/test/import_/test_relative_imports.py index 5b4e23c..4569c26 100644 --- a/Lib/importlib/test/import_/test_relative_imports.py +++ b/Lib/importlib/test/import_/test_relative_imports.py @@ -203,6 +203,11 @@ class RelativeImports(unittest.TestCase): self.assertEqual(mod.__name__, 'crash.mod') self.relative_import_test(create, globals_, callback) + def test_relative_import_no_globals(self): + # No globals for a relative import is an error. + with self.assertRaises(KeyError): + import_util.import_('sys', level=1) + def test_main(): from test.support import run_unittest |