[Python-checkins] cpython: Issue #27731: Opt-out of MAX_PATH on Windows 10

steve.dower python-checkins at python.org
Tue Sep 6 23:40:25 EDT 2016


https://hg.python.org/cpython/rev/26601191b368
changeset:   103205:26601191b368
user:        Steve Dower <steve.dower at microsoft.com>
date:        Tue Sep 06 20:40:11 2016 -0700
summary:
  Issue #27731: Opt-out of MAX_PATH on Windows 10

files:
  Doc/using/windows.rst |  25 +++++++++++++++++++++++++
  Doc/whatsnew/3.6.rst  |   5 ++++-
  Misc/NEWS             |   2 ++
  PC/python.manifest    |   7 ++++++-
  4 files changed, 37 insertions(+), 2 deletions(-)


diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -74,6 +74,31 @@
 * If selected, the install directory will be added to the system :envvar:`PATH`
 * Shortcuts are available for all users
 
+.. _max-path:
+
+Removing the MAX_PATH Limitation
+--------------------------------
+
+Windows historically has limited path lengths to 260 characters. This meant that
+paths longer than this would not resolve and errors would result.
+
+In the latest versions of Windows, this limitation can be expanded to
+approximately 32,000 characters. Your administrator will need to activate the
+"Enable Win32 long paths" group policy, or set the registry value
+``HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem at LongPathsEnabled``
+to ``1``.
+
+This allows the :func:`open` function, the :mod:`os` module and most other
+path functionality to accept and return paths longer than 260 characters when
+using strings. (Use of bytes as paths is deprecated on Windows, and this feature
+is not available when using bytes.)
+
+After changing the above option, no further configuration is required.
+
+.. versionchanged:: 3.6
+
+   Support for long paths was enabled in Python.
+
 .. _install-quiet-option:
 
 Installing Without UI
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -83,6 +83,10 @@
   command line arguments or a config file).  Handling of shebang lines
   remains unchanged - "python" refers to Python 2 in that case.
 
+* ``python.exe`` and ``pythonw.exe`` have been marked as long-path aware,
+  which means that when the 260 character path limit may no longer apply.
+  See :ref:`removing the MAX_PATH limitation <max-path>` for details.
+
 .. PEP-sized items next.
 
 .. _pep-4XX:
@@ -507,7 +511,6 @@
 :func:`os.getrandom` function.
 (Contributed by Victor Stinner, part of the :pep:`524`)
 
-
 pickle
 ------
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -237,6 +237,8 @@
 Windows
 -------
 
+- Issue #27731: Opt-out of MAX_PATH on Windows 10
+
 - Issue #6135: Adds encoding and errors parameters to subprocess.
 
 - Issue #27959: Adds oem encoding, alias ansi to mbcs, move aliasmbcs to
diff --git a/PC/python.manifest b/PC/python.manifest
--- a/PC/python.manifest
+++ b/PC/python.manifest
@@ -16,10 +16,15 @@
       <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
     </application> 
   </compatibility>
+  <application xmlns="urn:schemas-microsoft-com:asm.v3">
+    <windowsSettings>
+      <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
+    </windowsSettings>
+  </application>
   <dependency>
     <dependentAssembly>
       <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
                         version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
     </dependentAssembly>
   </dependency>
-</assembly>
\ No newline at end of file
+</assembly>

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list