This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.path.join('/some/path', '') adds extra slash at end of result
Type: behavior Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: os.path.join('x','') behavior
View: 9921
Assigned To: Nosy List: brian.curtin, r.david.murray, socketpair
Priority: normal Keywords:

Created on 2011-05-18 19:05 by socketpair, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg136258 - (view) Author: Марк Коренберг (socketpair) * Date: 2011-05-18 19:05
os.path.join('/some/path', '') adds extra slash at end of result. I expect in that case return value should be '/some/path' but not '/some/path/'
msg136331 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-05-19 19:45
This is intentional. See the implementation of join in Lib/posixpath.py and the Windows implementation in Lib/ntpath.py which also includes a comment explaining why.

# path is not empty and does not end with a backslash,
# but b is empty; since, e.g., split('a/') produces
# ('a', ''), it's best if join() adds a backslash in
# this case.
msg136351 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-05-20 03:20
See also #9921.
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56313
2011-05-20 03:20:07r.david.murraysetnosy: + r.david.murray
messages: + msg136351
resolution: rejected -> duplicate

superseder: os.path.join('x','') behavior
2011-05-19 19:45:52brian.curtinsetstatus: open -> closed

nosy: + brian.curtin
messages: + msg136331

resolution: rejected
stage: resolved
2011-05-18 19:05:26socketpaircreate