File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 11import array
22import collections
33import dataclasses
4+ import dis
45import enum
56import inspect
67import sys
@@ -3083,6 +3084,24 @@ class Keys:
30833084 self .assertIs (y , None )
30843085 self .assertIs (z , None )
30853086
3087+ class TestSourceLocations (unittest .TestCase ):
3088+ def test_jump_threading (self ):
3089+ # See gh-123048
3090+ def f ():
3091+ x = 0
3092+ v = 1
3093+ match v :
3094+ case 1 :
3095+ if x < 0 :
3096+ x = 1
3097+ case 2 :
3098+ if x < 0 :
3099+ x = 1
3100+ x += 1
3101+
3102+ for inst in dis .get_instructions (f ):
3103+ if inst .opcode in dis .hasjrel or inst .opcode in dis .hasjabs :
3104+ self .assertIsNotNone (inst .positions .lineno , "jump without location" )
30863105
30873106class TestTracing (unittest .TestCase ):
30883107
Original file line number Diff line number Diff line change 1+ Fix a bug where pattern matching code could emit a :opcode: `JUMP_FORWARD `
2+ with no source location.
You can’t perform that action at this time.
0 commit comments