mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
closes bpo-34353: Add sockets to stat.filemode fallback python implementation. (GH-8703)
This commit is contained in:
parent
a7548230ff
commit
b92c526ed5
3 changed files with 12 additions and 0 deletions
|
@ -111,6 +111,7 @@ SF_SNAPSHOT = 0x00200000 # file is a snapshot file
|
||||||
|
|
||||||
_filemode_table = (
|
_filemode_table = (
|
||||||
((S_IFLNK, "l"),
|
((S_IFLNK, "l"),
|
||||||
|
(S_IFSOCK, "s"), # Must appear before IFREG and IFDIR as IFSOCK == IFREG | IFDIR
|
||||||
(S_IFREG, "-"),
|
(S_IFREG, "-"),
|
||||||
(S_IFBLK, "b"),
|
(S_IFBLK, "b"),
|
||||||
(S_IFDIR, "d"),
|
(S_IFDIR, "d"),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from test.support import TESTFN, import_fresh_module
|
from test.support import TESTFN, import_fresh_module
|
||||||
|
|
||||||
|
@ -191,6 +192,14 @@ class TestFilemode:
|
||||||
self.assertS_IS("BLK", st_mode)
|
self.assertS_IS("BLK", st_mode)
|
||||||
break
|
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):
|
def test_module_attributes(self):
|
||||||
for key, value in self.stat_struct.items():
|
for key, value in self.stat_struct.items():
|
||||||
modvalue = getattr(self.statmod, key)
|
modvalue = getattr(self.statmod, key)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Added the "socket" option in the `stat.filemode()` Python implementation to
|
||||||
|
match the C implementation.
|
Loading…
Add table
Add a link
Reference in a new issue