[Python-Dev] PyString_DecodeEscape and PEP293

Walter Dörwald walter@livinglogic.de
Tue, 03 Sep 2002 18:05:21 +0200

Martin v. Loewis wrote:

> Walter Dörwald <walter@livinglogic.de> writes:
>>So does escape_decode need an errors argument. AFAICT
>>escape_decode is used only in the context of reading pickles.
>>Will there ever be a need to call escape_decode with anything
>>other than errors="strict"?
> It's a codec, so anybody is entitled to write
>   "foo".decode("string-escape", "replace")
> if they chose to. If you are suggesting that this is not supported is
> only acceptable if you also suggest how it should fail. Silently
> ignoring the "replace" argument is not acceptable.

I won't suggest that. Let's keep PyString_DecodeEscape as it is now.
It should not be a problem for encoding, because encoding can't fail,
so there is no need for using "xmlcharrefreplace" etc. as the error
handling. Decoding can fail, but lets add custom error handling
only when the need for it arises (which hopefully won't).

> [...]
>>So it doesn't need the new PEP293 error handling?
> Probably not - just supporting "strict", "replace", "ignore", and
> failing for any other error handling would be sufficient. If you
> manage to make it fail for anything but "strict", that would be
> acceptable as well (IMO).

OK, lets keep PyString_DecodeEscape as it is now (i.e. "strict", 
"ignore", "replace" implemented inline with no
custom error handling).

    Walter Dörwald