Message228883
On Windows, os.path.abspath() treats None as if it were an empty string, so os.path.abspath(None) returns the current working directory. On Linux, os.path.abspath(None) raises an AttributeError. With macpath, abspath(None) raises a TypeError. I've seen this behavior with Python 2.7.3, 2.7.8, 3.2.5, and 3.4.2.
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ntpath, posixpath, macpath
>>> ntpath.abspath(None)
'C:\\Users\\Keating\\Documents'
>>> posixpath.abspath(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\programs\Python34\lib\posixpath.py", line 357, in abspath
if not isabs(path):
File "C:\programs\Python34\lib\posixpath.py", line 63, in isabs
return s.startswith(sep)
AttributeError: 'NoneType' object has no attribute 'startswith'
>>> macpath.abspath(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\programs\Python34\lib\macpath.py", line 177, in abspath
if not isabs(path):
File "C:\programs\Python34\lib\macpath.py", line 49, in isabs
return colon in s and s[:1] != colon
TypeError: argument of type 'NoneType' is not iterable
This case seems very closely related to http://bugs.python.org/issue9018, which noted a platform inconsistency in os.path.normcase. |
|
Date |
User |
Action |
Args |
2014-10-09 16:56:14 | KevKeating | set | recipients:
+ KevKeating |
2014-10-09 16:56:13 | KevKeating | set | messageid: <1412873773.97.0.374832942416.issue22587@psf.upfronthosting.co.za> |
2014-10-09 16:56:13 | KevKeating | link | issue22587 messages |
2014-10-09 16:56:13 | KevKeating | create | |
|