Re: Does os.path relpath produce an incorrect relative path?

2023-05-27 Thread BlindAnagram
On 26/05/2023 16:42, Eryk Sun wrote: On 5/26/23, cactus wrote: Surprisingly (for me at least) the alternative provided by the pathlib module 'relative_to' method doesn't provide for full relative path computation. I was expecting this would offer everything that os.path offers but it doesn't

Re: Does os.path relpath produce an incorrect relative path?

2023-05-26 Thread Eryk Sun
On 5/26/23, cactus wrote: > > Surprisingly (for me at least) the alternative provided by the pathlib > module 'relative_to' method doesn't provide for full relative path > computation. I was expecting this would offer everything that os.path > offers but it doesn't in this case. Starting with

Re: Does os.path relpath produce an incorrect relative path?

2023-05-26 Thread cactus
On Thursday, 25 May 2023 at 17:57:21 UTC+1, MRAB wrote: > On 2023-05-25 16:53, Eryk Sun wrote: > > On 5/25/23, BlindAnagram wrote: > >> > >> vcx_path = 'C:\\build.vs22\\lib\\lib.vcxproj' > >> src_path = 'C:\\lib\\src\\' > >> rel_path = '..\\..\\..\\lib\\src' > >> > >> [snip] > >> > >> The

Re: Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread MRAB
On 2023-05-25 16:53, Eryk Sun wrote: On 5/25/23, BlindAnagram wrote: vcx_path = 'C:\\build.vs22\\lib\\lib.vcxproj' src_path = 'C:\\lib\\src\\' rel_path = '..\\..\\..\\lib\\src' [snip] The first of these three results produces an incorrect relative path because relpath does not strip off any

Re: Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread Greg Ewing via Python-list
On 25/05/23 7:49 pm, BlindAnagram wrote: The first of these three results produces an incorrect relative path because relpath does not strip off any non-directory tails before comparing paths. It has no way of knowing whether a pathname component is a directory or not. It's purely an

Re: Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread Eryk Sun
On 5/25/23, BlindAnagram wrote: > > vcx_path = 'C:\\build.vs22\\lib\\lib.vcxproj' > src_path = 'C:\\lib\\src\\' > rel_path = '..\\..\\..\\lib\\src' > > [snip] > > The first of these three results produces an incorrect relative path > because relpath does not strip off any non-directory tails

Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread BlindAnagram
I am wondering whether I have misunderstood the semantics of os.path relpath or whether it has a bug. Here is a short test program: --- from os.path import relpath, split src_path = 'C:\\lib\\src\\' vcx_path =