Skip to content

Commit 3aa1b79

Browse files
committed
Remove the use of deprecated ast.Num and ast.Str types
Signed-off-by: Matěj Cepl <[email protected]>
1 parent 0c4d127 commit 3aa1b79

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Tools/clinic/clinic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import inspect
1818
import io
1919
import itertools
20+
import numbers
2021
import os
2122
import pprint
2223
import re
@@ -3788,7 +3789,8 @@ def bad_node(self, node):
37883789
py_default = 'None'
37893790
c_default = "NULL"
37903791
elif (isinstance(expr, ast.BinOp) or
3791-
(isinstance(expr, ast.UnaryOp) and not isinstance(expr.operand, ast.Num))):
3792+
(isinstance(expr, ast.UnaryOp) and
3793+
not (isinstance(expr.operand, ast.Constant) and isinstance(expr.operand.value, numbers.Number)))):
37923794
c_default = kwargs.get("c_default")
37933795
if not (isinstance(c_default, str) and c_default):
37943796
fail("When you specify an expression (" + repr(default) + ") as your default value,\nyou MUST specify a valid c_default.")
@@ -3866,7 +3868,7 @@ def bad_node(self, node):
38663868
self.function.parameters[parameter_name] = p
38673869

38683870
def parse_converter(self, annotation):
3869-
if isinstance(annotation, ast.Str):
3871+
if isinstance(annotation, ast.Constant) and isinstance(expr.operand.value, str):
38703872
return annotation.s, True, {}
38713873

38723874
if isinstance(annotation, ast.Name):

0 commit comments

Comments
 (0)