Skip to content

Commit 20fe182

Browse files
[3.11] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140856)
(cherry picked from commit fe694a6) Co-authored-by: Alex Waygood <[email protected]>
1 parent 0cd888b commit 20fe182

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
@@ -4664,10 +4664,8 @@ def bad_node(self, node):
46644664
c_default = "NULL"
46654665
elif (isinstance(expr, ast.BinOp) or
46664666
(isinstance(expr, ast.UnaryOp) and
4667-
not (isinstance(expr.operand, ast.Num) or
4668-
(hasattr(ast, 'Constant') and
4669-
isinstance(expr.operand, ast.Constant) and
4670-
type(expr.operand.value) in (int, float, complex)))
4667+
not (isinstance(expr.operand, ast.Constant) and
4668+
type(expr.operand.value) in {int, float, complex})
46714669
)):
46724670
c_default = kwargs.get("c_default")
46734671
if not (isinstance(c_default, str) and c_default):
@@ -4769,14 +4767,10 @@ def bad_node(self, node):
47694767
self.function.parameters[key] = p
47704768

47714769
def parse_converter(self, annotation):
4772-
if (hasattr(ast, 'Constant') and
4773-
isinstance(annotation, ast.Constant) and
4770+
if (isinstance(annotation, ast.Constant) and
47744771
type(annotation.value) is str):
47754772
return annotation.value, True, {}
47764773

4777-
if isinstance(annotation, ast.Str):
4778-
return annotation.s, True, {}
4779-
47804774
if isinstance(annotation, ast.Name):
47814775
return annotation.id, False, {}
47824776

0 commit comments

Comments
 (0)