File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -478,8 +478,8 @@ def prepare(self):
478478 """Get ready to run. Call restore when finished. You must not
479479 write to the console in between the calls to prepare and
480480 restore."""
481- self .console .prepare ()
482481 try :
482+ self .console .prepare ()
483483 self .arg = None
484484 self .screeninfo = []
485485 self .finished = 0
Original file line number Diff line number Diff line change @@ -359,6 +359,7 @@ def prepare(self):
359359 except termios .error : # (25, 'Inappropriate ioctl for device')
360360 # assert not os.fdopen(self.input_fd).isatty()
361361 raise EOFError
362+ self ._prepared = True
362363 raw = self .__svtermstate .copy ()
363364 raw .iflag |= termios .ICRNL
364365 raw .iflag &= ~ (termios .BRKINT | termios .INPCK |
@@ -390,6 +391,9 @@ def prepare(self):
390391 pass
391392
392393 def restore (self ):
394+ if not hasattr (self , '_prepared' ):
395+ return
396+ del self ._prepared
393397 self .__maybe_write_code (self ._rmkx )
394398 self .flushoutput ()
395399 tcsetattr (self .input_fd , termios .TCSADRAIN , self .__svtermstate )
You can’t perform that action at this time.
0 commit comments