[Python-checkins] CVS: python/dist/src/Lib xmlrpclib.py,1.13,1.14
Skip Montanaro
montanaro@users.sourceforge.net
Wed, 17 Oct 2001 15:53:35 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv24483
Modified Files:
xmlrpclib.py
Log Message:
test for int and long int overflow (allows operation on 64-bit platforms)
closes patch 470254
Index: xmlrpclib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** xmlrpclib.py 2001/10/17 01:51:04 1.13
--- xmlrpclib.py 2001/10/17 22:53:33 1.14
***************
*** 35,38 ****
--- 35,39 ----
# 2001-10-01 fl Use faster escape method (80% dumps speedup)
# 2001-10-10 sm Allow long ints to be passed as ints if they don't overflow
+ # 2001-10-17 sm test for int and long overflow (allows use on 64-bit systems)
#
# Copyright (c) 1999-2001 by Secret Labs AB.
***************
*** 145,148 ****
--- 146,152 ----
return replace(s, ">", ">",)
+ MAXINT = 2L**31-1
+ MININT = -2L**31
+
if unicode:
def _stringify(string):
***************
*** 463,472 ****
def dump_int(self, value):
self.write("<value><int>%s</int></value>\n" % value)
dispatch[IntType] = dump_int
def dump_long(self, value):
! val = int(value)
! self.write("<value><int>%s</int></value>\n" % val)
dispatch[LongType] = dump_long
--- 467,481 ----
def dump_int(self, value):
+ # in case ints are > 32 bits
+ if value > MAXINT or value < MININT:
+ raise OverflowError, "int exceeds XML-RPC limits"
self.write("<value><int>%s</int></value>\n" % value)
dispatch[IntType] = dump_int
def dump_long(self, value):
! # in case ints are > 32 bits
! if value > MAXINT or value < MININT:
! raise OverflowError, "long int exceeds XML-RPC limits"
! self.write("<value><int>%s</int></value>\n" % int(value))
dispatch[LongType] = dump_long