From 6fe011b6184c7e6ec0a3d704d943801b6f548ba2 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Sat, 4 Oct 2025 20:40:48 +0800 Subject: [PATCH 1/2] gh-127305: more detailed doc for `register_error`'s error_handler --- Doc/library/codecs.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 8c5c87a7ef16e4..0d6971247df274 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -462,8 +462,10 @@ handler: where encoding should continue. The replacement may be either :class:`str` or :class:`bytes`. If the replacement is bytes, the encoder will simply copy them into the output buffer. If the replacement is a string, the encoder will - encode the replacement. Encoding continues on original input at the - specified position. Negative position values will be treated as being + encode the replacement with the ``'strict'`` error handling, which means + :exc:`UnicodeEncodeError` may be raised here. + Encoding continues on originalinput at the specified position. + Negative position values will be treated as being relative to the end of the input string. If the resulting position is out of bound an :exc:`IndexError` will be raised. From 150aa41337b44044e9981224e5ddb48dff67ed25 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Sat, 4 Oct 2025 21:24:56 +0800 Subject: [PATCH 2/2] fixup! gh-127305: more detailed doc for `register_error`'s error_handler --- Doc/library/codecs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 0d6971247df274..4d9b6a271898a5 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -464,7 +464,7 @@ handler: them into the output buffer. If the replacement is a string, the encoder will encode the replacement with the ``'strict'`` error handling, which means :exc:`UnicodeEncodeError` may be raised here. - Encoding continues on originalinput at the specified position. + Encoding continues on original input at the specified position. Negative position values will be treated as being relative to the end of the input string. If the resulting position is out of bound an :exc:`IndexError` will be raised.