New submission from tegavu:

Windows does not like/permit folders with spaces in the beginning or folders 
and files with a tailing space character, as this will cause problems.
The python functions for os.mkdir will solve this by eliminating the blanks 
automatically.
But os.path.join() will give wrong results.

Example:

#Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23)
import os
dir1 = "c:\\"
dir2 = "test   "
file = "test.txt"     

os.mkdir( os.path.join(dir1, dir2) )    
    # this will correctly create c:\test\
f = open( os.path.join(dir1, dir2, file) ,"wb")
    # this will fail with 'FileNotFoundError: [Errno 2] No such file or 
directory: 'c:\\test     \\test.txt''
print("__" + os.path.join(dir1, dir2, file) + "__")   
    # this will incorrectly show 'c:\test     \test.txt'
    # or if you chose to also have spaces at the end of "test.txt     " will 
show them

----------
messages: 230082
nosy: tegavu
priority: normal
severity: normal
status: open
title: os.path.join on Windows creates invalid paths with spaces
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22744>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to