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 Hassan El Karouni
Recipients Hassan El Karouni
Date 2015-08-27.09:15:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1440666935.19.0.799788470417.issue24944@psf.upfronthosting.co.za>
In-reply-to
Content
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tempfile.mkstemp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\tempfile.py", line 308, in mkstemp
    return _mkstemp_inner(dir, prefix, suffix, flags)
  File "C:\Python27\lib\tempfile.py", line 240, in _mkstemp_inner
    _set_cloexec(fd)
  File "C:\Python27\lib\tempfile.py", line 50, in _set_cloexec
    flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
AttributeError: 'module' object has no attribute 'F_GETFD'


On line 51 in tempfile.py, an AttributeError exception is not caught. The problem is caused by the fact that on Windows, the fcntl module is supposed not to exist, but in my case, a dummy module with the same name was put on the path. This means that line 50 is run thru when making the mkstemp() call.
The fix is to catch the AttributeError exception on line 51.
The bug might also affect Python 3 but this is to be checked.
History
Date User Action Args
2015-08-27 09:15:35Hassan El Karounisetrecipients: + Hassan El Karouni
2015-08-27 09:15:35Hassan El Karounisetmessageid: <1440666935.19.0.799788470417.issue24944@psf.upfronthosting.co.za>
2015-08-27 09:15:35Hassan El Karounilinkissue24944 messages
2015-08-27 09:15:34Hassan El Karounicreate