mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.11] gh-90953: Don't use deprecated AST nodes in clinic.py (GH-104322) (GH-140856)
(cherry picked from commit fe694a6db6)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
0cd888b8d3
commit
20fe1821d7
1 changed files with 3 additions and 9 deletions
|
|
@ -4664,10 +4664,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):
|
||||
|
|
@ -4769,14 +4767,10 @@ def bad_node(self, node):
|
|||
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, {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue