Skip to content

bpo-1635741: Fix refleaks of encodings module by removing the encodings._aliases #21896

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
remove encodings._aliases to search_function
  • Loading branch information
shihai1991 committed Aug 16, 2020
commit c933b1a9ce51cc942e6a58270261d2bd6a5298f7
3 changes: 2 additions & 1 deletion Lib/encodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
_cache = {}
_unknown = '--unknown--'
_import_tail = ['*']
_aliases = aliases.aliases


class CodecRegistryError(LookupError, SystemError):
pass
Expand Down Expand Up @@ -69,6 +69,7 @@ def normalize_encoding(encoding):

def search_function(encoding):

_aliases = aliases.aliases
Copy link

@ghost ghost Aug 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand the problem.
This statement should be placed at below so that it does not affect the performance of the cache.

Copy link
Member Author

@shihai1991 shihai1991 Aug 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand the problem.

Thanks for your comment. It will affect the encodings module's refcount in C level and reduce the refleaks.

This statement should be placed at below so that it does not affect the performance of the cache.

MAYBE removing this line and using aliases.aliases to replace _aliases is fine too :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking this comment: #21896 (comment)

Copy link

@ghost ghost Aug 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking this comment: #21896 (comment)

The usage of aliases.aliasesis is very normal, maybe the root of the problem is not here.

# Cache lookup
entry = _cache.get(encoding, _unknown)
if entry is not _unknown:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix refleaks of `encodings.aliases` by Moving `encodings._aliases` to
:func:`encodings.search_function`.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy