diff options
author | Brett Cannon <brett@python.org> | 2015-08-14 18:06:43 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2015-08-14 18:06:43 (GMT) |
commit | 7c97a05618733b93f0a6e80ad5b672c2f966f448 (patch) | |
tree | eebf9b4118d5e5f7e6d69b1ff6e64f8f3ba6c2a4 /Lib | |
parent | f7a92673ab38f43c1d274e1663f62da394f4f153 (diff) | |
parent | 3008bc0f4abb3f71433b1fcd97cc801da0a866cc (diff) | |
download | cpython-7c97a05618733b93f0a6e80ad5b672c2f966f448.zip cpython-7c97a05618733b93f0a6e80ad5b672c2f966f448.tar.gz cpython-7c97a05618733b93f0a6e80ad5b672c2f966f448.tar.bz2 |
Merge from 3.5.0 for issue #24492
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_import/__init__.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index 586478f..14a688d 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -324,6 +324,19 @@ class ImportTests(unittest.TestCase): with self.assertRaisesRegex(ImportError, "^cannot import name 'bogus'"): from re import bogus + def test_from_import_AttributeError(self): + # Issue #24492: trying to import an attribute that raises an + # AttributeError should lead to an ImportError. + class AlwaysAttributeError: + def __getattr__(self, _): + raise AttributeError + + module_name = 'test_from_import_AttributeError' + self.addCleanup(unload, module_name) + sys.modules[module_name] = AlwaysAttributeError() + with self.assertRaises(ImportError): + from test_from_import_AttributeError import does_not_exist + @skip_if_dont_write_bytecode class FilePermissionTests(unittest.TestCase): |