From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:57:52 +0000 (+0100) Subject: [3.11] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140856) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=20fe1821d7957c112b666ceadbdb1ad67c8104c2;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140856) (cherry picked from commit fe694a6db620062f467469bd2bb987315d72fd62) Co-authored-by: Alex Waygood --- diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 337ab88f7e7e..d644b716aec7 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -4664,10 +4664,8 @@ class DSLParser: 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): @@ -4769,14 +4767,10 @@ class DSLParser: self.function.parameters[key] = 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, {}