]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The ansi_x3.4_1968 encoding is an alias for ascii, but isn't known in
authorBarry Warsaw <barry@python.org>
Mon, 30 Sep 2002 15:23:17 +0000 (15:23 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 30 Sep 2002 15:23:17 +0000 (15:23 +0000)
Python 2.1.3.  However it's required by the email tests suite, so poke
it into the encodings aliases if it's missing.  The is apparently the
approved API for doing so.

Now we can remove the hexversion shortcircuits in the test suite.

Lib/email/__init__.py
Lib/email/test/test_email.py

index f7759b7a95a197890cea09a1a95191f0afeac16a..fd129a349a9248a701d9b615ba158642f5dc499e 100644 (file)
@@ -59,3 +59,12 @@ def message_from_file(fp, _class=None, strict=False):
         from email.Message import Message
         _class = Message
     return Parser(_class, strict=strict).parse(fp)
+
+
+\f
+# Patch encodings.aliases to recognize 'ansi_x3.4_1968' which isn't a standard
+# alias in Python 2.1.3, but is used by the email package test suite.
+from encodings.aliases import aliases # The aliases dictionary
+if not aliases.has_key('ansi_x3.4_1968'):
+    aliases['ansi_x3.4_1968'] = 'ascii'
+del aliases # Not needed any more
index 07460b93ca788bf826e2e989e313ec1551a29466..459915696703c70326b8b2a2222597936f1119a6 100644 (file)
@@ -1470,12 +1470,6 @@ class TestIdempotent(TestEmailBase):
         self._idempotent(msg, text)
 
     def test_more_rfc2231_parameters(self):
-        # BAW: What to do about this.  Python 2.1 doesn't know about the
-        # charset ansi-x3.4-1968, so this test will fail.  Do we teach Python
-        # about that charset, and if so, where (maybe Charset.py)?  For now,
-        # just skip this test if we aren't at least in Python 2.2.
-        if sys.hexversion < 0x20200000:
-            return
         msg, text = self._msgobj('msg_33.txt')
         self._idempotent(msg, text)
 
@@ -2258,12 +2252,6 @@ Do you like this message?
 """)
 
     def test_rfc2231_get_content_charset(self):
-        # BAW: What to do about this.  Python 2.1 doesn't know about the
-        # charset ansi-x3.4-1968, so this test will fail.  Do we teach Python
-        # about that charset, and if so, where (maybe Charset.py)?  For now,
-        # just skip this test if we aren't at least in Python 2.2.
-        if sys.hexversion < 0x20200000:
-            return
         eq = self.assertEqual
         msg = self._msgobj('msg_32.txt')
         eq(msg.get_content_charset(), 'us-ascii')