diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-09-19 12:51:19 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-19 12:51:19 (GMT) |
commit | 99a51d4e5b154a7b8d971090fecc1e34769a3ca1 (patch) | |
tree | 1a612669e6b01a6c3b66ffae79c39d2dfad4dc4f /Lib | |
parent | 113bc6f57b86aa88a5607258758718b294cf7205 (diff) | |
download | cpython-99a51d4e5b154a7b8d971090fecc1e34769a3ca1.zip cpython-99a51d4e5b154a7b8d971090fecc1e34769a3ca1.tar.gz cpython-99a51d4e5b154a7b8d971090fecc1e34769a3ca1.tar.bz2 |
[3.6] bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (GH-3257) (#3653)
(cherry picked from commit 9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_imp.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 6f35f49..d513eed 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -318,6 +318,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): |