Skip to content
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
2 changes: 1 addition & 1 deletion Lib/email/charset.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'iso-8859-15': (QP, QP, None),
'iso-8859-16': (QP, QP, None),
'windows-1252':(QP, QP, None),
'viscii': (QP, QP, None),
# 'viscii' removed - no Python codec exists
'us-ascii': (None, None, None),
'big5': (BASE64, BASE64, None),
'gb2312': (BASE64, BASE64, None),
Expand Down
23 changes: 23 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -5008,6 +5008,29 @@ def test_unicode_charset_name(self):
self.assertEqual(str(charset), 'us-ascii')
self.assertRaises(errors.CharsetError, Charset, 'asc\xffii')

def test_viscii_not_registered(self):
# viscii has no Python codec, so it should not be in CHARSETS.
from email.charset import CHARSETS
self.assertNotIn('viscii', CHARSETS)

def test_all_charsets_have_codecs(self):
# Every charset registered in CHARSETS should have a resolvable
# Python codec (via CODEC_MAP or by name).
import codecs
from email.charset import CHARSETS, CODEC_MAP
for name in CHARSETS:
codec_name = CODEC_MAP.get(name, name)
if codec_name is None:
continue
with self.subTest(charset=name, codec=codec_name):
try:
codecs.lookup(codec_name)
except LookupError:
self.fail(
f"charset {name!r} maps to codec {codec_name!r} "
f"which is not available"
)



# Test multilingual MIME headers.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove ``viscii`` from :mod:`email.charset` ``CHARSETS`` table. Python has
no ``viscii`` codec, so any encoding operation on ``Charset('viscii')``
raised :exc:`LookupError`.
Loading