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 2009年01月31日 07:25 by eli.bendersky, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_relpath_v3.patch | ocean-city, 2009年01月31日 17:16 | review | ||
| py3k_fix_relpath.patch | ocean-city, 2010年10月02日 14:10 | review | ||
| py27_fix_relpath.patch | ocean-city, 2010年10月02日 19:55 | review | ||
| Messages (19) | |||
|---|---|---|---|
| msg80860 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2009年01月31日 07:25 | |
This is correct: relpath(r'd:\abc\jho', r'd:\abc') => 'jho' But this isn't: relpath(r'd:\jho', r'd:\\') => '..\jho' Neither is this: relpath(r'd:\jho', r'd:') => '..\..\..\jho' |
|||
| msg80861 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2009年01月31日 08:34 | |
About this, >But this isn't: >relpath(r'd:\jho', r'd:\\') >=> '..\jho' Same happens on posixpath. from posixpath import relpath print relpath(r'/abc', r'/') #=> ../abc I'll look at the code. |
|||
| msg80862 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2009年01月31日 08:46 | |
The problem is with these lines: start_list = abspath(start).split(sep) path_list = abspath(path).split(sep) In case of 'd:\', the split returns two elements, the second empty. |
|||
| msg80863 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2009年01月31日 09:20 | |
I hope attached patch will fix this bug. |
|||
| msg80877 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2009年01月31日 16:21 | |
It seems that there is still problem.
>>> ntpath.relpath("//whiterab-c2znlh/foo/", "//whiterab-c2znlh/bar/")
'..\\foo'
This should raise ValueError because "//whiterab-c2znlh/foo" is UNC root
prefix (like "e:" for normal path) not "//whiterab-c2znlh" AFAIK.
I'll look into more deeper...
|
|||
| msg80880 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2009年01月31日 17:16 | |
I hope this works. |
|||
| msg83146 - (view) | Author: Jim Blandy (jimb) | Date: 2009年03月04日 22:01 | |
In case the behavior requested here is controversial, here's an example
of where it would be nice to have relpath(x, '/') return a path for x
that is relative to the root directory:
The 'oprofile' system profiler for Linux profiles everything running on
the system at once. Its profile count database takes the form of a
directory tree of counter files that mirrors the whole filesystem:
/var/lib/oprofile/samples/current/{root}/bin/ls holds the samples for
/bin/ls, and so on. Also, the 'opannotate' command annotates source
trees with profile counts: if /bin/ls were built from /src/ls.c, then
'opannotate -o ~/ann-tree' would put a count-annotated copy of ls's
source '~/ann-tree/src/ls.c'.
At the moment, I wish I could simply say:
src=path to source file
real_src = os.path.realpath(src)
rel_real_src = os.path.relpath(real_src, '/')
annotated_source = os.path.join(annotation_dir, rel_real_src)
but this bug gets in the way.
|
|||
| msg90061 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2009年07月03日 14:25 | |
Maybe this patch should be updated because os.path functions changed their behaviors for UNC in py3k. (#5799) |
|||
| msg110994 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2010年07月21日 02:59 | |
msg90061 refers to #5799 which is closed, fixed. Will the attached patch need reworking as a result of the #5799 change? |
|||
| msg117876 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月02日 14:10 | |
In py3k, ntpath is almost fixed. but posixpath is not fixed yet. ntpath has another problem about case sensitivity. I'll attach the patch to fix ntpath's case issue and posixpath. In Py27, ntpath has whole issue still there. |
|||
| msg117877 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月02日 14:11 | |
I'll create the patch for it. |
|||
| msg117894 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月02日 19:55 | |
Well, I said msg80877 past, and I think so too, but os.path module of python2.x seems not to support UNC correctly, and I'm not sure if the behavior change is allowed here. Probably UNC support is new feature, so I'll attach the patch to solve only this problem as is. |
|||
| msg119018 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月18日 13:57 | |
Committed fixes in r85689(py3k), r85693(release31-maint), r85694(release27-maint). (This should work because I simply ported already working fix in ntpath.relpath) |
|||
| msg119024 - (view) | Author: Stephen Hansen (ixokai) (Python triager) | Date: 2010年10月18日 14:41 | |
FYI, this fix broke some buildbots: http://www.python.org/dev/buildbot/all/builders/x86%20Snow%20Leopard%202.7/builds/50 for instance. Gentoo too. |
|||
| msg119068 - (view) | Author: Bill Janssen (janssen) * (Python committer) | Date: 2010年10月18日 19:22 | |
Broke bunches of 2.7 buildbots. But why are we running test_ntpath on OS X, anyway? Shouldn't this be skipped everywhere except win32 platforms? |
|||
| msg119069 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2010年10月18日 19:23 | |
No - the posixpath/ntpath routines are meant to be usable for path manipulation for posix/NT paths on any platform. |
|||
| msg119070 - (view) | Author: Bill Janssen (janssen) * (Python committer) | Date: 2010年10月18日 19:25 | |
Then we need to revert this patch and find one that works. |
|||
| msg119100 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月19日 01:25 | |
Sorry, I've commit the fix in r85717(release27-maint). I'll sit and watch buildbot. |
|||
| msg119101 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月19日 01:59 | |
I confirmed test runs fine on x86 Snow Leopard 2.7. So I'm closing this issue.... |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:45 | admin | set | github: 49367 |
| 2010年10月19日 01:59:36 | ocean-city | set | status: open -> closed resolution: fixed messages: + msg119101 |
| 2010年10月19日 01:25:54 | ocean-city | set | messages: + msg119100 |
| 2010年10月18日 19:25:02 | janssen | set | resolution: fixed -> (no value) messages: + msg119070 |
| 2010年10月18日 19:23:59 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg119069 |
| 2010年10月18日 19:22:09 | janssen | set | nosy:
+ janssen messages: + msg119068 |
| 2010年10月18日 18:34:41 | georg.brandl | set | status: closed -> open |
| 2010年10月18日 14:41:49 | ixokai | set | nosy:
+ ixokai messages: + msg119024 |
| 2010年10月18日 13:57:56 | ocean-city | set | status: open -> closed resolution: fixed messages: + msg119018 stage: commit review -> resolved |
| 2010年10月08日 13:16:15 | ocean-city | set | stage: patch review -> commit review |
| 2010年10月02日 19:55:31 | ocean-city | set | files:
+ py27_fix_relpath.patch messages: + msg117894 |
| 2010年10月02日 14:11:50 | ocean-city | set | messages:
+ msg117877 versions: - Python 2.6 |
| 2010年10月02日 14:10:40 | ocean-city | set | files:
+ py3k_fix_relpath.patch messages: + msg117876 |
| 2010年09月29日 08:51:50 | eckhardt | set | nosy:
+ eckhardt |
| 2010年07月21日 02:59:05 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg110994 |
| 2009年07月03日 14:28:59 | ocean-city | set | versions: + Python 3.2, - Python 3.0 |
| 2009年07月03日 14:25:30 | ocean-city | set | dependencies:
+ Change ntpath functions to implicitly support UNC paths messages: + msg90061 |
| 2009年04月22日 14:39:08 | ajaksu2 | set | priority: normal stage: patch review |
| 2009年03月04日 22:01:21 | jimb | set | nosy:
+ jimb messages: + msg83146 |
| 2009年02月01日 10:56:43 | ocean-city | set | title: os.path.relpath problem with root drive directory on windows -> os.path.relpath problem with root directory |
| 2009年02月01日 07:41:43 | ocean-city | set | versions: + Python 3.0, Python 3.1, Python 2.7 |
| 2009年01月31日 17:17:00 | ocean-city | set | messages: - msg80864 |
| 2009年01月31日 17:16:47 | ocean-city | set | files: - fix_relpath_v2.patch |
| 2009年01月31日 17:16:35 | ocean-city | set | files: - fix_relpath.patch |
| 2009年01月31日 17:16:22 | ocean-city | set | files:
+ fix_relpath_v3.patch messages: + msg80880 |
| 2009年01月31日 16:21:54 | ocean-city | set | messages: + msg80877 |
| 2009年01月31日 10:17:41 | ocean-city | set | files: + fix_relpath_v2.patch |
| 2009年01月31日 10:17:24 | ocean-city | set | files: - fix_relpath_v2.patch |
| 2009年01月31日 10:01:57 | ocean-city | set | files:
+ fix_relpath_v2.patch messages: + msg80864 |
| 2009年01月31日 09:20:20 | ocean-city | set | files:
+ fix_relpath.patch keywords: + patch messages: + msg80863 |
| 2009年01月31日 08:46:39 | eli.bendersky | set | messages: + msg80862 |
| 2009年01月31日 08:34:59 | ocean-city | set | nosy:
+ ocean-city messages: + msg80861 |
| 2009年01月31日 07:25:51 | eli.bendersky | create | |