summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_imp.py
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-09-19 11:39:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-09-19 11:39:47 (GMT)
commit9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54 (patch)
tree5cd22abadd721260709dcd9e43ab6a173107f1e0 /Lib/test/test_imp.py
parent6db7033192cd537ca987a65971acb01206c3ba82 (diff)
downloadcpython-9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54.zip
cpython-9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54.tar.gz
cpython-9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54.tar.bz2
bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (#3257)
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r--Lib/test/test_imp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 3bfcb09..51bec50 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -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):