mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (#3257)
This commit is contained in:
parent
6db7033192
commit
9974e1bcf3
3 changed files with 18 additions and 0 deletions
|
@ -313,6 +313,17 @@ class ImportTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(ValueError, 'embedded null'):
|
||||
imp.load_source(__name__, __file__ + "\0")
|
||||
|
||||
@support.cpython_only
|
||||
def test_issue31315(self):
|
||||
# There shouldn't be an assertion failure in imp.create_dynamic(),
|
||||
# when spec.name is not a string.
|
||||
create_dynamic = support.get_attribute(imp, 'create_dynamic')
|
||||
class BadSpec:
|
||||
name = None
|
||||
origin = 'foo'
|
||||
with self.assertRaises(TypeError):
|
||||
create_dynamic(BadSpec())
|
||||
|
||||
|
||||
class ReloadTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue