Message202519
Just thinking the first case might get quite a few false positives. Maybe that would still be acceptable, I dunno.
> - the str.encode method is called (redirect to codecs.encode to handle arbitrary input types in a forward compatible way)
I guess you are trying to catch cases like this, which I have come across quite a few times:
data.encode("hex") # data is a byte string
But I think you would also catch cases that depend on Python 2 “str” objects automatically converting to Unicode. Here are some examples taken from real code:
file_name.encode("utf-8") # File name parameter may be str or unicode
# Code meant to be compatible with both Python 2 and 3:
"""<?xml . . . encoding="iso-8859-1"?>""".encode("iso-8859-1")
("data %s\n" % len(...)).encode("ascii") |
|
Date |
User |
Action |
Args |
2013-11-10 10:35:40 | martin.panter | set | recipients:
+ martin.panter, ncoghlan |
2013-11-10 10:35:40 | martin.panter | set | messageid: <1384079740.22.0.580481590071.issue19543@psf.upfronthosting.co.za> |
2013-11-10 10:35:40 | martin.panter | link | issue19543 messages |
2013-11-10 10:35:39 | martin.panter | create | |
|