summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>1998-05-13 21:49:58 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>1998-05-13 21:49:58 (GMT)
commitee918cb48794ca18dbce6b3449d6f977d2142c60 (patch)
treefa363898de893ec0fd89db441d9f1db1e96c1e40 /Lib
parented7adcff731695446e2d2add4ff03f67989e6ac3 (diff)
downloadcpython-ee918cb48794ca18dbce6b3449d6f977d2142c60.zip
cpython-ee918cb48794ca18dbce6b3449d6f977d2142c60.tar.gz
cpython-ee918cb48794ca18dbce6b3449d6f977d2142c60.tar.bz2
Fix bug reported by Harri Pasanen: gzip + cPickle doesn't work. The
problem was a couple of bugs in the readline implementation. 1. Include the '\n' in the string returned by readline 2. Bug calculating new buffer size in _unread Also remove unncessary import of StringIO
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gzip.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 9c5ff0c..fda1121 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -1,7 +1,6 @@
import time
import string
import zlib
-import StringIO
import __builtin__
# implements a python function that reads and writes a gzipped file
@@ -157,7 +156,7 @@ class GzipFile:
def writelines(self,lines):
self.write(string.join(lines))
- def read(self,size=None):
+ def read(self, size=None):
if self.extrasize <= 0 and self.fileobj is None:
return ''
@@ -185,7 +184,7 @@ class GzipFile:
def _unread(self, buf):
self.extrabuf = buf + self.extrabuf
- self.extrasize = len(buf) + self.extrasize
+ self.extrasize = len(self.extrabuf)
def _read(self, size=1024):
try:
@@ -250,7 +249,7 @@ class GzipFile:
c = self.read(readsize)
i = string.find(c, '\n')
if i >= 0 or c == '':
- bufs.append(c[:i])
+ bufs.append(c[:i+1])
self._unread(c[i+1:])
return string.join(bufs, '')
bufs.append(c)