Skip to content

Commit

Permalink
more defensive
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed May 7, 2019
1 parent 506ef93 commit 97fc943
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyrepl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ def prepare(self):
"""Get ready to run. Call restore when finished. You must not
write to the console in between the calls to prepare and
restore."""
self.console.prepare()
try:
self.console.prepare()
self.arg = None
self.screeninfo = []
self.finished = 0
Expand Down
4 changes: 4 additions & 0 deletions pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def prepare(self):
except termios.error: # (25, 'Inappropriate ioctl for device')
# assert not os.fdopen(self.input_fd).isatty()
raise EOFError
self._prepared = True
raw = self.__svtermstate.copy()
raw.iflag |= termios.ICRNL
raw.iflag &= ~(termios.BRKINT | termios.INPCK |
Expand Down Expand Up @@ -390,6 +391,9 @@ def prepare(self):
pass

def restore(self):
if not hasattr(self, '_prepared'):
return
del self._prepared
self.__maybe_write_code(self._rmkx)
self.flushoutput()
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
Expand Down

0 comments on commit 97fc943

Please sign in to comment.