diff options
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)) |