mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
bpo-46659: Fix the MBCS codec alias on Windows (GH-31218)
This commit is contained in:
parent
8fb94893e4
commit
ccbe8045fa
2 changed files with 17 additions and 11 deletions
|
@ -3191,13 +3191,16 @@ class CodePageTest(unittest.TestCase):
|
|||
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")
|
||||
# Check that looking up our 'default' codepage will return
|
||||
# mbcs when we don't have a more specific one available
|
||||
code_page = 99_999
|
||||
name = f'cp{code_page}'
|
||||
with mock.patch('_winapi.GetACP', return_value=code_page):
|
||||
try:
|
||||
codec = codecs.lookup(name)
|
||||
self.assertEqual(codec.name, 'mbcs')
|
||||
finally:
|
||||
codecs.unregister(name)
|
||||
|
||||
@support.bigmemtest(size=2**31, memuse=7, dry_run=False)
|
||||
def test_large_input(self, size):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue