summaryrefslogtreecommitdiffstats
path: root/Tools/clinic/clinic.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/clinic/clinic.py')
-rwxr-xr-xTools/clinic/clinic.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index a6a43d1..ca8096f 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -3840,9 +3840,6 @@ class DSLParser:
# "starred": "a = [1, 2, 3]; *a"
visit_Starred = bad_node
- # allow ellipsis, for now
- # visit_Ellipsis = bad_node
-
blacklist = DetectBadNodes()
blacklist.visit(module)
bad = blacklist.bad
@@ -3868,10 +3865,15 @@ class DSLParser:
py_default = 'None'
c_default = "NULL"
elif (isinstance(expr, ast.BinOp) or
- (isinstance(expr, ast.UnaryOp) and not isinstance(expr.operand, ast.Num))):
+ (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)))
+ )):
c_default = kwargs.get("c_default")
if not (isinstance(c_default, str) and c_default):
- fail("When you specify an expression (" + repr(default) + ") as your default value,\nyou MUST specify a valid c_default.")
+ fail("When you specify an expression (" + repr(default) + ") as your default value,\nyou MUST specify a valid c_default." + ast.dump(expr))
py_default = default
value = unknown
elif isinstance(expr, ast.Attribute):
@@ -3946,6 +3948,11 @@ class DSLParser:
self.function.parameters[parameter_name] = p
def parse_converter(self, annotation):
+ if (hasattr(ast, 'Constant') and
+ isinstance(annotation, ast.Constant) and
+ type(annotation.value) is str):
+ return annotation.value, True, {}
+
if isinstance(annotation, ast.Str):
return annotation.s, True, {}