You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2013-07-24.19:17:05.269>created_at=<Date2013-07-24.16:31:59.432>labels= ['type-bug', 'library']
title='os.path.dirname() does not behave as expected for path without /:es'updated_at=<Date2013-07-24.19:17:05.268>user='https://bugs.python.org/JonasEriksson'
Only tested on marked python versions. Checked the code in hg (a5681f50bae2) and did not see anything related to this in the current development version.
Essentially, what I see is this:
>>> os.path.dirname("asdf")
''
>>> os.path.dirname("./asdf")
'.'
>>>
What I expect is the same output as from the unix command dirname:
$ dirname asdf
.
$ dirname ./asdf
.
$
The change is quite straight forwards, Lib/posixpath.py needs something like if head = "": head = ".", and Lib/ntpath.py something similar.
Now, this bug is a tricky one since it alters the behavior of dirname. However, I cannot see any case where "" would be useful and have seen at least one bug because of this behaviour because the return value "" is treated like an error. So I gracefully hand over the final decision to you :)
As you can see, the current behavior has significant value in Python. So I think it is behaving correctly. Python is not the shell, even though it does have many functions that provide APIs very similar to the corresponding shell functions.
See bpo-17545 for a related issue, and specifically msg189401 for another reason why the current behavior of dirname is correct within the logic of Python.
Based on the above I'm going to go ahead and close this. If other developers disagree they can reopen. If they don't, and you disagree, I would suggest that talking about it on python-ideas would be your next step.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: