Skip to content

Commit 45ed845

Browse files
committed
Handle hex bigint literals in nativeparse
1 parent 6fcb8f0 commit 45ed845

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

mypy/nativeparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ def read_expression(state: State, data: ReadBuffer) -> Expression:
15821582
return expr
15831583
elif tag == nodes.BIG_INT_EXPR:
15841584
strval = read_str(data)
1585-
ie = IntExpr(int(strval))
1585+
ie = IntExpr(int(strval, base=0))
15861586
read_loc(data, ie)
15871587
expect_end_tag(data)
15881588
return ie

test-data/unit/native-parser.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MypyFile:1(
4040
StrExpr(z))))
4141

4242
[case testIntExpr]
43-
(0, 1, 2, 203, 5345, 50123, 1234567890, 9982374892739487239847897928374897298374)
43+
(0, 1, 2, 203, 5345, 50123, 1234567890, 9982374892739487239847897928374897298374, 0x1950A86A20F9469CFC6C)
4444
[out]
4545
MypyFile:1(
4646
ExpressionStmt:1(
@@ -52,7 +52,8 @@ MypyFile:1(
5252
IntExpr(5345)
5353
IntExpr(50123)
5454
IntExpr(1234567890)
55-
IntExpr(9982374892739487239847897928374897298374))))
55+
IntExpr(9982374892739487239847897928374897298374)
56+
IntExpr(119547037146038801333356))))
5657

5758
[case testAssignmentStmt]
5859
x = 1

0 commit comments

Comments
 (0)