summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-08-20 10:39:41 (GMT)
committerGitHub <noreply@github.com>2024-08-20 10:39:41 (GMT)
commitbffed80230f2617de2ee02bd4bdded1024234dab (patch)
tree8a0b46e06425ae76817b50571b5bf29c5349909d /Lib/test
parent77133f570dcad599e5b1199c39e999bfac959ae2 (diff)
downloadcpython-bffed80230f2617de2ee02bd4bdded1024234dab.zip
cpython-bffed80230f2617de2ee02bd4bdded1024234dab.tar.gz
cpython-bffed80230f2617de2ee02bd4bdded1024234dab.tar.bz2
gh-123048: Fix missing source location in pattern matching code (#123167)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_patma.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py
index 1bdab12..8325b83 100644
--- a/Lib/test/test_patma.py
+++ b/Lib/test/test_patma.py
@@ -1,6 +1,7 @@
import array
import collections
import dataclasses
+import dis
import enum
import inspect
import sys
@@ -3377,6 +3378,24 @@ class TestValueErrors(unittest.TestCase):
self.assertIs(y, None)
self.assertIs(z, None)
+class TestSourceLocations(unittest.TestCase):
+ def test_jump_threading(self):
+ # See gh-123048
+ def f():
+ x = 0
+ v = 1
+ match v:
+ case 1:
+ if x < 0:
+ x = 1
+ case 2:
+ if x < 0:
+ x = 1
+ x += 1
+
+ for inst in dis.get_instructions(f):
+ if inst.opcode in dis.hasjump:
+ self.assertIsNotNone(inst.positions.lineno, "jump without location")
class TestTracing(unittest.TestCase):