https://github.com/python/cpython/commit/fde6ac1290ac582b4f7bf95e8d9e28408ddffe15 commit: fde6ac1290ac582b4f7bf95e8d9e28408ddffe15 branch: 3.9 author: Miss Islington (bot) <[email protected]> committer: ambv <[email protected]> date: 2025-10-31T17:56:55+01:00 summary:
[3.9] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140854) (cherry picked from commit fe694a6db620062f467469bd2bb987315d72fd62) Co-authored-by: Alex Waygood <[email protected]> files: M Tools/clinic/clinic.py diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index c68ee9a232078f..f35f08f010c5c5 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -4518,10 +4518,8 @@ def bad_node(self, node): c_default = "NULL" elif (isinstance(expr, ast.BinOp) or (isinstance(expr, ast.UnaryOp) and - not (isinstance(expr.operand, ast.Num) or - (hasattr(ast, 'Constant') and - isinstance(expr.operand, ast.Constant) and - type(expr.operand.value) in (int, float, complex))) + not (isinstance(expr.operand, ast.Constant) and + type(expr.operand.value) in {int, float, complex}) )): c_default = kwargs.get("c_default") if not (isinstance(c_default, str) and c_default): @@ -4613,14 +4611,10 @@ def bad_node(self, node): self.function.parameters[parameter_name] = p def parse_converter(self, annotation): - if (hasattr(ast, 'Constant') and - isinstance(annotation, ast.Constant) and + if (isinstance(annotation, ast.Constant) and type(annotation.value) is str): return annotation.value, True, {} - if isinstance(annotation, ast.Str): - return annotation.s, True, {} - if isinstance(annotation, ast.Name): return annotation.id, False, {} _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
