From: SourceForge.net <no...@so...> - 2003-03-07 06:03:22
|
Bugs item #694358, was opened at 2003-02-27 18:34 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=694358&group_id=16528 Category: PgNumeric Group: None Status: Open Resolution: None Priority: 5 Submitted By: Gerhard Häring (ghaering) Assigned to: Billy G. Allie (ballie01) Summary: Buggy __radd__ in PgNumeric Initial Comment: [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 ---------------------------------------------------------------------- Comment By: Vivek Kumar (gupt_vive) Date: 2003-03-07 11:14 Message: 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 ---------------------------------------------------------------------- Comment By: Vivek Kumar (gupt_vive) Date: 2003-03-07 11:13 Message: 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 ---------------------------------------------------------------------- Comment By: Gerhard Häring (ghaering) Date: 2003-03-02 16:40 Message: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=694358&group_id=16528 |