summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-05-18 21:22:03 (GMT)
committerGitHub <noreply@github.com>2023-05-18 21:22:03 (GMT)
commit0589c6a4d3d822cace42050198cb9a5e99c879ad (patch)
treeae6785cbe277413976d6513d80f42206477d5f0b /Lib/test/test_compile.py
parentdcdc90d384723920e8dea0ee04eae8c219333634 (diff)
downloadcpython-0589c6a4d3d822cace42050198cb9a5e99c879ad.zip
cpython-0589c6a4d3d822cace42050198cb9a5e99c879ad.tar.gz
cpython-0589c6a4d3d822cace42050198cb9a5e99c879ad.tar.bz2
gh-104615: don't make unsafe swaps in apply_static_swaps (#104620)
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r--Lib/test/test_compile.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index c68b9ce..784c055 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1168,6 +1168,24 @@ class TestSpecifics(unittest.TestCase):
""")
compile(code, "<test>", "exec")
+ def test_apply_static_swaps(self):
+ def f(x, y):
+ a, a = x, y
+ return a
+ self.assertEqual(f("x", "y"), "y")
+
+ def test_apply_static_swaps_2(self):
+ def f(x, y, z):
+ a, b, a = x, y, z
+ return a
+ self.assertEqual(f("x", "y", "z"), "z")
+
+ def test_apply_static_swaps_3(self):
+ def f(x, y, z):
+ a, a, b = x, y, z
+ return a
+ self.assertEqual(f("x", "y", "z"), "y")
+
@requires_debug_ranges()
class TestSourcePositions(unittest.TestCase):