From: <wa...@us...> - 2003-12-19 20:19:18
|
Update of /cvsroot/pywebsvcs/SOAPpy/SOAPpy In directory sc8-pr-cvs1:/tmp/cvs-serv29152/SOAPpy Modified Files: Client.py Parser.py SOAPBuilder.py Log Message: - Updated calls to fpconst - SOAPpy now checks for nonstandard infinity encoding produced by some older SOAP tools like SOAP4J and Apache SOAP (both now superceeded by Axis SOAP). - Added the offending XML string to the exception thrown when a float/double underflow or overflow occurs. - Minor twiddles in the examples. Index: Client.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/Client.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Client.py 19 Dec 2003 18:22:23 -0000 1.12 +++ Client.py 19 Dec 2003 20:19:13 -0000 1.13 @@ -356,10 +356,11 @@ try: count = 0 for i in p.__dict__.keys(): - if i[0] != "_": # don't move the private stuff + if i[0] != "_": # don't count the private stuff count += 1 t = getattr(p, i) - if count == 1: p = t # Only one piece of data, bubble it up + if count == 1: # Only one piece of data, bubble it up + p = t except: pass Index: Parser.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/Parser.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Parser.py 19 Dec 2003 17:04:43 -0000 1.10 +++ Parser.py 19 Dec 2003 20:19:13 -0000 1.11 @@ -807,40 +807,41 @@ l = self.floatlimits[t[1]] s = d.strip().lower() - if s == "nan": - return fpconst.NaN - elif s == "inf": - return fpconst.PosInf - elif s == "-inf": - return fpconst.NegInf - d = float(s) if config.strict_range: if d < l[1]: raise UnderflowError if d > l[2]: raise OverflowError + else: + # some older SOAP impementations (notably SOAP4J, + # Apache SOAP) return "infinity" instead of "INF" + # so check the first 3 characters for a match. + if s == "nan": + return fpconst.NaN + elif s[0:3] in ("inf", "+inf"): + return fpconst.PosInf + elif s[0:3] == "-inf": + return fpconst.NegInf - if str(d).lower() == 'nan': + if fpconst.isNaN(d): if s != 'nan': - raise ValueError, "invalid %s" % t[1] - elif str(d).lower() == '-inf': + raise ValueError, "invalid %s: %s" % (t[1], s) + elif fpconst.isNegInf(d): if s != '-inf': - raise UnderflowError, "%s too small" % t[1] - elif str(d).lower() == 'inf': + raise UnderflowError, "%s too small: %s" % (t[1], s) + elif fpconst.isPosInf(d): if s != 'inf': - raise OverflowError, "%s too large" % t[1] - elif d < 0: - if d < l[1]: - raise UnderflowError, "%s too small" % t[1] - elif d > 0: - if d < l[0] or d > l[2]: - raise OverflowError, "%s too large" % t[1] + raise OverflowError, "%s too large: %s" % (t[1], s) + elif d < 0 and d < l[1]: + raise UnderflowError, "%s too small: %s" % (t[1], s) + elif d > 0 and ( d < l[0] or d > l[2] ): + raise OverflowError, "%s too large: %s" % (t[1], s) elif d == 0: if type(self.zerofloatre) == StringType: self.zerofloatre = re.compile(self.zerofloatre) if self.zerofloatre.search(s): - raise UnderflowError, "invalid %s" % t[1] + raise UnderflowError, "invalid %s: %s" % (t[1], s) return d if t[1] in ("dateTime", "date", "timeInstant", "time"): Index: SOAPBuilder.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/SOAPBuilder.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SOAPBuilder.py 18 Dec 2003 22:40:57 -0000 1.9 +++ SOAPBuilder.py 19 Dec 2003 20:19:13 -0000 1.10 @@ -326,11 +326,11 @@ if Config.strict_range: doubleType(obj) - if fpconst.is_PosInf(obj): + if fpconst.isPosInf(obj): obj = "INF" - elif fpconst.is_NegInf(obj): + elif fpconst.isNegInf(obj): obj = "-INF" - elif fpconst.is_NaN(obj): + elif fpconst.isNaN(obj): obj = "NaN" else: obj = str(obj) |