mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #18919: If the close() method of a writer in the sunau or wave module
failed, second invocation of close() and destructor no more raise an exception.
This commit is contained in:
		
							parent
							
								
									5c01d99c12
								
							
						
					
					
						commit
						e23b2d06c7
					
				
					 3 changed files with 22 additions and 13 deletions
				
			
		
							
								
								
									
										12
									
								
								Lib/wave.py
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								Lib/wave.py
									
										
									
									
									
								
							|  | @ -436,11 +436,13 @@ def writeframes(self, data): | |||
| 
 | ||||
|     def close(self): | ||||
|         if self._file: | ||||
|             self._ensure_header_written(0) | ||||
|             if self._datalength != self._datawritten: | ||||
|                 self._patchheader() | ||||
|             self._file.flush() | ||||
|             self._file = None | ||||
|             try: | ||||
|                 self._ensure_header_written(0) | ||||
|                 if self._datalength != self._datawritten: | ||||
|                     self._patchheader() | ||||
|                 self._file.flush() | ||||
|             finally: | ||||
|                 self._file = None | ||||
|         if self._i_opened_the_file: | ||||
|             self._i_opened_the_file.close() | ||||
|             self._i_opened_the_file = None | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka