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.

Title: ntpath.splitdrive fails on None argument
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bpqpng, eric.smith
Priority: normal Keywords:

Created on 2014-04-23 16:57 by bpqpng, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg217077 - (view) Author: a (bpqpng) Date: 2014-04-23 16:57
>>> import ntpath
>>> ntpath.splitdrive(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\python3\lib\", line 159, in splitdrive
    if p and len(p) > 1:
TypeError: object of type 'NoneType' has no len()

Solution: (that I've found)

#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
msg217078 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-04-23 17:20
Why are you passing None, and what would you expect the result to be?

The function is documented as taking a string.
msg217160 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-04-25 14:27
I'm going to close this as "not a bug". Feel free to reopen it if there's use case for passing in None.
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65535
2014-04-25 14:27:14eric.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg217160

stage: resolved
2014-04-23 17:20:13eric.smithsettype: crash -> behavior

messages: + msg217078
nosy: + eric.smith
2014-04-23 16:57:20bpqpngcreate