From 7dc58797148df765dc62c1cf29f4ca61b7a91c49 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Sat, 18 Jun 2016 18:13:47 -0600 Subject: [PATCH] castmode was failing overflow tests. Fix it. --- Lib/python/pyprimtypes.swg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index fb5bbf6df..575b6db88 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -223,6 +223,8 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) const double mant_min = -mant_max; double d; res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max)) + return SWIG_OverflowError; if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return SWIG_AddCast(res); @@ -280,6 +282,8 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) const double mant_max = 1LL << DBL_MANT_DIG; double d; res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { if (val) *val = (unsigned long long)(d); return SWIG_AddCast(res);