STINNER Victor <victor.stin...@gmail.com> added the comment: > Victor, that sounds like a strange behaviour to me.
We may change PyFile_FromString() to call fclose() when the file is closed explicitly (call its close() method), but it may break backward compatibility. I prefer to document the behaviour instead. > PyFile_FromString is a public API and maybe it shouldn't > have changed between 2.6 and 2.7. PyFile_FromString() didn't change in Python 2.7. I changed PyFile_FromFile() in Python 2.7 to fix the issue #7732. changeset: 72456:0f5b64630fda branch: 2.7 parent: 72450:c02e790c4535 user: Victor Stinner <victor.stin...@haypocalc.com> date: Fri Sep 23 19:37:03 2011 +0200 files: Doc/c-api/file.rst Lib/test/test_import.py Misc/NEWS Objects/fileobject.c Python/import.c description: 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). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14505> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com