[New-bugs-announce] [issue21336] ntpath.splitdrive fails on None argument

Ben Ma report at bugs.python.org
Wed Apr 23 18:57:20 CEST 2014


New submission from Ben Ma:

>>> import ntpath
>>> ntpath.splitdrive(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\python3\lib\ntpath.py", line 159, in splitdrive
    if p and len(p) > 1:
TypeError: object of type 'NoneType' has no len()

Solution: (that I've found)

Lib/ntpath.py
#in function splitdrive
...
    empty = _get_empty(p)
+++ if p and len(p) > 1:
--- if len(p) > 1:
        sep = _get_sep(p)
...
            return p[:2], p[2:]
+++ else:
+++     p = ''
    return empty, p
...

----------
components: Library (Lib)
messages: 217077
nosy: runapp
priority: normal
severity: normal
status: open
title: ntpath.splitdrive fails on None argument
type: crash
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21336>
_______________________________________


More information about the New-bugs-announce mailing list