This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年09月07日 16:40 by kaba2, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (9) | |||
|---|---|---|---|
| msg169990 - (view) | Author: Kalle Rutanen (kaba2) | Date: 2012年09月07日 16:40 | |
On Windows, long-UNC paths are needed to inspect and modify paths with more than 260 characters. The os.path.split() function behaves incorrectly in the presence of a long-UNC prefix //?/ or \\?\. Consider iterating d = os.path.split(d)[0] with d = '//?/e:/python-test/dir'. Then the values of d are as follows:
'//?/e:/python-test/dir'
'//?/e:/python-test'
'//?/e:'
'//?'
'//'
The two last splits are the incorrect ones, where the splitting should end at '//?/e:'.
One consequence of this is that os.makedirs(d) crashes, because it attempts to run os.mkdir('//') at the bottom of its recursion. The same thing happens when replacing all / with \\ in the above.
|
|||
| msg169992 - (view) | Author: Kalle Rutanen (kaba2) | Date: 2012年09月07日 16:50 | |
By inspecting the code for os.path.split() in ntpath.py, one sees that the problem is actually in os.path.splitdrive(), which does not handle long-UNC paths. |
|||
| msg169995 - (view) | Author: Kalle Rutanen (kaba2) | Date: 2012年09月07日 17:06 | |
It seems to me that this problem can be fixed by replacing splitdrive with splitunc at line 170 in ntpath.py. |
|||
| msg172450 - (view) | Author: Kushal Das (kushal.das) * (Python committer) | Date: 2012年10月09日 05:58 | |
splitunc is deprecated since 3.1. It is also written in the code that "Paths containing drive letters never have an UNC part" |
|||
| msg174486 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年11月02日 00:06 | |
This behavior reproduced only on 2.7. See issue5799 which changed the behavior for 3.1. |
|||
| msg175427 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年11月12日 09:09 | |
I propose to close this issue as "won't fix". A long-UNC prefix support is a new feature and can't be applied to 2.7. As workaround use splitunc() in Python prior to 3.1. |
|||
| msg175465 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年11月12日 19:30 | |
I agree. Larry H.'s patch in #5799 was called an enhancement and is explicitly a replacement for splitunc. The latter was deprecated and may disappear in 3.4. |
|||
| msg175468 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年11月12日 20:00 | |
ISTM that fixing this for 3.x (3? 4?) is worthwhile though. Or did somebody already fix it in 3.x? |
|||
| msg175469 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年11月12日 20:11 | |
Serhiy claims that the commit of Mark's version of your patch in #5799 fixed this in 3.1. Retesting in IDLE, 3.3, Win7: >>> import os >>> d = '//?/e:/python-test/dir' >>> d = os.path.split(d)[0] >>> d '//?/e:/python-test' >>> d = os.path.split(d)[0] >>> d '//?/e:/' >>> d = os.path.split(d)[0] >>> d '//?/e:/' So the splitting ends where Kalle agrees it should. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:35 | admin | set | github: 60084 |
| 2012年11月12日 20:11:44 | terry.reedy | set | messages: + msg175469 |
| 2012年11月12日 20:00:18 | larry | set | messages: + msg175468 |
| 2012年11月12日 19:30:00 | terry.reedy | set | status: pending -> closed resolution: wont fix messages: + msg175465 stage: test needed -> resolved |
| 2012年11月12日 09:09:43 | serhiy.storchaka | set | status: open -> pending messages: + msg175427 |
| 2012年11月02日 00:06:21 | serhiy.storchaka | set | nosy:
+ mhammond, larry, serhiy.storchaka messages: + msg174486 versions: - Python 3.2, Python 3.3 |
| 2012年11月01日 23:35:37 | kevin.chen | set | nosy:
+ kevin.chen |
| 2012年10月09日 05:58:39 | kushal.das | set | nosy:
+ kushal.das messages: + msg172450 |
| 2012年09月15日 06:02:18 | ezio.melotti | set | versions:
+ Python 3.2, Python 3.3 nosy: + ezio.melotti keywords: + easy type: crash -> behavior stage: test needed |
| 2012年09月14日 17:45:18 | terry.reedy | set | nosy:
+ terry.reedy |
| 2012年09月07日 17:06:53 | kaba2 | set | messages: + msg169995 |
| 2012年09月07日 16:50:50 | kaba2 | set | messages: + msg169992 |
| 2012年09月07日 16:40:15 | kaba2 | create | |