]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140855) 3.10
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 31 Oct 2025 16:56:30 +0000 (17:56 +0100)
committerGitHub <noreply@github.com>
Fri, 31 Oct 2025 16:56:30 +0000 (17:56 +0100)
(cherry picked from commit fe694a6db620062f467469bd2bb987315d72fd62)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Tools/clinic/clinic.py

index b0d1717596f6b1523ad3e79ddb5f6a22983e444f..c9cbf0b2e29f4e4b76591612b6efe95c4d4f0a43 100755 (executable)
@@ -4558,10 +4558,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):
@@ -4658,14 +4656,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, {}