summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2023-07-11 01:14:53 (GMT)
committerGitHub <noreply@github.com>2023-07-11 01:14:53 (GMT)
commit115df8491a6633ced3cc3f2343b349869de30b8c (patch)
tree8de8d0a393db340069e8a155af42adc9dd7f1377
parent22988c323ad621b9f47b6cb640b80ac806e26368 (diff)
downloadcpython-115df8491a6633ced3cc3f2343b349869de30b8c.zip
cpython-115df8491a6633ced3cc3f2343b349869de30b8c.tar.gz
cpython-115df8491a6633ced3cc3f2343b349869de30b8c.tar.bz2
gh-104635: Add a test case for variables that have a dependency. (gh-106583)
-rw-r--r--Lib/test/test_compile.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 784c055..85ce0a4 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1186,6 +1186,15 @@ class TestSpecifics(unittest.TestCase):
return a
self.assertEqual(f("x", "y", "z"), "y")
+ def test_variable_dependent(self):
+ # gh-104635: Since the value of b is dependent on the value of a
+ # the first STORE_FAST for a should not be skipped. (e.g POP_TOP).
+ # This test case is added to prevent potential regression from aggressive optimization.
+ def f():
+ a = 42; b = a + 54; a = 54
+ return a, b
+ self.assertEqual(f(), (54, 96))
+
@requires_debug_ranges()
class TestSourcePositions(unittest.TestCase):