| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1904,7 +1904,10 @@ def test_basics(self): | |
| name += "_codec" | ||
| elif encoding == "latin_1": | ||
| name = "latin_1" | ||
| self.assertEqual(encoding.replace("_", "-"), name.replace("_", "-")) | ||
| # Skip the mbcs alias on Windows | ||
| if name != "mbcs": | ||
| self.assertEqual(encoding.replace("_", "-"), | ||
| name.replace("_", "-")) | ||
|
|
||
| (b, size) = codecs.getencoder(encoding)(s) | ||
| self.assertEqual(size, len(s), "encoding=%r" % encoding) | ||
| Expand Down Expand Up | @@ -3188,11 +3191,13 @@ def test_incremental(self): | |
| self.assertEqual(decoded, ('abc', 3)) | ||
|
|
||
| def test_mbcs_alias(self): | ||
| # Check that looking up our 'default' codepage will return | ||
| # mbcs when we don't have a more specific one available | ||
| with mock.patch('_winapi.GetACP', return_value=123): | ||
| codec = codecs.lookup('cp123') | ||
| self.assertEqual(codec.name, 'mbcs') | ||
| # 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") | ||
|
Comment thread
Comment on lines
+3198
to
+3200
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis was never true before. With 1252 as my ANSI code page, I checked codecs.lookup('cp1252') in 2.7, 3.4, 3.5, 3.6, 3.9, and 3.10, and none of them return the "mbcs" encoding. It's not equivalent, and not supposed to be. The implementation of "cp1252" should be cross-platform, regardless of whether we're on a Windows system with 1252 as the ANSI code page, as opposed to a Windows system with some other ANSI code page, or a Linux or macOS system. The differences are that "mbcs" maps every byte, whereas our code-page encodings do not map undefined bytes, and the "replace" handler of "mbcs" uses a best-fit mapping (e.g. "α" -> "a") when encoding text, instead of mapping all undefined characters to "?".
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis issue is worse than what I expected, I created https://bugs.python.org/issue46668 to discuss it.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| @support.bigmemtest(size=2**31, memuse=7, dry_run=False) | ||
| def test_large_input(self, size): | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis will fail if PYTHONUTF8 is set in the environment, because it overrides getpreferredencoding(False) and _get_locale_encoding().
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.