This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Trundle, amaury.forgeotdarc, brett.cannon, doko, flox, l0nwlf, ncoghlan, orsenthil, r.david.murray
Date 2010-04-09.08:36:17
SpamBayes Score 2.8737165e-07
Marked as misclassified No
Message-id <>
Ah, OK - the problem is confined solely to the wrapper for the Python imp module function. The normal import machinery doesn't go through the wrapper and hence doesn't have the problem.

The PyFile_FromFile logic is a little convoluted, but Florent's patch looks correct. Currently, if the dircheck call in fill_file_fields fails, the function returns NULL, but leaves the file object populated (included its f_fp field). The Py_DECREF call then implicitly closes the file, resulting in a double close when call_find_module does the same thing manually.

One other thing that is a little dubious in this code is the lack of error checking on the conversion of mode to a string object in fill_file_fields. That's fine for file_init (where mode came from a Python string object in the first place), but not valid for PyFile_FromFile (where mode is passed in as a char * instance).
Date User Action Args
2010-04-09 08:36:20ncoghlansetrecipients: + ncoghlan, brett.cannon, doko, amaury.forgeotdarc, orsenthil, r.david.murray, Trundle, flox, l0nwlf
2010-04-09 08:36:19ncoghlansetmessageid: <>
2010-04-09 08:36:18ncoghlanlinkissue7732 messages
2010-04-09 08:36:17ncoghlancreate