ktbs/ktbs — comment on commit 8f23cdf380218337702aedd8695b859a27f25302
File:  line 0
By oaubert:

Problems in sight... Every time you deal with unicode, you have to specify the encoding, else you finish with strange errors depending on the platform (which do not define the same default encoding). And with the new IDNs, it would be worth to check if it works or not on these strange new domain names.
I would advise using
if isinstance(uri, unicode):
uri = uri.encode('ascii', 'ignore')
as precautionary measure.