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 all commits
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
10 changes: 5 additions & 5 deletions 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 @@ -82,8 +82,8 @@ def search_function(encoding):
# try in the encodings package, then at top-level.
#
norm_encoding = normalize_encoding(encoding)
aliased_encoding = _aliases.get(norm_encoding) or \
_aliases.get(norm_encoding.replace('.', '_'))
aliased_encoding = aliases.aliases.get(norm_encoding) or \
aliases.aliases.get(norm_encoding.replace('.', '_'))
if aliased_encoding is not None:
modnames = [aliased_encoding,
norm_encoding]
Expand Down Expand Up @@ -145,8 +145,8 @@ def search_function(encoding):
pass
else:
for alias in codecaliases:
if alias not in _aliases:
_aliases[alias] = modname
if alias not in aliases.aliases:
aliases.aliases[alias] = modname

# Return the registry entry
return entry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix refleaks of `encodings.aliases` by using `encodings.aliases` directly in
:func:`encodings.search_function`.