[Python-checkins] bpo-38109: Add missing constants to Lib/stat.py (GH-16665) (GH-16690)
Victor Stinner
webhook-mailer at python.org
Thu Oct 10 09:50:37 EDT 2019
https://github.com/python/cpython/commit/8ab11c433a81b6c7ef84a66e36fbe199915e2ff6
commit: 8ab11c433a81b6c7ef84a66e36fbe199915e2ff6
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Victor Stinner <vstinner at python.org>
date: 2019-10-10T15:50:32+02:00
summary:
bpo-38109: Add missing constants to Lib/stat.py (GH-16665) (GH-16690)
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.
(cherry picked from commit 7bb14316b8ceddb813f31040a299af94a57ab339)
Co-authored-by: Ronan Lamy <ronan.lamy at gmail.com>
files:
A Misc/NEWS.d/next/Library/2019-10-10-00-25-28.bpo-38109.9w-IGF.rst
M Lib/stat.py
M Lib/test/test_stat.py
diff --git a/Lib/stat.py b/Lib/stat.py
index a9c678ec03c9c..fc024db3f4fbe 100644
--- a/Lib/stat.py
+++ b/Lib/stat.py
@@ -40,6 +40,10 @@ def S_IFMT(mode):
S_IFIFO = 0o010000 # fifo (named pipe)
S_IFLNK = 0o120000 # symbolic link
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
@@ -71,6 +75,18 @@ def S_ISSOCK(mode):
"""Return True if mode is from a socket."""
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
S_ISUID = 0o4000 # set UID bit
diff --git a/Lib/test/test_stat.py b/Lib/test/test_stat.py
index 17443bed0738b..be01db2ed5574 100644
--- a/Lib/test/test_stat.py
+++ b/Lib/test/test_stat.py
@@ -16,10 +16,10 @@ class TestFilemode:
'UF_IMMUTABLE', 'UF_NODUMP', 'UF_NOUNLINK', 'UF_OPAQUE'}
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',
- 'S_ISREG', 'S_ISSOCK'}
+ 'S_ISREG', 'S_ISSOCK', 'S_ISDOOR', 'S_ISPORT', 'S_ISWHT'}
stat_struct = {
'ST_MODE': 0,
@@ -231,10 +231,6 @@ def test_file_attribute_constants(self):
class TestFilemodeCStat(TestFilemode, unittest.TestCase):
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):
statmod = py_stat
diff --git a/Misc/NEWS.d/next/Library/2019-10-10-00-25-28.bpo-38109.9w-IGF.rst b/Misc/NEWS.d/next/Library/2019-10-10-00-25-28.bpo-38109.9w-IGF.rst
new file mode 100644
index 0000000000000..3f4484dc644fa
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-10-10-00-25-28.bpo-38109.9w-IGF.rst
@@ -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`.
\ No newline at end of file
More information about the Python-checkins
mailing list