New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relpath: Provide better errors when mixing bytes and strings #66082
Comments
Howdy! I encountered this error when accidently passing in mixed types to reldir >>> import os
>>> os.path.relpath('/Users/bachmann', b'.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/posixpath.py", line 451, in relpath
start_list = [x for x in abspath(start).split(sep) if x]
TypeError: Type str doesn't support the buffer API When this mistake is done in join we get a helpful error message. I simply borrowed this logic and put in in relpath. Is this useful? |
Includes change and tests. The test is similar so I just broke out the logic |
Error message for posixpath.join() was fixed and enhanced in bpo-22034. Here is a patch which extends this enhancement to relpath() and to other os.path implementations (ntpath and macpath). |
Ah, tests fail when Python runs without the -bb option. Here is fixed path. |
New changeset 2ba2ee5713bd by Serhiy Storchaka in branch 'default': |
New changeset 85de13b746ac by Serhiy Storchaka in branch 'default': |
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: