python.exe崩溃时,在打开的窗口长路7

问题描述:

的Python崩溃时我做以下步骤:python.exe崩溃时,在打开的窗口长路7

os.makedirs(ur'\\?\c:\测试文件夹') 
open(ur'\\?\c:\测试文件夹\t.txt','w') 

你可以看到完整的路径在这里: http://psf.upfronthosting.co.za/roundup/meta/issue629%3E

enter image description here

+0

也许这是一个权限问题? –

+0

我自己并不是Windows用户,但不会Windows报告WindowsError:[错误5]访问被拒绝或类似的权限问题? – errata

+0

请访问链接,这是一个漫长的路径问题 – aokaywe

Windows有一个包含256个字符的路径长度限制(包括盘符后的所有内容);这个问题似乎是你的路径超过了这个限制。如果您尝试通过Windows资源管理器手动创建该路径,我想您会发现该路径无法在该处创建。

从MSDN文档(link):

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

+0

当您在路径之前添加UNC前缀时,windows suport unicode路径。在我的系统中,os.makedirs()和os.listdir()是可以的,但是打开函数并不好。 – aokaywe

+0

绝对,但问题是路径的总体长度*,而不是它的组件。我已经用相关的引文更新了我的答案。 – jshrimp29

+0

hi @ jshrimp29,请查看https://bugs.python.org/issue18199,在我的系统中,unicode长路径对os.makedirs()和os.listdir()正常工作,但不能用于打开函数。 – aokaywe

感谢所有。 它可能是macfee注入python.exe进程。 请参阅:https://bugs.python.org/issue30494