Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(228)

#15180: Cryptic traceback from os.path.join when mixing str & bytes

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 months ago by ncoghlan
Modified:
10 months, 1 week ago
Reviewers:
merwok, hs
CC:
Georg, terry.reedy, Nick Coghlan, AntoinePitrou, eric.araujo, Arfrever.FTA_GMail.Com, r.david.murray, devnull_psf.upfronthosting.co.za, hynek
Visibility:
Public.

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/posixpath.py View 1 chunk +14 lines, -6 lines 4 comments Download
Lib/test/test_posixpath.py View 1 chunk +12 lines, -0 lines 2 comments Download

Messages

Total messages: 2
eric.araujo
http://bugs.python.org/review/15180/diff/5242/Lib/posixpath.py File Lib/posixpath.py (right): http://bugs.python.org/review/15180/diff/5242/Lib/posixpath.py#newcode88 Lib/posixpath.py:88: raise TypeError('You can\'t mix strings and bytes in path ...
10 months, 3 weeks ago #1
hynek
10 months, 1 week ago #2
http://bugs.python.org/review/15180/diff/5242/Lib/posixpath.py
File Lib/posixpath.py (right):

http://bugs.python.org/review/15180/diff/5242/Lib/posixpath.py#newcode88
Lib/posixpath.py:88: raise TypeError('You can\'t mix strings and bytes in path '
On 2012/07/02 22:11:25, eric.araujo wrote:
> Minor: I don’t remember error messages using “you”, more often “impossible to
X”
> or “can't X”

You’re right, I still suck at copywriting. Fixing.

http://bugs.python.org/review/15180/diff/5242/Lib/posixpath.py#newcode89
Lib/posixpath.py:89: 'components.') from None
On 2012/07/02 22:11:25, eric.araujo wrote:
> I like error messages that tell which argument has a bad type or value.

Me too, but you don’t really know in this case which one was the intended one…I
think it’s better to have the user have a look at it. At least they know now why
it’s happening. :)

http://bugs.python.org/review/15180/diff/5242/Lib/test/test_posixpath.py
File Lib/test/test_posixpath.py (right):

http://bugs.python.org/review/15180/diff/5242/Lib/test/test_posixpath.py#newc...
Lib/test/test_posixpath.py:61: try:
On 2012/07/02 22:11:25, eric.araujo wrote:
> This should fail if the exception is not raised.  Instead of recommending
> try/except/else, I advise just using assertRaises, and also not testing for
the
> exact error message (which Python does not guarantee).

Then I wouldn’t have to add any tests at all, because we get TypeError already.
The point of the patch is to make it more readable. :)
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7