mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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.
This commit is contained in:
parent
da6eb5305f
commit
53ffdc53bf
3 changed files with 22 additions and 2 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue