Skip to content

Commit 64580da

Browse files
vstinnereryksun
andauthored
bpo-37412: pythoninfo: add Windows long paths (GH-14434)
On Windows, test.pythoninfo now checks if support for long paths is enabled using ntdll.RtlAreLongPathsEnabled() function. Co-Authored-By: Eryk Sun <[email protected]>
1 parent ec3e20a commit 64580da

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Lib/test/pythoninfo.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,29 @@ def collect_subprocess(info_add):
651651
copy_attributes(info_add, subprocess, 'subprocess.%s', ('_USE_POSIX_SPAWN',))
652652

653653

654+
def collect_windows(info_add):
655+
try:
656+
import ctypes
657+
except ImportError:
658+
return
659+
660+
if not hasattr(ctypes, 'WinDLL'):
661+
return
662+
663+
ntdll = ctypes.WinDLL('ntdll')
664+
BOOLEAN = ctypes.c_ubyte
665+
666+
try:
667+
RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
668+
except AttributeError:
669+
res = '<function not available>'
670+
else:
671+
RtlAreLongPathsEnabled.restype = BOOLEAN
672+
RtlAreLongPathsEnabled.argtypes = ()
673+
res = bool(RtlAreLongPathsEnabled())
674+
info_add('windows.RtlAreLongPathsEnabled', res)
675+
676+
654677
def collect_info(info):
655678
error = False
656679
info_add = info.add
@@ -684,6 +707,7 @@ def collect_info(info):
684707
collect_testcapi,
685708
collect_time,
686709
collect_tkinter,
710+
collect_windows,
687711
collect_zlib,
688712

689713
# Collecting from tests should be last as they have side effects.

0 commit comments

Comments
 (0)