[Python-checkins] python/dist/src/Lib/test test_binascii.py, 1.18, 1.19

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Sep 7 00:58:40 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9212

Modified Files:
	test_binascii.py 
Log Message:
SF #1022953:  binascii.a2b_hqx("") raises SystemError

Several functions adopted the strategy of altering a full lengthed
string copy and resizing afterwards.  That would fail if the initial
string was short enough (0 or 1) to be interned.  Interning precluded
the subsequent resizing operation.

The solution was to make sure the initial string was at least two
characters long.

Added tests to verify that all binascii functions do not crater when
given an empty string argument.



Index: test_binascii.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binascii.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test_binascii.py	8 Jul 2004 04:22:19 -0000	1.18
+++ test_binascii.py	6 Sep 2004 22:58:37 -0000	1.19
@@ -148,6 +148,16 @@
             "0"*75+"=\r\n=FF\r\n=FF\r\n=FF"
         )
 
+    def test_empty_string(self):
+        # A test for SF bug #1022953.  Make sure SystemError is not raised.
+        for n in ['b2a_qp', 'a2b_hex', 'b2a_base64', 'a2b_uu', 'a2b_qp',
+                  'b2a_hex', 'unhexlify', 'hexlify', 'crc32', 'b2a_hqx',
+                  'a2b_hqx', 'a2b_base64', 'rlecode_hqx', 'b2a_uu',
+                  'rledecode_hqx']:
+            f = getattr(binascii, n)
+            f('')
+        binascii.crc_hqx('', 0)
+
 def test_main():
     test_support.run_unittest(BinASCIITest)
 



More information about the Python-checkins mailing list