[issue30906] os.path.join misjoins paths

2017-07-13 Thread Steve Dower
Steve Dower added the comment: Fair point. I was thinking of how chdir handles it, but of course that's relative to the cwd on D, so the rest of the path on C is ignored. D:dir2 is correct. -- ___ Python tracker

[issue30906] os.path.join misjoins paths

2017-07-13 Thread Eryk Sun
Eryk Sun added the comment: BTW, I don't see why one would expect join(r"C:\dir1", "D:dir2") to return r"D:\dir1\dir2" instead of "D:dir2". Python's result is in agreement with Windows PathCchCombineEx. Paths on different drives should not be combined. The first path has to be ignored:

[issue30906] os.path.join misjoins paths

2017-07-13 Thread Eryk Sun
Eryk Sun added the comment: The difference compared to PathCchCombineEx stems from the following snippet in ntpath.join: if p_path and p_path[0] in seps: # Second path is absolute if p_drive or not result_drive: result_drive = p_dr

[issue30906] os.path.join misjoins paths

2017-07-13 Thread Steve Dower
Steve Dower added the comment: There's absolutely no risk of ignoring later parameters or raising a ValueError here, so please don't let those cloud the discussion. The behaviour of Python 3.6 seems to be correct for every case except: >>> os.path.join("C:\\dir1", "D:dir2") D:dir2 (

[issue30906] os.path.join misjoins paths

2017-07-12 Thread mesheb82
mesheb82 added the comment: Testing on Python 2.7.12 on through Windows 10 bash (so Linux), I find an inconsistency with the documented statement "If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component" >>> os.path.jo

[issue30906] os.path.join misjoins paths

2017-07-12 Thread Eric V. Smith
Eric V. Smith added the comment: We absolutely cannot change this to give an error if the second or subsequent parameters is absolute. I have code that reads user-named config files. If the path is relative, it's relative to a config directory, but it's allowed to be absolute: config_filename

[issue30906] os.path.join misjoins paths

2017-07-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I afraid that failing on os.path.join('', '/path') or os.path.join('.', '/path') can break a lot of code. > I'd be in favor of preserving the drive when encountering a component > starting with a separator. Already done (issue19456). >>> import ntpath >>>

[issue30906] os.path.join misjoins paths

2017-07-11 Thread Steve Dower
Steve Dower added the comment: > since a component starting with a slash *is not* an absolute path. -- ___ Python tracker ___ ___ Pyth

[issue30906] os.path.join misjoins paths

2017-07-11 Thread Steve Dower
Steve Dower added the comment: Arguably it isn't even against the documented behavior, since a component starting with a slash an absolute path. I'd be in favor of preserving the drive when encountering a component starting with a separator. Not sure of the value in changing the behavior in ol

[issue30906] os.path.join misjoins paths

2017-07-11 Thread Eryk Sun
Eryk Sun added the comment: This differs slightly from WinAPI PathCchCombineEx, which fails the example case as an invalid parameter. If the second path is rooted but without a drive or UNC share, then if the first path is relative it must be at least drive relative (e.g. "C:dir1"). Should Pyt

[issue30906] os.path.join misjoins paths

2017-07-11 Thread Paul Moore
Paul Moore added the comment: This is as documented - see https://docs.python.org/3.6/library/os.path.html#os.path.join (" If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component"). In this case, "/dir2" is an absolute

[issue30906] os.path.join misjoins paths

2017-07-11 Thread mesheb82
New submission from mesheb82: I'm trying to join paths on Windows with data taken from a user generated file. In doing so, I came across: >>> os.path.join('dir1', '/dir2') '/dir2' I'd expect an error or: 'dir1\\dir2' This has been tested and is consistent with Python 2.7.13 and