A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/084738.html below:

PyObject_CallObject, execptions and ref counts

PyObject_CallObject, execptions and ref counts PyObject_CallObject, execptions and ref countsPatrick Down pdown at bigfoot.com
Thu Apr 19 22:38:29 EDT 2001
I have a python object that has a method that I use as a callback function
from C.
I pass the method a couple of objects as parameters. When the callback code
executes correctly and returns, all the reference counts on the objects I
passed
as parameters are decremented correctly and they are deleted. ( The callback
doesn't hold a reference to them. )  When there is an error in the callback
code
I test for it with PyErr_Occurred() and call PyErr_Print() and PyErr_Clear()
but the reference counts on the objects I passed in are not decremented.
It's as
if the stack was not being unwound correctly and the local variables
dereferenced.

As an experiment I put a try: except: block in the callback code.  This
fixed the
reference count problem. However I would like to be able to handle errors
gracefully
from the C code without expecting the callback writer to put in exception
handling.

Anyone have an idea what I might be doing wrong or how I can fix this?

Patrick Down
pdown at codemoon.com




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4