[vivek kumar sent this to DB-SIG]
hi all,
I am sending this mail at this address coz i was unable
to find some address for reporting possible bug in
pyPgSQL and the
+pyPgSQL project page was not opening (slow net speed).
This may be a bug left in the pyPgSQL version 2.3. When
i try to add some numeric data returned by query
(PgNumeric) then it
+gives me name error (global __add__ not found). The
actual code for the __radd__ in PgNumeric was
def __radd__(self,other):
return __add__(self,other)
A possible work around (it worked for me) may be
def __radd__(self,other):
return self.__add__(other)
regards
vivek kumar
Logged In: YES
user_id=163326
Billy, would you like to take a look at this one? I'm quite
puzzled with the workings of PgNumeric.
Once the obvious bug (self in wrong place) is fixed, there's
more that doesn't work:
>>> 3 + PgNumeric("-5.0")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "pyPgSQL/PgSQL.py", line 1495, in __radd__
return self.__add__(other)
File "pyPgSQL/PgSQL.py", line 1492, in __add__
return PgNumeric((_s + _o), (mp + ms), ms)
File "pyPgSQL/PgSQL.py", line 1262, in __init__
raise OverflowError, "value too large for PgNumeric"
OverflowError: value too large for PgNumeric
__rsub__ seems to be problematic, too.
Logged In: YES
user_id=695184
dear sir,
In your follow up u have given the code
>3+PgNumeric("-5.0")
in the __add__ function the last line returns
>return PgNumeric((_s + _o), (mp + ms), ms)
the __init__code
>__init__(self, value, prec=None, scale=None)
In this case:
the value goes -20 and precision goes 2
in __init__ function
>self.__v = value
and
>_v = str(value)
so here _v becomes "-20"
now also
>if len(_v) > prec: # here len(_v)=3 and prec=2
> raise OverflowError, "value too large for PgNumeric"
so here it returns the OverflowError , as mentioned in your
follow up.
May be the code should first check for negative/positive
values before checking for the value length and precision..
regards
Vivek Kumar
Logged In: YES
user_id=695184
dear sir,
In your follow up u have given the code
>3+PgNumeric("-5.0")
in the __add__ function the last line returns
>return PgNumeric((_s + _o), (mp + ms), ms)
the __init__code
>__init__(self, value, prec=None, scale=None)
In this case:
the value goes -20 and precision goes 2
in __init__ function
>self.__v = value
and
>_v = str(value)
so here _v becomes "-20"
now also
>if len(_v) > prec: # here len(_v)=3 and prec=2
> raise OverflowError, "value too large for PgNumeric"
so here it returns the OverflowError , as mentioned in your
follow up.
May be the code should first check for negative/positive
values before checking for the value length and precision..
regards
Vivek Kumar
Logged In: YES
user_id=8500
This bug is squashed in version 1.32 of PgSQL.py.