From: <wa...@us...> - 2008-05-14 21:23:44
|
Revision: 1448 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1448&view=rev Author: warnes Date: 2008-05-14 14:23:50 -0700 (Wed, 14 May 2008) Log Message: ----------- Apply patch from Olen (olatho) to fix handling of header when some entries are not present Modified Paths: -------------- trunk/SOAPpy/SOAPpy/Parser.py Modified: trunk/SOAPpy/SOAPpy/Parser.py =================================================================== --- trunk/SOAPpy/SOAPpy/Parser.py 2008-05-14 21:21:04 UTC (rev 1447) +++ trunk/SOAPpy/SOAPpy/Parser.py 2008-05-14 21:23:50 UTC (rev 1448) @@ -137,7 +137,10 @@ i = kind.find(':') if i >= 0: - kind = (self._prem[kind[:i]], kind[i + 1:]) + try: + kind = (self._prem[kind[:i]], kind[i + 1:]) + except: + kind = None else: kind = None @@ -232,7 +235,10 @@ if kind != None: i = kind.find(':') if i >= 0: - kind = (self._prem[kind[:i]], kind[i + 1:]) + try: + kind = (self._prem[kind[:i]], kind[i + 1:]) + except: + kind = (None, kind) else: # XXX What to do here? (None, kind) is just going to fail in convertType #print "Kind with no NS:", kind This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2008-05-15 22:19:50
|
Revision: 1461 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1461&view=rev Author: warnes Date: 2008-05-15 15:19:57 -0700 (Thu, 15 May 2008) Log Message: ----------- Correct separate handling of SOAP 'integer' type, which is unbounded Modified Paths: -------------- trunk/SOAPpy/SOAPpy/Parser.py Modified: trunk/SOAPpy/SOAPpy/Parser.py =================================================================== --- trunk/SOAPpy/SOAPpy/Parser.py 2008-05-15 22:19:29 UTC (rev 1460) +++ trunk/SOAPpy/SOAPpy/Parser.py 2008-05-15 22:19:57 UTC (rev 1461) @@ -371,6 +371,12 @@ # Nothing's been added to the current frame so it must be a # simple type. +# print "cur:", cur +# print "ns:", ns +# print "attrs:", attrs +# print "kind:", kind + + if kind == None: # If the current item's container is an array, it will # have a kind. If so, get the bit before the first [, @@ -792,7 +798,7 @@ 'negative-integer': (0, None, -1), 'long': (1, -9223372036854775808L, 9223372036854775807L), - 'int': (0, -2147483648L, 2147483647), + 'int': (0, -2147483648L, 2147483647L), 'short': (0, -32768, 32767), 'byte': (0, -128, 127), 'nonNegativeInteger': (0, 0, None), @@ -854,8 +860,18 @@ #print " requested_type=", t #print " data=", d + +# print "convertToBasicTypes:" +# print " requested_type=", t +# print " data=", d +# print " attrs=", attrs +# print " t[0]=", t[0] +# print " t[1]=", t[1] + +# print " in?", t[0] in NS.EXSD_L + if t[0] in NS.EXSD_L: - if t[1] in ["int", "integer"]: + if t[1]=="integer": # unbounded integer type try: d = int(d) if len(attrs): @@ -863,7 +879,7 @@ except: d = long(d) return d - if self.intlimits.has_key (t[1]): # integer types + if self.intlimits.has_key (t[1]): # range-bounded integer types l = self.intlimits[t[1]] try: d = int(d) except: d = long(d) @@ -883,7 +899,7 @@ return str(dnn) except: return dnn - if t[1] in ["bool", "boolean"]: + if t[1] in ("bool", "boolean"): d = d.strip().lower() if d in ('0', 'false'): return False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2008-05-15 22:34:30
|
Revision: 1463 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1463&view=rev Author: warnes Date: 2008-05-15 15:34:37 -0700 (Thu, 15 May 2008) Log Message: ----------- Avoid relying on Python's builtin 'float(x)' function to properly handle NaN, Inf, +Inf, -Inf, resolves bug #1366752 Modified Paths: -------------- trunk/SOAPpy/SOAPpy/Parser.py Modified: trunk/SOAPpy/SOAPpy/Parser.py =================================================================== --- trunk/SOAPpy/SOAPpy/Parser.py 2008-05-15 22:22:01 UTC (rev 1462) +++ trunk/SOAPpy/SOAPpy/Parser.py 2008-05-15 22:34:37 UTC (rev 1463) @@ -910,43 +910,38 @@ l = self.floatlimits[t[1]] s = d.strip().lower() - d = float(s) + # Explicitly check for NaN and Infinities + if s == "nan": + d = fpconst.NaN + elif s[0:2]=="inf" or s[0:3]=="+inf": + d = fpconst.PosInf + elif s[0:3] == "-inf": + d = fpconst.NegInf + else : + 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 fpconst.isNaN(d): - if s != 'nan': - raise ValueError, "invalid %s: %s" % (t[1], s) - elif fpconst.isNegInf(d): - if s != '-inf': - raise UnderflowError, "%s too small: %s" % (t[1], s) - elif fpconst.isPosInf(d): - if s != 'inf': - 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: %s" % (t[1], s) - + if fpconst.isNaN(d): + if s[0:2] != 'nan': + raise ValueError, "invalid %s: %s" % (t[1], s) + elif fpconst.isNegInf(d): + if s[0:3] != '-inf': + raise UnderflowError, "%s too small: %s" % (t[1], s) + elif fpconst.isPosInf(d): + if s[0:2] != 'inf' and s[0:3] != '+inf': + 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: %s" % (t[1], s) return d + if t[1] in ("dateTime", "date", "timeInstant", "time"): return self.convertDateTime(d, t[1]) if t[1] == "decimal": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |