mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Improper type for __package__ should raise TypeError, not ValueError.
This commit is contained in:
parent
068915cc8b
commit
f500778f65
2 changed files with 2 additions and 2 deletions
|
@ -926,7 +926,7 @@ def _sanity_check(name, package, level):
|
|||
raise ValueError('level must be >= 0')
|
||||
if package:
|
||||
if not isinstance(package, str):
|
||||
raise ValueError("__package__ not set to a string")
|
||||
raise TypeError("__package__ not set to a string")
|
||||
elif package not in sys.modules:
|
||||
msg = ("Parent module {0!r} not loaded, cannot perform relative "
|
||||
"import")
|
||||
|
|
|
@ -67,7 +67,7 @@ class Using__package__(unittest.TestCase):
|
|||
|
||||
def test_bunk__package__(self):
|
||||
globals = {'__package__': 42}
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(TypeError):
|
||||
import_util.import_('', globals, {}, ['relimport'], 1)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue