Conversation started May 16, 2013 at 12:44.
May 16, 2013 12:44
Also, the code shown clearly doesn't cause the error shown (notice "encode" vs "decode").
Oh wait, maybe it does.
@R.MartinhoFernandes Whoa.
ew ew ew, too many toes! if you dare
Python is sort of braindead in this.
TIL of unescape
It isn't in the docs anywhere
Ha.
Yeah, the "decode" error comes from the "encode" call.
lol, Python2.
No, wait, 'ignore' should not cause an error anyway. WTF.
Ah, no.
lol, Python2.
Yeah, Python2 is a bit braindead.
>>> u'foö'.encode('utf-8').encode('ascii', 'ignore')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)
>>>
user784668
> byte
@Rapptz Internal.
Yeah but you can use it still :(
@Fanael What about it?
May 16, 2013 12:51
sounds cool.
user784668
oh wait, ascii
The thing is, the second encode assumes the byte string is in ASCII, so it tries to decode as ASCII before encoding it as requested as ASCII. This decoding fails and the errors are only ignored when encoding. So you get a decode error in your encode call.
OP is stupid for trying this in the first place, but Python's behaviour is silly.
@R.MartinhoFernandes What?
In Py3 that crap doesn't even compile.
I'm not sure what I meant by that.
May 16, 2013 12:57
@LucDanton Yeah, that's the right reaction.
<- brain broke
ffff foot cramp, I'm sure this is related
In Py3 byte strings don't have encode functions and Unicode strings don't have decode functions.
 
Conversation ended May 16, 2013 at 12:58.