Message163945
As seen in #4489, the traceback when mixing str and bytes in os.path.join is rather cryptic and hard to decipher if you've never encountered it before:
>>> import os.path
>>> os.path.join(b'', '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/posixpath.py", line 78, in join
if b.startswith(sep):
TypeError: startswith first arg must be str or a tuple of str, not bytes
>>> os.path.join('', b'')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/posixpath.py", line 78, in join
if b.startswith(sep):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
While it's slightly less cryptic with a real source file (since you can at least see the os.path.join call), you have to have some how idea of how os.path.join works to realise that:
- type(sep) == type(args[0])
- b in args[1:]
The challenge is to generate a more user friendly error message without making the normal case of correct types any slower. |
|
Date |
User |
Action |
Args |
2012-06-25 11:45:37 | ncoghlan | set | recipients:
+ ncoghlan |
2012-06-25 11:45:37 | ncoghlan | set | messageid: <1340624737.77.0.388823323175.issue15180@psf.upfronthosting.co.za> |
2012-06-25 11:45:37 | ncoghlan | link | issue15180 messages |
2012-06-25 11:45:36 | ncoghlan | create | |
|