[issue43620] os.path.join does not use os.sep as documentation claims
New submission from Jared Sutton : The behavior of os.path.join() does not match the documentation, in regards to the use of os.sep. From the docs: """ The return value is the concatenation of path and any members of *paths with exactly one directory separator (os.sep) following each non-empty part except the last, meaning that the result will only end in a separator if the last part is empty. """ The documentation clearly states that the function uses the value of os.sep (which differs based on platform). However, if you review the 2 implementations (ntpath.py and posixpath.py), the separator character used is clearly hard-coded and doesn't reference os.sep at all. One could say that this is either a doc bug or an implementation bug, depending on what the intended behavior is. I submit that this is an implementation bug, as one might want to use os.path.join() to construct a path to be used on a platform other than the one currently running the application. For example, a person might be running Python on Windows, but calling a web API and constructing a path for use on a remote posix system. -- assignee: docs@python components: Documentation, Library (Lib) messages: 389489 nosy: docs@python, jpsutton priority: normal severity: normal status: open title: os.path.join does not use os.sep as documentation claims type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue43620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43620] os.path.join does not use os.sep as documentation claims
Jared Sutton added the comment: I can understand your suggestion to just utilize the posixpath library on Windows if needed. That's a reasonable work-around. But certainly you can see this is a doc bug, since the doc clearly states that os.sep is utilized to join the elements of the path, when it clearly isn't; right? -- components: -Library (Lib) ___ Python tracker <https://bugs.python.org/issue43620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43620] os.path.join does not use os.sep as documentation claims
Jared Sutton added the comment: > Perhaps Jared was expecting that modifying os.sep would affect the functions > in os.path? This is precisely what I thought, because the documentation makes it sound like that variable named os.sep is read and used as the path delimiter when constructing something with join(). In fact, that variable isn't read *at all* because the path separator is hard-coded in both posixpath.py and ntpath.py. Since os.sep isn't used, I see no reason why it should be referenced in the documentation at all. I'm not trying to be pedantic here (though we nerds are famous for that :) ), but what I see here is a disagreement between what is documented and what actually exists in the implementation. Yes the *value* of os.sep happens to be the same as the one hard-coded into either ntpath or posixpath, but since that variable is not referenced in the implementation, its presence in the doc only serves to confuse people who take the documentation at face value and then get an unexpected result. -- ___ Python tracker <https://bugs.python.org/issue43620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43620] os.path.join does not use os.sep as documentation claims
Change by Jared Sutton : -- keywords: +patch pull_requests: +23775 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/25025 ___ Python tracker <https://bugs.python.org/issue43620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43620] os.path.join does not use os.sep as documentation claims
Jared Sutton added the comment: Thank you for understanding my position, Fred. I submitted a draft PR (25025) for this bug. -- ___ Python tracker <https://bugs.python.org/issue43620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com