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.

Author vstinner
Recipients Claudiu.Popa, berker.peksag, brett.cannon, martin.panter, paul.moore, serhiy.storchaka, vstinner
Date 2015-03-20.10:16:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426846584.17.0.944374682295.issue23681@psf.upfronthosting.co.za>
In-reply-to
Content
> This will help when someone writes something like `b'abcd'[2] == b'c'`

What if someone writes line[-1] == 0 and line is a Unicode string? Should we emit a warning?

I patched locally PyUnicode_RichCompare() to emit a warning. Hum, there are *many* warnings in argparse, http.client, and many other modules. I don't think that it's a good idea. It looks common to use a string for a sentinel (ex: state = "UNKNOWN") and then store an int (ex: state = 0). So comparison need to check the type (ex: isinstance(state, str) and state == "UNKNOWN") which is verbose and annoying.

So no, we should not emit a warning :-)
History
Date User Action Args
2015-03-20 10:16:24vstinnersetrecipients: + vstinner, brett.cannon, paul.moore, Claudiu.Popa, berker.peksag, martin.panter, serhiy.storchaka
2015-03-20 10:16:24vstinnersetmessageid: <1426846584.17.0.944374682295.issue23681@psf.upfronthosting.co.za>
2015-03-20 10:16:24vstinnerlinkissue23681 messages
2015-03-20 10:16:23vstinnercreate