diff options
author | Tomas R. <tomas.roun8@gmail.com> | 2025-01-22 16:15:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-22 16:15:23 (GMT) |
commit | ba9a4b621577b92f36d88388cc9f791c2dc7d7ba (patch) | |
tree | 2af929cad38cb20c01a1fe6e4f8d2eedf32de598 /Lib/test/test_pyrepl/test_unix_console.py | |
parent | 2ed5ee9a50454b3fce87b26be5838ca7127b2ff9 (diff) | |
download | cpython-ba9a4b621577b92f36d88388cc9f791c2dc7d7ba.zip cpython-ba9a4b621577b92f36d88388cc9f791c2dc7d7ba.tar.gz cpython-ba9a4b621577b92f36d88388cc9f791c2dc7d7ba.tar.bz2 |
gh-128636: Fix crash in PyREPL when `os.environ` is overwritten with an invalid value (#128653)
Diffstat (limited to 'Lib/test/test_pyrepl/test_unix_console.py')
-rw-r--r-- | Lib/test/test_pyrepl/test_unix_console.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_unix_console.py b/Lib/test/test_pyrepl/test_unix_console.py index e3bbabc..15dbf48 100644 --- a/Lib/test/test_pyrepl/test_unix_console.py +++ b/Lib/test/test_pyrepl/test_unix_console.py @@ -1,7 +1,9 @@ import itertools +import os import sys import unittest from functools import partial +from test.support import os_helper from unittest import TestCase from unittest.mock import MagicMock, call, patch, ANY @@ -312,3 +314,14 @@ class TestConsole(TestCase): ) console.restore() con.restore() + + def test_getheightwidth_with_invalid_environ(self, _os_write): + # gh-128636 + console = UnixConsole() + with os_helper.EnvironmentVarGuard() as env: + env["LINES"] = "" + self.assertIsInstance(console.getheightwidth(), tuple) + env["COLUMNS"] = "" + self.assertIsInstance(console.getheightwidth(), tuple) + os.environ = [] + self.assertIsInstance(console.getheightwidth(), tuple) |