# HG changeset patch # Parent ac0d6c09457e659c6f47a1d3ca125b35a9e93257 diff -r ac0d6c09457e Doc/library/codecs.rst --- a/Doc/library/codecs.rst Sun Jan 18 21:25:15 2015 -0800 +++ b/Doc/library/codecs.rst Mon Jan 19 05:39:07 2015 +0000 @@ -1298,8 +1298,8 @@ +----------------------+------------------+------------------------------+------------------------------+ | Codec | Aliases | Purpose | Encoder / decoder | +======================+==================+==============================+==============================+ -| base64_codec [#b64]_ | base64, base_64 | Convert operand to MIME | :meth:`base64.b64encode` / | -| | | base64 (the result always | :meth:`base64.b64decode` | +| base64_codec [#b64]_ | base64, base_64 | Convert operand to MIME | :meth:`base64.encodebytes` / | +| | | base64 (the result always | :meth:`base64.decodebytes` | | | | includes a trailing | | | | | ``'\n'``) | | | | | | | @@ -1312,14 +1312,14 @@ | bz2_codec | bz2 | Compress the operand | :meth:`bz2.compress` / | | | | using bz2 | :meth:`bz2.decompress` | +----------------------+------------------+------------------------------+------------------------------+ -| hex_codec | hex | Convert operand to | :meth:`base64.b16encode` / | -| | | hexadecimal | :meth:`base64.b16decode` | +| hex_codec | hex | Convert operand to | :meth:`binascii.b2a_hex` / | +| | | hexadecimal | :meth:`binascii.a2b_hex` | | | | representation, with two | | | | | digits per byte | | +----------------------+------------------+------------------------------+------------------------------+ -| quopri_codec | quopri, | Convert operand to MIME | :meth:`quopri.encodestring` /| -| | quotedprintable, | quoted printable | :meth:`quopri.decodestring` | -| | quoted_printable | | | +| quopri_codec | quopri, | Convert operand to MIME | :meth:`quopri.encode` with | +| | quotedprintable, | quoted printable | ``quotetabs=True`` / | +| | quoted_printable | | :meth:`quopri.decode` | +----------------------+------------------+------------------------------+------------------------------+ | uu_codec | uu | Convert the operand using | :meth:`uu.encode` / | | | | uuencode | :meth:`uu.decode` | diff -r ac0d6c09457e Lib/encodings/quopri_codec.py --- a/Lib/encodings/quopri_codec.py Sun Jan 18 21:25:15 2015 -0800 +++ b/Lib/encodings/quopri_codec.py Mon Jan 19 05:39:07 2015 +0000 @@ -11,7 +11,7 @@ assert errors == 'strict' f = BytesIO(input) g = BytesIO() - quopri.encode(f, g, 1) + quopri.encode(f, g, quotetabs=True) return (g.getvalue(), len(input)) def quopri_decode(input, errors='strict'): diff -r ac0d6c09457e Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py Sun Jan 18 21:25:15 2015 -0800 +++ b/Lib/test/test_codecs.py Mon Jan 19 05:39:07 2015 +0000 @@ -2627,6 +2627,14 @@ info = codecs.lookup(alias) self.assertEqual(info.name, expected_name) + def test_quopri_stateless(self): + # Should encode with quotetabs=True + encoded = codecs.encode(b"space tab\teol \n", "quopri-codec") + self.assertEqual(b"space=20tab=09eol=20\n", encoded) + # But should still support unescaped tabs and spaces + unescaped = b"space tab eol\n" + self.assertEqual(unescaped, codecs.decode(unescaped, "quopri-codec")) + def test_uu_invalid(self): # Missing "begin" line self.assertRaises(ValueError, codecs.decode, b"", "uu-codec")