summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin Panter <vadmium>2015-09-12 00:34:28 (GMT)
committerMartin Panter <vadmium>2015-09-12 00:34:28 (GMT)
commit06171bd52a02173910d7ab8082850bbed0db1410 (patch)
tree25921b647bee4cc2897fa44866e1c0dc9f9bc565 /Lib
parentf9b687525950999a08862b1339a62a0a163d7228 (diff)
downloadcpython-06171bd52a02173910d7ab8082850bbed0db1410.zip
cpython-06171bd52a02173910d7ab8082850bbed0db1410.tar.gz
cpython-06171bd52a02173910d7ab8082850bbed0db1410.tar.bz2
Issue #16473: Fix byte transform codec documentation; test quotetabs=True
This changes the equivalent functions listed for the Base-64, hex and Quoted- Printable codecs to reflect the functions actually used. Also mention and test the "quotetabs" setting for Quoted-Printable encoding.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/encodings/quopri_codec.py2
-rw-r--r--Lib/test/test_codecs.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/encodings/quopri_codec.py b/Lib/encodings/quopri_codec.py
index 0533dbe..496cb76 100644
--- a/Lib/encodings/quopri_codec.py
+++ b/Lib/encodings/quopri_codec.py
@@ -11,7 +11,7 @@ def quopri_encode(input, errors='strict'):
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 --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 6629ccd..8b78c24 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -2613,6 +2613,14 @@ class TransformCodecTest(unittest.TestCase):
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(encoded, b"space=20tab=09eol=20\n")
+ # But should still support unescaped tabs and spaces
+ unescaped = b"space tab eol\n"
+ self.assertEqual(codecs.decode(unescaped, "quopri-codec"), unescaped)
+
def test_uu_invalid(self):
# Missing "begin" line
self.assertRaises(ValueError, codecs.decode, b"", "uu-codec")