diff options
author | GPery <GPery@pm.me> | 2018-08-10 05:12:08 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-08-10 05:12:08 (GMT) |
commit | b92c526ed5da474694f89e29d82565f2a654c29b (patch) | |
tree | 2ddd1982ae5cc38fedc927fbbd5752e8ea7ff93b /Lib | |
parent | a7548230ff6db5008c76e97f2597ebfdb41da19d (diff) | |
download | cpython-b92c526ed5da474694f89e29d82565f2a654c29b.zip cpython-b92c526ed5da474694f89e29d82565f2a654c29b.tar.gz cpython-b92c526ed5da474694f89e29d82565f2a654c29b.tar.bz2 |
closes bpo-34353: Add sockets to stat.filemode fallback python implementation. (GH-8703)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/stat.py | 1 | ||||
-rw-r--r-- | Lib/test/test_stat.py | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Lib/stat.py b/Lib/stat.py index 46837c0..a9c678e 100644 --- a/Lib/stat.py +++ b/Lib/stat.py @@ -111,6 +111,7 @@ SF_SNAPSHOT = 0x00200000 # file is a snapshot file _filemode_table = ( ((S_IFLNK, "l"), + (S_IFSOCK, "s"), # Must appear before IFREG and IFDIR as IFSOCK == IFREG | IFDIR (S_IFREG, "-"), (S_IFBLK, "b"), (S_IFDIR, "d"), diff --git a/Lib/test/test_stat.py b/Lib/test/test_stat.py index 73cd901..38ff2bc 100644 --- a/Lib/test/test_stat.py +++ b/Lib/test/test_stat.py @@ -1,5 +1,6 @@ import unittest import os +import socket import sys from test.support import TESTFN, import_fresh_module @@ -191,6 +192,14 @@ class TestFilemode: self.assertS_IS("BLK", st_mode) break + @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix socket') + def test_socket(self): + with socket.socket(socket.AF_UNIX) as s: + s.bind(TESTFN) + st_mode, modestr = self.get_mode() + self.assertEqual(modestr[0], 's') + self.assertS_IS("SOCK", st_mode) + def test_module_attributes(self): for key, value in self.stat_struct.items(): modvalue = getattr(self.statmod, key) |