diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-23 16:59:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-23 16:59:08 (GMT) |
commit | a1fe1f8dcfd43059c38b1493ec67af06fd2afe7f (patch) | |
tree | e6998aa6681a95508a4f4f6dafd9aef6f9d43ec3 /Lib/test/test_import.py | |
parent | 92c144ee72d4ab488ec0a9d50cb78dc739c68069 (diff) | |
parent | 53ffdc53bf0500e402682d1459a9a8d06573664c (diff) | |
download | cpython-a1fe1f8dcfd43059c38b1493ec67af06fd2afe7f.zip cpython-a1fe1f8dcfd43059c38b1493ec67af06fd2afe7f.tar.gz cpython-a1fe1f8dcfd43059c38b1493ec67af06fd2afe7f.tar.bz2 |
Merge 3.2: Issue #7732: Don't open a directory as a file anymore while
importing a module. Ignore the direcotry if its name matchs the module name
(e.g. "__init__.py") and raise a ImportError instead.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r-- | Lib/test/test_import.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index a1cebf9..6cbd218 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -139,6 +139,15 @@ class ImportTests(unittest.TestCase): self.assertIs(orig_path, new_os.path) self.assertIsNot(orig_getenv, new_os.getenv) + def test_bug7732(self): + source = TESTFN + '.py' + os.mkdir(source) + try: + self.assertRaisesRegex(ImportError, '^No module', + imp.find_module, TESTFN, ["."]) + finally: + os.rmdir(source) + def test_module_with_large_stack(self, module='longlist'): # Regression test for http://bugs.python.org/issue561858. filename = module + '.py' |