mirror of https://github.com/python/cpython
bpo-38109: Add missing constants to Lib/stat.py (GH-16665)
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT, stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to the Python implementation of the stat module.
This commit is contained in:
parent
a5447735c3
commit
7bb14316b8
16
Lib/stat.py
16
Lib/stat.py
|
@ -40,6 +40,10 @@ S_IFREG = 0o100000 # regular file
|
||||||
S_IFIFO = 0o010000 # fifo (named pipe)
|
S_IFIFO = 0o010000 # fifo (named pipe)
|
||||||
S_IFLNK = 0o120000 # symbolic link
|
S_IFLNK = 0o120000 # symbolic link
|
||||||
S_IFSOCK = 0o140000 # socket file
|
S_IFSOCK = 0o140000 # socket file
|
||||||
|
# Fallbacks for uncommon platform-specific constants
|
||||||
|
S_IFDOOR = 0
|
||||||
|
S_IFPORT = 0
|
||||||
|
S_IFWHT = 0
|
||||||
|
|
||||||
# Functions to test for each file type
|
# Functions to test for each file type
|
||||||
|
|
||||||
|
@ -71,6 +75,18 @@ def S_ISSOCK(mode):
|
||||||
"""Return True if mode is from a socket."""
|
"""Return True if mode is from a socket."""
|
||||||
return S_IFMT(mode) == S_IFSOCK
|
return S_IFMT(mode) == S_IFSOCK
|
||||||
|
|
||||||
|
def S_ISDOOR(mode):
|
||||||
|
"""Return True if mode is from a door."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def S_ISPORT(mode):
|
||||||
|
"""Return True if mode is from an event port."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def S_ISWHT(mode):
|
||||||
|
"""Return True if mode is from a whiteout."""
|
||||||
|
return False
|
||||||
|
|
||||||
# Names for permission bits
|
# Names for permission bits
|
||||||
|
|
||||||
S_ISUID = 0o4000 # set UID bit
|
S_ISUID = 0o4000 # set UID bit
|
||||||
|
|
|
@ -16,10 +16,10 @@ class TestFilemode:
|
||||||
'UF_IMMUTABLE', 'UF_NODUMP', 'UF_NOUNLINK', 'UF_OPAQUE'}
|
'UF_IMMUTABLE', 'UF_NODUMP', 'UF_NOUNLINK', 'UF_OPAQUE'}
|
||||||
|
|
||||||
formats = {'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK',
|
formats = {'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK',
|
||||||
'S_IFREG', 'S_IFSOCK'}
|
'S_IFREG', 'S_IFSOCK', 'S_IFDOOR', 'S_IFPORT', 'S_IFWHT'}
|
||||||
|
|
||||||
format_funcs = {'S_ISBLK', 'S_ISCHR', 'S_ISDIR', 'S_ISFIFO', 'S_ISLNK',
|
format_funcs = {'S_ISBLK', 'S_ISCHR', 'S_ISDIR', 'S_ISFIFO', 'S_ISLNK',
|
||||||
'S_ISREG', 'S_ISSOCK'}
|
'S_ISREG', 'S_ISSOCK', 'S_ISDOOR', 'S_ISPORT', 'S_ISWHT'}
|
||||||
|
|
||||||
stat_struct = {
|
stat_struct = {
|
||||||
'ST_MODE': 0,
|
'ST_MODE': 0,
|
||||||
|
@ -231,10 +231,6 @@ class TestFilemode:
|
||||||
class TestFilemodeCStat(TestFilemode, unittest.TestCase):
|
class TestFilemodeCStat(TestFilemode, unittest.TestCase):
|
||||||
statmod = c_stat
|
statmod = c_stat
|
||||||
|
|
||||||
formats = TestFilemode.formats | {'S_IFDOOR', 'S_IFPORT', 'S_IFWHT'}
|
|
||||||
format_funcs = TestFilemode.format_funcs | {'S_ISDOOR', 'S_ISPORT',
|
|
||||||
'S_ISWHT'}
|
|
||||||
|
|
||||||
|
|
||||||
class TestFilemodePyStat(TestFilemode, unittest.TestCase):
|
class TestFilemodePyStat(TestFilemode, unittest.TestCase):
|
||||||
statmod = py_stat
|
statmod = py_stat
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Add missing :data:`stat.S_IFDOOR`, :data:`stat.S_IFPORT`, :data:`stat.S_IFWHT`,
|
||||||
|
:func:`stat.S_ISDOOR`, :func:`stat.S_ISPORT`, and :func:`stat.S_ISWHT` values to
|
||||||
|
the Python implementation of :mod:`stat`.
|
Loading…
Reference in New Issue