[Patches] [ python-Patches-486743 ] remove bad INCREF, propagate exception
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 02 Dec 2001 10:12:28 -0800
Patches item #486743, was opened at 2001-11-28 15:11
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=486743&group_id=5470
Category: None
Group: None
Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Zooko Ozoko (zooko)
Assigned to: Martin v. Löwis (loewis)
Summary: remove bad INCREF, propagate exception
Initial Comment:
This is my very first foray into the Python
interpreter, so please be patient. It looks like to me
that this INCREF is wrong since the PyList_Append()
will steal the reference. Also I tested it. Current
CVS does this:
>>> import gc
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1562
>>> len(gc.get_objects())
1565
>>> len(gc.get_objects())
1568
>>> len(gc.get_objects())
1571
>>> len(gc.get_objects())
1574
and with my patch it does this:
>>> import gc
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
>>> len(gc.get_objects())
1559
In addition I added checks for error return from
PyList_Append(), and propagated the exception condition
up the callstack.
----------------------------------------------------------------------
>Comment By: Zooko Ozoko (zooko)
Date: 2001-12-02 10:12
Message:
Logged In: YES
user_id=52562
Whoo-hoo! My patch was accepted! :-)
Here's the remaining diffs between my sandbox and the
current CVS. Not sure if there is something wrong with this
or if you just didn't see it:
(The same thing is also attached, since I guess my web
browser will mangle it.)
@@ -724,6 +758,9 @@
if (!PyArg_ParseTuple(args, ":get_objects")) /*
check no args */
return NULL;
result = PyList_New(0);
+ if (result == NULL) {
+ return NULL;
+ }
if (append_objects(result, &_PyGC_generation0) ||
append_objects(result, &generation1) ||
append_objects(result, &generation2)) {
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-12-02 04:22
Message:
Logged In: YES
user_id=21627
Thanks for the patch, committed as gcmodule.c 2.32 (with
slight modifications: return 0 in case of success).
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2001-11-28 16:33
Message:
Logged In: YES
user_id=52562
Whoops. It is against dist/src/Modules/gcmodule.c
----------------------------------------------------------------------
Comment By: Gregory P. Smith (greg)
Date: 2001-11-28 16:30
Message:
Logged In: YES
user_id=413
which file is the patch against?
----------------------------------------------------------------------
Comment By: Zooko Ozoko (zooko)
Date: 2001-11-28 16:12
Message:
Logged In: YES
user_id=52562
Oh, and here is a new version of the patch, which also tests
for failure from PyList_New().
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=486743&group_id=5470