Matt Giuca <matt.gi...@gmail.com> added the comment:

If you're going the way of option 2, I would strongly advise against relying on 
the KeyError. The fact that a KeyError is raised by urllib.quote is not part of 
it's specification, it's a bug/quirk in the implementation (which is now 
unlikely to be change, but it's unsafe to rely on it).

Robotparser should encode the string, if and only if it is a unicode string, 
with ('ascii', 'strict'), catch the UnicodeEncodeError, and raise the TypeError 
you suggested. This will have precisely the same behaviour as your proposed 
option 2 (will work fine for byte strings and Unicode strings with ASCII-only 
characters, but raise a TypeError on Unicode strings with non-ASCII characters) 
without relying on the KeyError from urllib.quote.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1712522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to