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 martin.panter
Recipients martin.panter, ncoghlan
Date 2013-11-10.10:35:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384079740.22.0.580481590071.issue19543@psf.upfronthosting.co.za>
In-reply-to
Content
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")
History
Date User Action Args
2013-11-10 10:35:40martin.pantersetrecipients: + martin.panter, ncoghlan
2013-11-10 10:35:40martin.pantersetmessageid: <1384079740.22.0.580481590071.issue19543@psf.upfronthosting.co.za>
2013-11-10 10:35:40martin.panterlinkissue19543 messages
2013-11-10 10:35:39martin.pantercreate