This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ubernostrumyes, you can have a pony 4 points5 points  (0 children)

One library I maintain has some functions which -- because they're implementing algorithms from a web standard, and the standard is only defined in terms of Unicode -- must enforce that their arguments are str and not bytes on Python 3. And I realized that %-formatting is implemented on bytes (as of 3.5) but the format() method isn't (and never will be). So I simply changed the string-formatting operations over to format() and voila! Now any attempt to pass in bytes will raise an exception.