[New-bugs-announce] [issue41509] ntpath.relpath behaves differently on Windows with trailing spaces
Jason R. Coombs
report at bugs.python.org
Sat Aug 8 13:34:37 EDT 2020
New submission from Jason R. Coombs <jaraco at jaraco.com>:
On Windows:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ntpath
>>> ntpath.relpath('foo ', 'foo')
'.'
On macOS:
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ntpath
>>> ntpath.relpath('foo ', 'foo')
'..\\foo '
I stumbled into this issue when troubleshooting an [issue in a Setuptools PR](https://github.com/pypa/setuptools/pull/2305#issuecomment-670946965).
I suspect the Windows version is using some API that strips whitespace from the filename before performing a relative path. However, when using relpath to detect characters after a common path, stripping the whitespace can cause problems.
I wouldn't expect Windows to be performing normalization of paths in relpath, but it seems it does. If this behavior is by design and has a good reason, that behavior should be mirrored in the non-Windows implementation.
----------
components: Windows
messages: 375053
nosy: jaraco, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: ntpath.relpath behaves differently on Windows with trailing spaces
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41509>
_______________________________________
More information about the New-bugs-announce
mailing list