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() wrong concatenation of "C:" on Windows
Type: behavior Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Eugene Bright, benhoyt, eric.smith
Priority: normal Keywords:

Created on 2015-02-27 12:20 by Eugene Bright, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg236739 - (view) Author: Eugene Bright (Eugene Bright) Date: 2015-02-27 12:20
Hello!

I found strange os.path.join() behavior on Windows.

It works fine in common case.
>>> os.path.join("C", "filename")
'C\\filename'

But if first argument is "C:" there are no backslashes added at all!

>>> os.path.join("C:", "filename")
'C:filename'

But I expect two inserted backslashes...

>>> sys.version
'3.4.1 |Anaconda 2.1.0 (64-bit)| (default, Sep 24 2014, 18:32:42) [MSC v.1600 64 bit (AMD64)]'

Is there a bug?
Thanks!
msg236742 - (view) Author: Ben Hoyt (benhoyt) * Date: 2015-02-27 13:01
Sorry, but this is operating as designed and documented. See the docs here: https://docs.python.org/3.4/library/os.path.html#os.path.join

"On Windows ... since there is a current directory for each drive, os.path.join("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not c:\foo.

So I think this issue should be closed as not a bug.
msg236744 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-02-27 13:22
I agree this isn't a bug, due to per-drive current directories on Windows.
msg236834 - (view) Author: Eugene Bright (Eugene Bright) Date: 2015-02-27 20:42
Sorry for disturbing.
I'll read docs more careful next time.
History
Date User Action Args
2022-04-11 14:58:13adminsetgithub: 67723
2015-02-27 20:42:46Eugene Brightsetmessages: + msg236834
2015-02-27 13:22:31eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg236744

resolution: not a bug
stage: resolved
2015-02-27 13:01:51benhoytsetnosy: + benhoyt
messages: + msg236742
2015-02-27 12:21:45Eugene Brightsettype: behavior
versions: + Python 3.4
2015-02-27 12:20:32Eugene Brightcreate