[issue18221] abspath strips trailing spaces on win32

2013-06-15 Thread Jeremy Gray

New submission from Jeremy Gray:

The behavior of os.path.abspath differs between Mac OS X and Windows. It seems 
like a bug that, on Windows, abspath strips trailing whitespace:
Windows:
>>> from os.path import abspath
>>> abspath('start  ') + 'END'
'c:\Users\jgray\code\startEND'
 ^
Mac:
>>> from os.path import abspath
>>> abspath('start  ') + 'END'
'/Users/jgray/code/start  END'
^^

I have only tested with python 2.7.3 (Enthought distribution), 32-bit, and only 
Mac 10.8.2 and Windows 7.

--
components: Windows
messages: 191202
nosy: Jeremy.Gray
priority: normal
severity: normal
status: open
title: abspath strips trailing spaces on win32
type: behavior
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue18221>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18221] abspath strips trailing spaces on win32

2013-06-15 Thread Jeremy Gray

Jeremy Gray added the comment:

Maybe this a documentation / run-time warning issue, rather than bug. Trailing 
spaces in filenames are illegal in Win32; nonetheless they can occur, because 
there are instructions on how to remove such files: 
http://support.microsoft.com/kb/320081. So os.path.abspath() not only returns 
the absolute path of a (hypothetical) file, it is also ensuring that the file 
name is legal within the operating system. It does so silently. (I say 
hypothetical because there's no requirement that the file actually exists.)

This behavior from python was surprising since "explicit is better than 
implicit": I was not getting just an absolute path, but a changed filename 
(causing a file-not-found error later in my code), with no warning from python 
at any point that the filename was illegal and so was being "cleaned up" for 
me, behind the scenes. Maybe this is the Windows-like way to do things 
(longtime mac / linux here).

Playing around a little, I see "open('file  ', 'wb')" also silently changes the 
filename.

--

___
Python tracker 
<http://bugs.python.org/issue18221>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com