Skip to content

Commit 659c450

Browse files
committed
make FILE_ATTRIBUTE__* available on all platforms
Fixes: #14865
1 parent 7765087 commit 659c450

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

stdlib/@tests/stubtest_allowlists/darwin.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ multiprocessing.popen_spawn_win32 # exists on Darwin but fails to import
4545
readline.append_history_file # Only available if compiled with GNU readline, not editline
4646
select.poll # Actually a function; we have a class so it can be used as a type
4747

48-
# Some of these exist on non-windows, but they are useless and this is not intended
49-
stat.FILE_ATTRIBUTE_[A-Z_]+
50-
5148
tkinter.Tk.createfilehandler # Methods that come from __getattr__() at runtime
5249
tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime
5350

stdlib/@tests/stubtest_allowlists/linux.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ _?socket.SOL_IPX
5454
_?socket.SOL_NETROM
5555
_?socket.SOL_ROSE
5656

57-
# Some of these exist on non-windows, but they are useless and this is not intended
58-
stat.FILE_ATTRIBUTE_[A-Z_]+
59-
6057
# This is available on Linux, but it's documented as for kernel debugging and
6158
# not present on GitHub Actions runners.
6259
termios.TIOCTTYGSTRUCT

stdlib/stat.pyi

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1+
# pyright: reportConstantRedefinition=false
2+
13
import sys
2-
from _stat import *
4+
from _stat import * # pyright: ignore[reportGeneralTypeIssues]
35
from typing import Final
46

7+
# _stat.py defines FILE_ATTRIBUTE_* constants conditionally,
8+
# making them available only at runtime on Windows.
9+
# stat.py unconditionally redefines the same FILE_ATTRIBUTE_* constants
10+
# on all platforms.
11+
# See:
12+
# <https://github.com/python/cpython/blob/447c7a89fb41b7fa84b9b26f111aedd649bc5400/Lib/stat.py#L181-L200>
13+
FILE_ATTRIBUTE_ARCHIVE: Final = 32
14+
FILE_ATTRIBUTE_COMPRESSED: Final = 2048
15+
FILE_ATTRIBUTE_DEVICE: Final = 64
16+
FILE_ATTRIBUTE_DIRECTORY: Final = 16
17+
FILE_ATTRIBUTE_ENCRYPTED: Final = 16384
18+
FILE_ATTRIBUTE_HIDDEN: Final = 2
19+
FILE_ATTRIBUTE_INTEGRITY_STREAM: Final = 32768
20+
FILE_ATTRIBUTE_NORMAL: Final = 128
21+
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Final = 8192
22+
FILE_ATTRIBUTE_NO_SCRUB_DATA: Final = 131072
23+
FILE_ATTRIBUTE_OFFLINE: Final = 4096
24+
FILE_ATTRIBUTE_READONLY: Final = 1
25+
FILE_ATTRIBUTE_REPARSE_POINT: Final = 1024
26+
FILE_ATTRIBUTE_SPARSE_FILE: Final = 512
27+
FILE_ATTRIBUTE_SYSTEM: Final = 4
28+
FILE_ATTRIBUTE_TEMPORARY: Final = 256
29+
FILE_ATTRIBUTE_VIRTUAL: Final = 65536
30+
531
if sys.version_info >= (3, 13):
632
# https://github.com/python/cpython/issues/114081#issuecomment-2119017790
733
SF_RESTRICTED: Final = 0x00080000

0 commit comments

Comments
 (0)