Skip to content

Commit 19ab0fd

Browse files
committed
Issue #27731: Opt-out of MAX_PATH on Windows 10
1 parent 437df90 commit 19ab0fd

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

Doc/using/windows.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,31 @@ installation". In this case:
7474
* If selected, the install directory will be added to the system :envvar:`PATH`
7575
* Shortcuts are available for all users
7676

77+
.. _max-path:
78+
79+
Removing the MAX_PATH Limitation
80+
--------------------------------
81+
82+
Windows historically has limited path lengths to 260 characters. This meant that
83+
paths longer than this would not resolve and errors would result.
84+
85+
In the latest versions of Windows, this limitation can be expanded to
86+
approximately 32,000 characters. Your administrator will need to activate the
87+
"Enable Win32 long paths" group policy, or set the registry value
88+
``HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled``
89+
to ``1``.
90+
91+
This allows the :func:`open` function, the :mod:`os` module and most other
92+
path functionality to accept and return paths longer than 260 characters when
93+
using strings. (Use of bytes as paths is deprecated on Windows, and this feature
94+
is not available when using bytes.)
95+
96+
After changing the above option, no further configuration is required.
97+
98+
.. versionchanged:: 3.6
99+
100+
Support for long paths was enabled in Python.
101+
77102
.. _install-quiet-option:
78103

79104
Installing Without UI

Doc/whatsnew/3.6.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Windows improvements:
8383
command line arguments or a config file). Handling of shebang lines
8484
remains unchanged - "python" refers to Python 2 in that case.
8585

86+
* ``python.exe`` and ``pythonw.exe`` have been marked as long-path aware,
87+
which means that when the 260 character path limit may no longer apply.
88+
See :ref:`removing the MAX_PATH limitation <max-path>` for details.
89+
8690
.. PEP-sized items next.
8791
8892
.. _pep-4XX:
@@ -507,7 +511,6 @@ The Linux ``getrandom()`` syscall (get random bytes) is now exposed as the new
507511
:func:`os.getrandom` function.
508512
(Contributed by Victor Stinner, part of the :pep:`524`)
509513

510-
511514
pickle
512515
------
513516

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ Build
237237
Windows
238238
-------
239239

240+
- Issue #27731: Opt-out of MAX_PATH on Windows 10
241+
240242
- Issue #6135: Adds encoding and errors parameters to subprocess.
241243

242244
- Issue #27959: Adds oem encoding, alias ansi to mbcs, move aliasmbcs to

PC/python.manifest

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
1717
</application>
1818
</compatibility>
19+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
20+
<windowsSettings>
21+
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
22+
</windowsSettings>
23+
</application>
1924
<dependency>
2025
<dependentAssembly>
2126
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
2227
version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
2328
</dependentAssembly>
2429
</dependency>
25-
</assembly>
30+
</assembly>

0 commit comments

Comments
 (0)