[3.11] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-1043… · python/cpython@20fe182

GitHub

@@ -4664,10 +4664,8 @@ def bad_node(self, node):

46644664c_default="NULL"

46654665elif (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 )):

46724670c_default=kwargs.get("c_default")

46734671ifnot (isinstance(c_default, str) andc_default):

@@ -4769,14 +4767,10 @@ def bad_node(self, node):

47694767self.function.parameters[key] =p

4770476847714769defparse_converter(self, annotation):

4772-if (hasattr(ast, 'Constant') and

4773-isinstance(annotation, ast.Constant) and

4770+if (isinstance(annotation, ast.Constant) and

47744771type(annotation.value) isstr):

47754772returnannotation.value, True, {}

477647734777-ifisinstance(annotation, ast.Str):

4778-returnannotation.s, True, {}

4779-47804774ifisinstance(annotation, ast.Name):

47814775returnannotation.id, False, {}

47824776