mirror of
https://github.com/python/cpython.git
synced 2025-08-19 08:11:46 +00:00
Issue #7732: Fix a crash on importing a module if a directory has the same name
than a Python module (e.g. "__init__.py"): don't close the file twice. PyFile_FromFile() does also close the file if PyString_FromString() failed. It did already close the file on fill_file_fields() error (e.g. if the file is a directory).
This commit is contained in:
parent
51b719814e
commit
63c22fac72
5 changed files with 34 additions and 18 deletions
|
@ -265,6 +265,14 @@ class ImportTests(unittest.TestCase):
|
|||
"""))
|
||||
script_helper.assert_python_ok(testfn)
|
||||
|
||||
def test_bug7732(self):
|
||||
source = TESTFN + '.py'
|
||||
os.mkdir(source)
|
||||
try:
|
||||
self.assertRaises(IOError, imp.find_module, TESTFN, ["."])
|
||||
finally:
|
||||
os.rmdir(source)
|
||||
|
||||
|
||||
class PycRewritingTests(unittest.TestCase):
|
||||
# Test that the `co_filename` attribute on code objects always points
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue