Skip to content

Commit fde6ac1

Browse files
[3.9] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140854)
(cherry picked from commit fe694a6) Co-authored-by: Alex Waygood <[email protected]>
1 parent 2e6150a commit fde6ac1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Tools/clinic/clinic.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,10 +4518,8 @@ def bad_node(self, node):
45184518
c_default = "NULL"
45194519
elif (isinstance(expr, ast.BinOp) or
45204520
(isinstance(expr, ast.UnaryOp) and
4521-
not (isinstance(expr.operand, ast.Num) or
4522-
(hasattr(ast, 'Constant') and
4523-
isinstance(expr.operand, ast.Constant) and
4524-
type(expr.operand.value) in (int, float, complex)))
4521+
not (isinstance(expr.operand, ast.Constant) and
4522+
type(expr.operand.value) in {int, float, complex})
45254523
)):
45264524
c_default = kwargs.get("c_default")
45274525
if not (isinstance(c_default, str) and c_default):
@@ -4613,14 +4611,10 @@ def bad_node(self, node):
46134611
self.function.parameters[parameter_name] = p
46144612

46154613
def parse_converter(self, annotation):
4616-
if (hasattr(ast, 'Constant') and
4617-
isinstance(annotation, ast.Constant) and
4614+
if (isinstance(annotation, ast.Constant) and
46184615
type(annotation.value) is str):
46194616
return annotation.value, True, {}
46204617

4621-
if isinstance(annotation, ast.Str):
4622-
return annotation.s, True, {}
4623-
46244618
if isinstance(annotation, ast.Name):
46254619
return annotation.id, False, {}
46264620

0 commit comments

Comments
 (0)