GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — bpo-46659: Update the test on the mbcs codec alias by vstinner · Pull Request #31168 · python/cpython Conversation
|
| # The encodings module create a "mbcs" alias to the ANSI code page | ||
| codec = codecs.lookup(encoding) | ||
| self.assertEqual(codec.name, "mbcs") |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This issue is worse than what I expected, I created https://bugs.python.org/issue46668 to discuss it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # On Windows, the encoding name must be the ANSI code page | ||
| encoding = locale.getpreferredencoding(False) | ||
| self.assertTrue(encoding.startswith('cp'), encoding) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This will fail if PYTHONUTF8 is set in the environment, because it overrides getpreferredencoding(False) and _get_locale_encoding().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.