summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-23 17:37:03 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-23 17:37:03 (GMT)
commit63c22fac727a72f0a4da8f72b12cd5f9b480376b (patch)
tree8c3da37f17c59c36e9204e527c1ceea2a48695f7 /Lib/test/test_import.py
parent51b719814e0c32fd0eea570d3769d323bea97cab (diff)
downloadcpython-63c22fac727a72f0a4da8f72b12cd5f9b480376b.zip
cpython-63c22fac727a72f0a4da8f72b12cd5f9b480376b.tar.gz
cpython-63c22fac727a72f0a4da8f72b12cd5f9b480376b.tar.bz2
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).
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r--Lib/test/test_import.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 5751901..f654c33 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -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