mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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.
This commit is contained in:
parent
09b86d1196
commit
273323cf68
3 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue