mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Add parser test
Note in particular that the `exceptions.py` test is unaffected.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Module: [1, 0] - [27, 0]
|
||||
Module: [1, 0] - [32, 0]
|
||||
body: [
|
||||
Try: [1, 0] - [1, 4]
|
||||
body: [
|
||||
@@ -153,4 +153,28 @@ Module: [1, 0] - [27, 0]
|
||||
]
|
||||
]
|
||||
finalbody: []
|
||||
Try: [28, 0] - [28, 4]
|
||||
body: [
|
||||
Pass: [29, 4] - [29, 8]
|
||||
]
|
||||
orelse: []
|
||||
handlers: [
|
||||
ExceptGroupStmt: [30, 0] - [31, 8]
|
||||
type:
|
||||
Tuple: [30, 8] - [30, 12]
|
||||
elts: [
|
||||
Name: [30, 8] - [30, 9]
|
||||
variable: Variable('x', None)
|
||||
ctx: Load
|
||||
Name: [30, 11] - [30, 12]
|
||||
variable: Variable('y', None)
|
||||
ctx: Load
|
||||
]
|
||||
ctx: Load
|
||||
name: None
|
||||
body: [
|
||||
Pass: [31, 4] - [31, 8]
|
||||
]
|
||||
]
|
||||
finalbody: []
|
||||
]
|
||||
|
||||
@@ -24,3 +24,8 @@ try:
|
||||
pass
|
||||
except *foo as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
pass
|
||||
except* x, y:
|
||||
pass
|
||||
|
||||
64
python/extractor/tests/parser/exceptions_new.expected
Normal file
64
python/extractor/tests/parser/exceptions_new.expected
Normal file
@@ -0,0 +1,64 @@
|
||||
Module: [1, 0] - [9, 0]
|
||||
body: [
|
||||
Try: [1, 0] - [1, 4]
|
||||
body: [
|
||||
Pass: [2, 4] - [2, 8]
|
||||
]
|
||||
orelse: []
|
||||
handlers: [
|
||||
ExceptStmt: [3, 0] - [3, 12]
|
||||
type:
|
||||
Tuple: [3, 7] - [3, 11]
|
||||
elts: [
|
||||
Name: [3, 7] - [3, 8]
|
||||
variable: Variable('a', None)
|
||||
ctx: Load
|
||||
Name: [3, 10] - [3, 11]
|
||||
variable: Variable('b', None)
|
||||
ctx: Load
|
||||
]
|
||||
ctx: Load
|
||||
name: None
|
||||
body: [
|
||||
Pass: [4, 4] - [4, 8]
|
||||
]
|
||||
ExceptStmt: [5, 0] - [5, 14]
|
||||
type:
|
||||
Tuple: [5, 8] - [5, 12]
|
||||
elts: [
|
||||
Name: [5, 8] - [5, 9]
|
||||
variable: Variable('c', None)
|
||||
ctx: Load
|
||||
Name: [5, 11] - [5, 12]
|
||||
variable: Variable('d', None)
|
||||
ctx: Load
|
||||
]
|
||||
ctx: Load
|
||||
parenthesised: True
|
||||
name: None
|
||||
body: [
|
||||
Pass: [6, 4] - [6, 8]
|
||||
]
|
||||
ExceptStmt: [7, 0] - [7, 19]
|
||||
type:
|
||||
Tuple: [7, 8] - [7, 12]
|
||||
elts: [
|
||||
Name: [7, 8] - [7, 9]
|
||||
variable: Variable('e', None)
|
||||
ctx: Load
|
||||
Name: [7, 11] - [7, 12]
|
||||
variable: Variable('f', None)
|
||||
ctx: Load
|
||||
]
|
||||
ctx: Load
|
||||
parenthesised: True
|
||||
name:
|
||||
Name: [7, 17] - [7, 18]
|
||||
variable: Variable('g', None)
|
||||
ctx: Store
|
||||
body: [
|
||||
Pass: [8, 4] - [8, 8]
|
||||
]
|
||||
]
|
||||
finalbody: []
|
||||
]
|
||||
8
python/extractor/tests/parser/exceptions_new.py
Normal file
8
python/extractor/tests/parser/exceptions_new.py
Normal file
@@ -0,0 +1,8 @@
|
||||
try:
|
||||
pass
|
||||
except a, b: # new, relaxed syntax
|
||||
pass
|
||||
except (c, d): # old syntax
|
||||
pass
|
||||
except (e, f) as g: # old syntax
|
||||
pass
|
||||
Reference in New Issue
Block a user