mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.13] GH-126606: don't write incomplete pyc files (GH-126627) (GH-126809)
GH-126606: don't write incomplete pyc files (GH-126627)
(cherry picked from commit c695e37a3f)
Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Brett Cannon <brett@python.org>
			
			
This commit is contained in:
		
							parent
							
								
									942f807f70
								
							
						
					
					
						commit
						ad1b23bf29
					
				
					 3 changed files with 40 additions and 1 deletions
				
			
		|  | @ -209,7 +209,11 @@ def _write_atomic(path, data, mode=0o666): | |||
|         # We first write data to a temporary file, and then use os.replace() to | ||||
|         # perform an atomic rename. | ||||
|         with _io.FileIO(fd, 'wb') as file: | ||||
|             file.write(data) | ||||
|             bytes_written = file.write(data) | ||||
|         if bytes_written != len(data): | ||||
|             # Raise an OSError so the 'except' below cleans up the partially | ||||
|             # written file. | ||||
|             raise OSError("os.write() didn't write the full pyc file") | ||||
|         _os.replace(path_tmp, path) | ||||
|     except OSError: | ||||
|         try: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)