3 jf@sdZddlZddlZddlmZdZddZddZejrHe Z d d Z ne Z e Z d d Z Gd ddeZddZddZddZddZdZedZedZejejZddZedkrdS)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)utilssurrogateescapecCstjr |S|jdSdS)NZunicode_escape)rPY3decode)textr>/tmp/pip-build-s1i5078x/future/future/utils/surrogateescape.pyusr cCstjr|jdS|SdS)Nlatin1)rrencode)datarrrbs r cCs t|fS)N)bytes)coderrr#src Csf|j|j|j}y0t|tr(t|}nt|trtjr dSytjtWn tk r8tjttYnXdS)zH Registers the surrogateescape error handler on Python 2 (only) N)rrcodecs lookup_errorr0 LookupErrorregister_errorrrrrrregister_surrogateescapes r:__main__)__doc__r6sysfuturerr0r r rchrr#r/unichrr Exceptionrrrr4r5r-r1r2lookupnamer:rrrrrs0  '