diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 311437a67f6e81..f3b5c859bbbc8e 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1310,7 +1310,7 @@ particular, the following variants typically exist: | | | | | | | .. versionadded:: 3.5 | +-----------------+--------------------------------+--------------------------------+ -| mac_cyrillic | maccyrillic | Belarusian, Bulgarian, | +| mac_cyrillic | maccyrillic, x-mac-cyrillic | Belarusian, Bulgarian, | | | | Macedonian, Russian, Serbian | +-----------------+--------------------------------+--------------------------------+ | mac_greek | macgreek | Greek | diff --git a/Lib/encodings/aliases.py b/Lib/encodings/aliases.py index de26353aecaaac..7968414566b354 100644 --- a/Lib/encodings/aliases.py +++ b/Lib/encodings/aliases.py @@ -502,6 +502,7 @@ # mac_cyrillic codec 'maccyrillic' : 'mac_cyrillic', + 'x_mac_cyrillic' : 'mac_cyrillic', # mac_greek codec 'macgreek' : 'mac_greek', diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index c4a9ffa5ff1c77..56600c631a48d8 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2247,6 +2247,15 @@ def test_basic(self): class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling): + def test_html5_aliases(self): + for alias, encoding in ( + ('windows-874', 'cp874'), + ('x-mac-cyrillic', 'mac_cyrillic'), + ): + with self.subTest(alias=alias): + self.assertEqual(codecs.lookup(alias).name, + codecs.lookup(encoding).name) + def test_basics(self): s = "abc123" # all codecs should be able to encode these for encoding in all_unicode_encodings: diff --git a/Misc/NEWS.d/next/Library/2026-09-20-15-14-50.gh-issue-69602.Fk3mQ9.rst b/Misc/NEWS.d/next/Library/2026-09-20-15-14-50.gh-issue-69602.Fk3mQ9.rst new file mode 100644 index 00000000000000..769291e53326c4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-20-15-14-50.gh-issue-69602.Fk3mQ9.rst @@ -0,0 +1 @@ +Add ``x-mac-cyrillic`` as an alias for the ``mac_cyrillic`` codec.