You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for the stat module is inconsistent
(Doc/library/stat.rst, at least for Python 2.7.2 and 3.3.0):
It talks about a function stat.S_IFMT() and a bit mask stat.S_IFMT.
Only the former does exist.
Besides, it states: "For complete details about the stat(), fstat()
and lstat() calls, consult the documentation for your system."
I suggest to add some pointers on what systems one might consult
what documentation: "(e.g., on GNU/Linux invoke 'man 2 stat')"
I don't know about other systems, though.
So, doing "man 2 stat", which refers to the POSIX standard and which
seems to have served as blueprint for stat's interface, I expected
to find the bit mask S_IFMT.
However, that does not exist. In contrast, in stat.py that bit mask
is hard-coded as 0o170000 in the definition of S_IFMT().
As long-term, backwards-incompatible fix, I suggest to export
S_IFMT = 0o170000
and to rename the function S_IFMT(). That way, stat would in fact
be aligned with the documentation for my system.
As short-term fix, I suggest to correct stat.rst.
Use of the functions above is more portable than use of the first
set of flags:
Bit mask for the file type bit fields.
Use of the functions above may be more portable than use of the
first set of flags.
Warning: Note that the stat module does not export a bit mask
S_IFMT. (As stated incorrectly in previous versions of the
Here, I replaced "is more portable" with "may be more portable" as
the constant 0o170000 is hard-coded into S_IFMT() in stat.py. Maybe
somebody could add a hint in what sense portability is improved?
Alternatively that sentence could be deleted.