mirror of
https://github.com/python/cpython.git
synced 2025-11-08 01:21:42 +00:00
[3.14] gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for macOS (GH-138089) (#138938)
Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
dc4d016e7e
commit
1c901860e6
5 changed files with 33 additions and 9 deletions
|
|
@ -159,6 +159,10 @@ def __init__(
|
|||
self.pollob.register(self.input_fd, select.POLLIN)
|
||||
self.terminfo = terminfo.TermInfo(term or None)
|
||||
self.term = term
|
||||
self.is_apple_terminal = (
|
||||
platform.system() == "Darwin"
|
||||
and os.getenv("TERM_PROGRAM") == "Apple_Terminal"
|
||||
)
|
||||
|
||||
@overload
|
||||
def _my_getstr(cap: str, optional: Literal[False] = False) -> bytes: ...
|
||||
|
|
@ -339,7 +343,7 @@ def prepare(self):
|
|||
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
|
||||
|
||||
# In macOS terminal we need to deactivate line wrap via ANSI escape code
|
||||
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
|
||||
if self.is_apple_terminal:
|
||||
os.write(self.output_fd, b"\033[?7l")
|
||||
|
||||
self.screen = []
|
||||
|
|
@ -370,7 +374,7 @@ def restore(self):
|
|||
self.flushoutput()
|
||||
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
|
||||
|
||||
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
|
||||
if self.is_apple_terminal:
|
||||
os.write(self.output_fd, b"\033[?7h")
|
||||
|
||||
if hasattr(self, "old_sigwinch"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue