B ÍAÒ[Ñã@s¼dZddlZddlZddlmZdZdd„Zdd„ZejrHe Z d d „Z ne Z e Z d d „Z Gd d„deƒZdd„Zdd„Zdd„Zdd„ZdZedƒZedƒZe e¡jZdd„Zedkr¸dS)z¾ This is Victor Stinner's pure-Python implementation of PEP 383: the "surrogateescape" error handler of Python 3. Source: misc/python/surrogateescape.py in https://bitbucket.org/haypo/misc éN)ÚutilsÚsurrogateescapecCstjr |S| d¡SdS)NZunicode_escape)rÚPY3Údecode)Útext©rúM/opt/alt/python37/lib/python3.7/site-packages/future/utils/surrogateescape.pyÚusr cCstjr| d¡S|SdS)NÚlatin1)rrÚencode)ÚdatarrrÚbs r cCs t|fƒS)N)Úbytes)ÚcoderrrÚ#órcCsf|j|j|j…}y0t|tƒr(t|ƒ}nt|tƒrtjr dSyt t¡Wn tk r8t tt¡YnXdS)zH Registers the surrogateescape error handler on Python 2 (only) N)rrÚcodecsÚ lookup_errorr1Ú LookupErrorÚregister_errorrrrrrÚregister_surrogateescape±s r;Ú__main__)Ú__doc__r7ÚsysZfuturerr1r r rÚchrr$r0ZunichrrÚ Exceptionrrrr5r6r.r2r3ÚlookupÚnamer;rrrrrÚs0  '