[ python-Bugs-1532920 ] os.path.isfile('CON:') does not behave as documented
SourceForge.net
noreply at sourceforge.net
Wed Aug 2 07:13:19 CEST 2006
Bugs item #1532920, was opened at 2006-08-02 15:13
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1532920&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: lplatypus (ldeller)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.isfile('CON:') does not behave as documented
Initial Comment:
In Windows, os.path.isfile() returns True for device
filenames such as 'CON:', 'NUL:', 'AUX:', 'PRN:', and
'C:\\Program Files\\con.mp3'.
The documentation for os.path.isfile() says that it
returns True only for regular files, so it should
return False for the above examples (or else the
documentation should be amended). In Linux,
os.path.isfile('/dev/null') returns False as expected.
This problem occurs because the “stat” function in
Microsoft’s C library behaves differently than in *nix.
Quoting from Microsoft's documentation for stat:
“st_mode: ... the _S_IFREG bit is set if path
specifies an ordinary file or a device”
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__stat.2c_._wstat.2c_._stati64.2c_._wstati64.asp
A similar problem exists with
stat.S_ISREG(os.stat('CON:').st_mode)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1532920&group_id=5470
More information about the Python-bugs-list
mailing list