mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	[3.13] gh-119553: Fix console when pressing Ctrl-C within a multiline block (GH-120075) (#120076)
(cherry picked from commit 69b3e8ea56)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									a9e807fe44
								
							
						
					
					
						commit
						4ac0ccf9d3
					
				
					 2 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -216,11 +216,13 @@ def do(self) -> None:
 | 
				
			||||||
        import signal
 | 
					        import signal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.reader.console.finish()
 | 
					        self.reader.console.finish()
 | 
				
			||||||
 | 
					        self.reader.finish()
 | 
				
			||||||
        os.kill(os.getpid(), signal.SIGINT)
 | 
					        os.kill(os.getpid(), signal.SIGINT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ctrl_c(Command):
 | 
					class ctrl_c(Command):
 | 
				
			||||||
    def do(self) -> None:
 | 
					    def do(self) -> None:
 | 
				
			||||||
 | 
					        self.reader.console.finish()
 | 
				
			||||||
        self.reader.finish()
 | 
					        self.reader.finish()
 | 
				
			||||||
        raise KeyboardInterrupt
 | 
					        raise KeyboardInterrupt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -149,7 +149,7 @@ def more_lines(unicodetext: str) -> bool:
 | 
				
			||||||
            assert not more
 | 
					            assert not more
 | 
				
			||||||
            input_n += 1
 | 
					            input_n += 1
 | 
				
			||||||
        except KeyboardInterrupt:
 | 
					        except KeyboardInterrupt:
 | 
				
			||||||
            console.write("\nKeyboardInterrupt\n")
 | 
					            console.write("KeyboardInterrupt\n")
 | 
				
			||||||
            console.resetbuffer()
 | 
					            console.resetbuffer()
 | 
				
			||||||
        except MemoryError:
 | 
					        except MemoryError:
 | 
				
			||||||
            console.write("\nMemoryError\n")
 | 
					            console.write("\nMemoryError\n")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue