[pypy-svn] r16231 - pypy/dist/pypy/lib

jacob at codespeak.net jacob at codespeak.net
Mon Aug 22 20:30:27 CEST 2005


Author: jacob
Date: Mon Aug 22 20:30:26 2005
New Revision: 16231

Modified:
   pypy/dist/pypy/lib/binascii.py
Log:
Fixed 2.4.1 regressions.

Modified: pypy/dist/pypy/lib/binascii.py
==============================================================================
--- pypy/dist/pypy/lib/binascii.py	(original)
+++ pypy/dist/pypy/lib/binascii.py	Mon Aug 22 20:30:26 2005
@@ -8,6 +8,9 @@
     pass
 
 def a2b_uu(s):
+    if not s:
+        return ''
+    
     length = (ord(s[0]) - 0x20) % 64
 
     def quadruplets_gen(s):
@@ -255,9 +258,14 @@
         linebreak = '\r\n'
     elif lf > 0:
         linebreak = '\n'
-
+    
+    # if linebreak and linebreak == '\r\n':
+    # The above is more efficient for files with \n linebreaks,
+    # but fails badly on files with mixed linebreak encoding
     if linebreak:
         s = s.replace('\r\n', '\n')
+    else:
+        linebreak = '\n'
 
     lines = s.split('\n')
 
@@ -494,6 +502,8 @@
     The CPython implementation does not do run length encoding
     of \x90 characters. This implementation does.
     """
+    if not s:
+        return ''
     result = []
     prev = s[0]
     count = 1
@@ -602,6 +612,7 @@
 ]
 
 def crc32(s, crc=0):
+    result = 0
     crc = ~long(crc) & 0xffffffffL
     for c in s:
         crc = crc_32_tab[(crc ^ long(ord(c))) & 0xffL] ^ (crc >> 8)



More information about the Pypy-commit mailing list