]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90953: Don't use deprecated AST nodes in clinic.py (#104322)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Tue, 9 May 2023 21:16:22 +0000 (22:16 +0100)
committerGitHub <noreply@github.com>
Tue, 9 May 2023 21:16:22 +0000 (22:16 +0100)
Tools/clinic/clinic.py

index a6f330d1502dadeecf821c8f30234b2efde7e61e..2ae8a02aa6d28507374482fe4ce547f5c5e77091 100755 (executable)
@@ -4701,10 +4701,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):
@@ -4806,14 +4804,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, {}