1111from types import FunctionType
1212
1313from mathics .builtin .box .compilation import CompiledCodeBox
14- from mathics .core .atoms import Complex , Integer , Real , String
14+ from mathics .core .atoms import Complex , Integer , Rational , Real , String
1515from mathics .core .attributes import A_HOLD_ALL , A_PROTECTED
1616from mathics .core .builtin import Builtin
1717from mathics .core .convert .expression import to_mathics_list
@@ -235,12 +235,12 @@ def eval(self, argnames, expr, code, args, evaluation: Evaluation):
235235 try :
236236 spec_type = spec .type
237237 if spec_type is float :
238- if isinstance (arg , (Integer , Real )):
238+ if isinstance (arg , (Integer , Rational , Real )):
239239 val = spec_type (arg .value )
240240 else :
241241 raise TypeError
242242 elif spec_type is int :
243- if isinstance (arg , (Integer , Real )):
243+ if isinstance (arg , (Integer , Rational , Real )):
244244 val = spec_type (arg .value )
245245 # If arg.value was not an integer, show a message but accept it:
246246 if val != arg .value :
@@ -264,7 +264,7 @@ def eval(self, argnames, expr, code, args, evaluation: Evaluation):
264264 if isinstance (arg , Complex ):
265265 value = arg .value
266266 val = complex (value [0 ].value , value [1 ].value )
267- elif isinstance (arg , (Integer , Real )):
267+ elif isinstance (arg , (Integer , Rational , Real )):
268268 val = complex (arg .value )
269269 else :
270270 raise TypeError
@@ -286,4 +286,6 @@ def eval(self, argnames, expr, code, args, evaluation: Evaluation):
286286 except (TypeError , ctypes .ArgumentError ):
287287 evaluation .message ("CompiledFunction" , "argerr" , args )
288288 return
289+ except Exception :
290+ return
289291 return from_python (result )
0 commit comments