Update of /cvsroot/pypgsql/pypgsql/pyPgSQL
In directory sc8-pr-cvs1:/tmp/cvs-serv15180/pyPgSQL
Modified Files:
PgSQL.py
Log Message:
04DEC2002 bga Fixed problems with PgNumeric that were missed in yesterday's
patch.
Index: PgSQL.py
===================================================================
RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** PgSQL.py 4 Dec 2002 07:08:44 -0000 1.26
--- PgSQL.py 5 Dec 2002 04:22:02 -0000 1.27
***************
*** 30,33 ****
--- 30,35 ----
# Date Ini Description |
# --------- --- ------------------------------------------------------- |
+ # 04DEC2002 bga - Correct some problems that were missed in yesterday's |
+ # fixes (Thanks, Adam, for the help with the problems) |
# 03DEC2002 bga - Fixed various problems with the constructor and the |
# formatting routine. These correct the problems re- |
***************
*** 1216,1219 ****
--- 1218,1229 ----
else:
self.__v = long(value)
+ # Check to see if the value is too large for the given
+ # precision/scale
+ _v = str(value)
+ if _v[-1:] == 'L':
+ _v = _v[:-1]
+ if len(_v) > prec:
+ raise OverflowError, "value too large for PgNumeric"
+
self.__p = prec
self.__s = scale
***************
*** 1241,1251 ****
_d = _v.rfind('.')
_e = _v.rfind('e')
_ip = _v[:_d]
! if _e >= 0:
! _fp = _v[_d+1:_e]
! _xp = _v[_e+1:]
! else:
! _fp = _v[_d+1:]
! _xp = ''
# Check the validity of the input
--- 1251,1265 ----
_d = _v.rfind('.')
_e = _v.rfind('e')
+
+ # Ensure that _e and _v contains a sane value
+ if _e < 0:
+ _e = len(_v)
+
+ if _d < 0:
+ _d = _e
+
_ip = _v[:_d]
! _fp = _v[_d+1:_e]
! _xp = _v[_e+1:]
# Check the validity of the input
***************
*** 1270,1279 ****
# Create the string that will become the base (long) object
! _v = _ip + _fp
_sc = len(_fp)
if _exp > 0:
if _exp > _sc:
! _v = _v + ("0" * (_exp - _sc + 1))
_sc = 0
else:
--- 1284,1293 ----
# Create the string that will become the base (long) object
! _v = _ip + _fp
_sc = len(_fp)
if _exp > 0:
if _exp > _sc:
! _v = _v + ("0" * (_exp - _sc))
_sc = 0
else:
***************
*** 1353,1359 ****
def __fmtNumeric(self, value=None):
- # Check to see if the string representation of the python long has
- # a trailing 'L', if so, remove it. Python 1.5 has the trailing 'L',
- # Python 1.6 does not.
if value is None:
_v = self.__v
--- 1367,1370 ----
***************
*** 1369,1372 ****
--- 1380,1386 ----
_v = str(_v)
+ # Check to see if the string representation of the python long has
+ # a trailing 'L', if so, remove it. Python 1.5 has the trailing 'L',
+ # Python 1.6 does not.
if _v[-1:] == 'L':
_v = _v[:-1]
|