Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-42846: Convert CJK codec extensions to multiphase init #24157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2021
Merged

bpo-42846: Convert CJK codec extensions to multiphase init #24157

merged 3 commits into from
Jan 7, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jan 7, 2021

Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk,
_codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the
multiphase initialization API (PEP 489).

Remove getmultibytecodec() local cache: always import
_multibytecodec. It should be uncommon to get a codec. For example,
this function is only called once per CJK codec module.

https://bugs.python.org/issue42846

Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk,
_codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the
multiphase initialization API (PEP 489).

Remove getmultibytecodec() local cache: always import
_multibytecodec. It should be uncommon to get a codec. For example,
this function is only called once per CJK codec module.
@vstinner
Copy link
Member Author

vstinner commented Jan 7, 2021

Without this change, the following tests fail:

With this change, these tests pass.

@vstinner vstinner merged commit 07f2cee into python:master Jan 7, 2021
@vstinner vstinner deleted the cjkcodec_multiphase branch January 7, 2021 23:15
@neonene
Copy link
Contributor

neonene commented Jan 8, 2021

Thanks for the quick fix!
Just in case, I linked this PR with #24095.

@vstinner
Copy link
Member Author

vstinner commented Jan 8, 2021

Thanks for the quick fix!

You're welcome. Thanks for the bug report.

It took me time to understand why the bug occurs and why it wasn't supported earlier.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…24157)

Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk,
_codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the
multiphase initialization API (PEP 489).

Remove getmultibytecodec() local cache: always import
_multibytecodec. It should be uncommon to get a codec. For example,
this function is only called once per CJK codec module.

Fix a reference leak in register_maps() error path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.