mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 07:01:21 +00:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									ed7adcff73
								
							
						
					
					
						commit
						ee918cb487
					
				
					 1 changed files with 3 additions and 4 deletions
				
			
		| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import string
 | 
					import string
 | 
				
			||||||
import zlib
 | 
					import zlib
 | 
				
			||||||
import StringIO
 | 
					 | 
				
			||||||
import __builtin__
 | 
					import __builtin__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# implements a python function that reads and writes a gzipped file
 | 
					# implements a python function that reads and writes a gzipped file
 | 
				
			||||||
| 
						 | 
					@ -185,7 +184,7 @@ def read(self,size=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _unread(self, buf):
 | 
					    def _unread(self, buf):
 | 
				
			||||||
        self.extrabuf = buf + self.extrabuf
 | 
					        self.extrabuf = buf + self.extrabuf
 | 
				
			||||||
        self.extrasize = len(buf) + self.extrasize
 | 
					        self.extrasize = len(self.extrabuf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _read(self, size=1024):
 | 
					    def _read(self, size=1024):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
| 
						 | 
					@ -250,7 +249,7 @@ def readline(self):
 | 
				
			||||||
            c = self.read(readsize)
 | 
					            c = self.read(readsize)
 | 
				
			||||||
            i = string.find(c, '\n')
 | 
					            i = string.find(c, '\n')
 | 
				
			||||||
            if i >= 0 or c == '':
 | 
					            if i >= 0 or c == '':
 | 
				
			||||||
                bufs.append(c[:i])
 | 
					                bufs.append(c[:i+1])
 | 
				
			||||||
                self._unread(c[i+1:])
 | 
					                self._unread(c[i+1:])
 | 
				
			||||||
                return string.join(bufs, '')
 | 
					                return string.join(bufs, '')
 | 
				
			||||||
            bufs.append(c)
 | 
					            bufs.append(c)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue