mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Merged revisions 85970 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r85970 | georg.brandl | 2010-10-30 10:29:28 +0200 (Sa, 30 Okt 2010) | 1 line #10198: fix duplicate header when writeframes() is called with an empty string. ........
This commit is contained in:
		
							parent
							
								
									7fef7a8375
								
							
						
					
					
						commit
						fbef44f255
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		|  | @ -319,6 +319,7 @@ def initfp(self, file): | |||
|         self._nframeswritten = 0 | ||||
|         self._datawritten = 0 | ||||
|         self._datalength = 0 | ||||
|         self._headerwritten = False | ||||
| 
 | ||||
|     def __del__(self): | ||||
|         self.close() | ||||
|  | @ -449,7 +450,7 @@ def close(self): | |||
|     # | ||||
| 
 | ||||
|     def _ensure_header_written(self, datasize): | ||||
|         if not self._datawritten: | ||||
|         if not self._headerwritten: | ||||
|             if not self._nchannels: | ||||
|                 raise Error('# channels not specified') | ||||
|             if not self._sampwidth: | ||||
|  | @ -459,6 +460,7 @@ def _ensure_header_written(self, datasize): | |||
|             self._write_header(datasize) | ||||
| 
 | ||||
|     def _write_header(self, initlength): | ||||
|         assert not self._headerwritten | ||||
|         self._file.write(b'RIFF') | ||||
|         if not self._nframes: | ||||
|             self._nframes = initlength // (self._nchannels * self._sampwidth) | ||||
|  | @ -472,8 +474,10 @@ def _write_header(self, initlength): | |||
|             self._sampwidth * 8, 'data')) | ||||
|         self._data_length_pos = self._file.tell() | ||||
|         self._file.write(struct.pack('<l', self._datalength)) | ||||
|         self._headerwritten = True | ||||
| 
 | ||||
|     def _patchheader(self): | ||||
|         assert self._headerwritten | ||||
|         if self._datawritten == self._datalength: | ||||
|             return | ||||
|         curpos = self._file.tell() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Georg Brandl
						Georg Brandl