mò B…Oc@sÜdZdkZdkZy dkZWnej o dZnWXeiƒdpeiƒdZyei epdƒWne j o dZnXde fd„ƒYZ de fd„ƒYZ de fd „ƒYZdS( sç Error reporting should be safe from encoding/decoding errors. However, implicit conversions of strings and exceptions like >>> u'%s world: %s' % ('Hällo', Exception(u'Hällo') fail in some Python versions: * In Python <= 2.6, ``unicode()`` uses `__str__` and fails with non-ASCII chars in`unicode` arguments. (work around http://bugs.python.org/issue2517): * In Python 2, unicode() fails, with non-ASCII chars in arguments. (Use case: in some locales, the errstr argument of IOError contains non-ASCII chars.) * In Python 2, str() fails, with non-ASCII chars in `unicode` arguments. The `SafeString`, `ErrorString` and `ErrorOutput` classes handle common exceptions. Nitt SafeStringcBs2tZdZeddd„Zd„Zd„ZRS(sG A wrapper providing robust conversion to `str` and `unicode`. tbackslashreplacetreplacecCsI||_|pt|ddƒp tpd|_||_||_dS(Ntencodingtascii(tdatatselfRtgetattrtNonetlocale_encodingtencoding_errorstdecoding_errors(RRRR R ((tr/home/project-web/docutils/web-update/infrastructure/update-dir/aux/snapshots/docutils/docutils/error_reporting.pyt__init__?s * cCsÃyt|iƒSWn«tj oŸ}t|itƒoPg}|iiD]%}|tt ||i |i ƒƒqH~}di |ƒSnt|itƒo|ii|i |i ƒSn‚nXdS(Ns, (tstrRRtUnicodeEncodeErrorterrt isinstancet Exceptiont_[1]targstargRRR tjointunicodetencode(RRRRR((R t__str__Hs)c CsPy@t|iƒ}t|itƒo|iddƒ}n|SWn tj oý}t|itƒoKd|ii t |ii |i |i ƒt |ii|i |i ƒfSnt|itƒoSg}|iiD](}|tt ||i d|i ƒƒqÕ~}di|ƒSnt|tƒot|i|i |i ƒSn‚nXdS(sf Return unicode representation of `self.data`. Try ``unicode(self.data)``, catch `UnicodeError` and * if `self.data` is an Exception instance, work around http://bugs.python.org/issue2517 with an emulation of Exception.__unicode__, * else decode with `self.encoding` and `self.decoding_errors`. s: u's: 'u[Errno %s] %s: '%s'R u, N(RRRtuRtEnvironmentErrorRt UnicodeErrorterrorterrnoRtstrerrorRR tfilenameRRRRRtUnicodeDecodeError(RRRRRR((R t __unicode__Us$ )(t__name__t __module__t__doc__R RRR#(((R R:s  t ErrorStringcBs tZdZd„Zd„ZRS(s3 Safely report exception type and message. cCs&d|iiitt|ƒiƒfS(Ns%s: %s(RRt __class__R$tsuperR'R(R((R RzscCs&d|iiitt|ƒiƒfS(Nu%s: %s(RRR(R$R)R'R#(R((R R#~s(R$R%R&RR#(((R R'vs  t ErrorOutputcBs5tZdZeeddd„Zd„Zd„ZRS(s’ Wrapper class for file-like error streams with failsave de- and encoding of `str`, `bytes`, `unicode` and `Exception` instances. RRcCsÉ|djo ti}ng|p t}nVt|tƒot|dƒ}n3t|tƒo"t|i ti ƒƒdƒ}n||_|pt |ddƒp tpd|_ ||_||_dS(sÑ :Parameters: - `stream`: a file-like object (which is written to), a string (opended as a file), `None` (bind to `sys.stderr`; default). If evaluating to `False` (but not `None`), write() requests are ignored. - `encoding`: `stream` text encoding. Guessed if None. - `encoding_errors`: how to treat encoding errors. twRRN(tstreamR tsyststderrtFalseRRtopenRRtgetfilesystemencodingRRRR R R (RR,RR R ((R RŠs    " * cCs|itjodSnt|tƒo(tt||i|i |i ƒƒ}ny|ii |ƒWnœt j o)|ii |i |i|i ƒƒnitj o\|ititifjo|iii |ƒq|ii t||i|i ƒƒnXdS(s– Write `data` to self.stream. Ignore, if self.stream is False. `data` can be a `string`, `unicode`, or `Exception` instance. N(RR,R/RRRRRRR R twriteRRt TypeErrorR-R.tstdouttbuffer(RR((R R2®s&cCsO|ititifjodSny|iiƒWntj onXdS(s‘ Close the error-output stream. Ignored if the stream is` sys.stderr` or `sys.stdout` or has no close() method. N(RR,R-R4R.tclosetAttributeError(R((R R6Äs(R$R%R&R RR2R6(((R R*ƒs $ (R&R-tcodecstlocalet ImportErrorR R t getlocaletgetdefaultlocaletlookupt LookupErrortobjectRR'R*(R R'R9RR*R-R8((R t?$s  ! <