File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import inspect
1818import io
1919import itertools
20+ import numbers
2021import os
2122import pprint
2223import re
@@ -3788,7 +3789,8 @@ def bad_node(self, node):
37883789 py_default = 'None'
37893790 c_default = "NULL"
37903791 elif (isinstance (expr , ast .BinOp ) or
3791- (isinstance (expr , ast .UnaryOp ) and not isinstance (expr .operand , ast .Num ))):
3792+ (isinstance (expr , ast .UnaryOp ) and
3793+ not (isinstance (expr .operand , ast .Constant ) and isinstance (expr .operand .value , numbers .Number )))):
37923794 c_default = kwargs .get ("c_default" )
37933795 if not (isinstance (c_default , str ) and c_default ):
37943796 fail ("When you specify an expression (" + repr (default ) + ") as your default value,\n you MUST specify a valid c_default." )
@@ -3866,7 +3868,7 @@ def bad_node(self, node):
38663868 self .function .parameters [parameter_name ] = p
38673869
38683870 def parse_converter (self , annotation ):
3869- if isinstance (annotation , ast .Str ):
3871+ if isinstance (annotation , ast .Constant ) and isinstance ( expr . operand . value , str ):
38703872 return annotation .s , True , {}
38713873
38723874 if isinstance (annotation , ast .Name ):
You can’t perform that action at this time.
0 commit comments