Author vstinner
Recipients doko, pitrou, vstinner
Date 2012-04-05.11:20:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> 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 <>
date:        Fri Sep 23 19:37:03 2011 +0200
files:       Doc/c-api/file.rst Lib/test/ Misc/NEWS
Objects/fileobject.c Python/import.c
Issue #7732: Fix a crash on importing a module if a directory has the same name
than a Python module (e.g. ""): 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
Date User Action Args
2012-04-05 11:20:08vstinnersetrecipients: + vstinner, doko, pitrou
2012-04-05 11:20:07vstinnerlinkissue14505 messages
2012-04-05 11:20:07vstinnercreate