Skip to content

Add output_length to _Py_EncodeLocaleEx() - #158680

Open
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:encode_locale
Open

vstinner wants to merge 2 commits into
python:mainfrom
vstinner:encode_locale

Conversation

@vstinner

@vstinner vstinner commented Oct 3, 2026

Copy link
Copy Markdown
Member

Add output_length to _Py_EncodeLocaleEx(), _Py_EncodeUTF8Ex(), encode_current_locale() and encode_ascii(). So
unicode_encode_locale() and wstr_to_utf8() can use the output_length, instead of having to compute strlen().

  • Add encode_current_locale_impl() to simplify encode_current_locale().
  • _Py_EncodeLocaleEx() now sets error_pos and reason if it fails with -1 or -3.
  • Add tests on Py_EncodeLocale() and Py_DecodeLocale() functions in test_codecs.
  • Remove reason parameter of _Py_EncodeUTF8Ex(), encode_current_locale() and encode_ascii().

Add output_length to _Py_EncodeLocaleEx(), _Py_EncodeUTF8Ex(),
encode_current_locale() and encode_ascii(). So
unicode_encode_locale() and wstr_to_utf8() can use the output_length,
instead of having to compute strlen().

* Add encode_current_locale_impl() to simplify encode_current_locale().
* _Py_EncodeLocaleEx() now sets error_pos and reason if it fails with
  -1 or -3.
* Add tests on Py_EncodeLocale() and Py_DecodeLocale() functions in
  test_codecs.
* Remove reason parameter of _Py_EncodeUTF8Ex(),
  encode_current_locale() and encode_ascii().
Also revert an useless change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant