Skip to content

Commit 9524203

Browse files
[3.10] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140855)
(cherry picked from commit fe694a6) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent 3a623c6 commit 9524203

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Tools/clinic/clinic.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4558,10 +4558,8 @@ def bad_node(self, node):
45584558
c_default = "NULL"
45594559
elif (isinstance(expr, ast.BinOp) or
45604560
(isinstance(expr, ast.UnaryOp) and
4561-
not (isinstance(expr.operand, ast.Num) or
4562-
(hasattr(ast, 'Constant') and
4563-
isinstance(expr.operand, ast.Constant) and
4564-
type(expr.operand.value) in (int, float, complex)))
4561+
not (isinstance(expr.operand, ast.Constant) and
4562+
type(expr.operand.value) in {int, float, complex})
45654563
)):
45664564
c_default = kwargs.get("c_default")
45674565
if not (isinstance(c_default, str) and c_default):
@@ -4658,14 +4656,10 @@ def bad_node(self, node):
46584656
self.function.parameters[key] = p
46594657

46604658
def parse_converter(self, annotation):
4661-
if (hasattr(ast, 'Constant') and
4662-
isinstance(annotation, ast.Constant) and
4659+
if (isinstance(annotation, ast.Constant) and
46634660
type(annotation.value) is str):
46644661
return annotation.value, True, {}
46654662

4666-
if isinstance(annotation, ast.Str):
4667-
return annotation.s, True, {}
4668-
46694663
if isinstance(annotation, ast.Name):
46704664
return annotation.id, False, {}
46714665

0 commit comments

Comments
 (0)