Skip to content

bpo-46668: Remove the mbcs alias #31174

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
wants to merge 1 commit into from
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
15 changes: 0 additions & 15 deletions Lib/encodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,5 @@ def search_function(encoding):
# Return the registry entry
return entry

if sys.platform == 'win32':
def _alias_mbcs(encoding):
try:
import _winapi
ansi_code_page = "cp%s" % _winapi.GetACP()
if encoding == ansi_code_page:
import encodings.mbcs
return encodings.mbcs.getregentry()
except ImportError:
# Imports may fail while we are shutting down
pass

# It must be registered before search_function()
codecs.register(_alias_mbcs)

# Register the search_function in the Python codec registry
codecs.register(search_function)
9 changes: 0 additions & 9 deletions Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3190,15 +3190,6 @@ def test_incremental(self):
False)
self.assertEqual(decoded, ('abc', 3))

def test_mbcs_alias(self):
# On Windows, the encoding name must be the ANSI code page
encoding = locale.getpreferredencoding(False)
self.assertTrue(encoding.startswith('cp'), encoding)

# The encodings module create a "mbcs" alias to the ANSI code page
codec = codecs.lookup(encoding)
self.assertEqual(codec.name, "mbcs")

@support.bigmemtest(size=2**31, memuse=7, dry_run=False)
def test_large_input(self, size):
# Test input longer than INT_MAX.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Python no longer creates an alias for the ANSI code page to the "mbcs"
codec: always use the Python implementation of the code page. Patch by
Victor Stinner.