diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2016-09-07 22:42:32 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2016-09-07 22:42:32 (GMT) |
commit | c943265ba56e7ce7e2fe79fdecfc6670e10e5467 (patch) | |
tree | 3447a25e48844f57e2e8452aad43a3567101cd32 /Lib | |
parent | 86a76684269f940a20366cb42668f1acb0982dca (diff) | |
download | cpython-c943265ba56e7ce7e2fe79fdecfc6670e10e5467.zip cpython-c943265ba56e7ce7e2fe79fdecfc6670e10e5467.tar.gz cpython-c943265ba56e7ce7e2fe79fdecfc6670e10e5467.tar.bz2 |
Issue #15767: Add ModuleNotFoundError.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_compat_pickle.py | 7 | ||||
-rw-r--r-- | Lib/test/exception_hierarchy.txt | 1 | ||||
-rw-r--r-- | Lib/test/test_pickle.py | 8 |
3 files changed, 16 insertions, 0 deletions
diff --git a/Lib/_compat_pickle.py b/Lib/_compat_pickle.py index c0e0443..f68496a 100644 --- a/Lib/_compat_pickle.py +++ b/Lib/_compat_pickle.py @@ -242,3 +242,10 @@ PYTHON3_OSERROR_EXCEPTIONS = ( for excname in PYTHON3_OSERROR_EXCEPTIONS: REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'OSError') + +PYTHON3_IMPORTERROR_EXCEPTIONS = ( + 'ModuleNotFoundError', +) + +for excname in PYTHON3_IMPORTERROR_EXCEPTIONS: + REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'ImportError') diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt index 0513765..7333b2a 100644 --- a/Lib/test/exception_hierarchy.txt +++ b/Lib/test/exception_hierarchy.txt @@ -14,6 +14,7 @@ BaseException +-- BufferError +-- EOFError +-- ImportError + +-- ModuleNotFoundError +-- LookupError | +-- IndexError | +-- KeyError diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 05203e5..e6c5d08 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -335,6 +335,9 @@ class CompatPickleTests(unittest.TestCase): if (module2, name2) == ('exceptions', 'OSError'): attr = getattribute(module3, name3) self.assertTrue(issubclass(attr, OSError)) + elif (module2, name2) == ('exceptions', 'ImportError'): + attr = getattribute(module3, name3) + self.assertTrue(issubclass(attr, ImportError)) else: module, name = mapping(module2, name2) if module3[:1] != '_': @@ -401,6 +404,11 @@ class CompatPickleTests(unittest.TestCase): if exc is not OSError and issubclass(exc, OSError): self.assertEqual(reverse_mapping('builtins', name), ('exceptions', 'OSError')) + elif exc is not ImportError and issubclass(exc, ImportError): + self.assertEqual(reverse_mapping('builtins', name), + ('exceptions', 'ImportError')) + self.assertEqual(mapping('exceptions', name), + ('exceptions', name)) else: self.assertEqual(reverse_mapping('builtins', name), ('exceptions', name)) |