mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +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
|
|
@ -303,3 +303,12 @@ class TestConsole(TestCase):
|
|||
self.assertIsInstance(console.getheightwidth(), tuple)
|
||||
os.environ = []
|
||||
self.assertIsInstance(console.getheightwidth(), tuple)
|
||||
|
||||
@unittest.skipUnless(sys.platform == "darwin", "requires macOS")
|
||||
def test_restore_with_invalid_environ_on_macos(self, _os_write):
|
||||
# gh-128636 for macOS
|
||||
console = UnixConsole(term="xterm")
|
||||
with os_helper.EnvironmentVarGuard():
|
||||
os.environ = []
|
||||
console.prepare() # needed to call restore()
|
||||
console.restore() # this should succeed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue