New submission from Jared Sutton <jpsut...@gmail.com>:
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 <rep...@bugs.python.org> <https://bugs.python.org/issue43620> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com