Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
On Apr 12, 4:27 pm, Gerhard Häring wrote: > Maybe somebody can enlighten me here. I can't figure out why doing a > rich comparison on my object decreases the total reference count by 1. [...] Doh! It turned out the strange effect was due to my particular build process. My Python

Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Can be run like this: ghaer...@ws124~/src/gh/test$ python3 setup.py build_ext --inplace running build_ext building 'foo' extension gcc -fno-strict-aliasing -g -fwrapv -O0 -Wall -Wstrict-prototypes - arch i386 -m32 -I/opt/jetstream/include/python3.1 -c foo.c -o build/ temp.macosx-10.4-i386-3.1-pyde

rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Maybe somebody can enlighten me here. I can't figure out why doing a rich comparison on my object decreases the total reference count by 1. Linked is the minimal test case with a C exension that compiles under both Python 2.6 and 3.1. No external dependencies, except a DEBUG build of Pyth

Re: Decrementing of reference count of new objects?

2008-04-01 Thread Gabriel Genellina
En Tue, 01 Apr 2008 18:49:28 -0300, Mitko Haralanov <[EMAIL PROTECTED]> escribió: > For the most part, I understand the theory behind reference counting in > Python C code. But there is one thing that I am confused about and I > have not been able to clear it up. > > Let say that you have the fo

Decrementing of reference count of new objects?

2008-04-01 Thread Mitko Haralanov
For the most part, I understand the theory behind reference counting in Python C code. But there is one thing that I am confused about and I have not been able to clear it up. Let say that you have the following function (over-simplified): PyObject *do_work (PyObject *self, PyObject *args) {

Re: getting the reference count of an object ...

2006-03-03 Thread Just
ating a dict subclass that counts > the number of assignments and deletions but that seems cumbersome (an > bug-prone). > > Is there a way to get the reference count of these datadict items? I > imagine that this would be a more stable implementation of such a feature. > >

getting the reference count of an object ...

2006-03-03 Thread Wildemar Wildenburger
t found an easy way to determine if said dictionary contents are still in use (so it is ok to delete them from the dictionary). I've thought about creating a dict subclass that counts the number of assignments and deletions but that seems cumbersome (an bug-prone). Is there a way to get th

Re: reference count

2005-09-28 Thread J
I tend to answer my own questions a lot. But he, lets grow the knowledge base :)... PyErr_Clear() after PyErr_Print did the trick J -- http://mail.python.org/mailman/listinfo/python-list

reference count

2005-09-28 Thread J
Hi, I have a problem with the reference count after an error occurs in a script which I execute as follows.. PyObject* lDict = PyDict_New(); PyDict_SetItemString(lDict, "item", (PyObject*)iItem->mPyObject); PyObject* lResult = PyEval_EvalCode(mCode, ScnGlobal::sDictionary, lDict);

Re: __del__ and reference count problem

2005-04-21 Thread Terry Reedy
"tiissa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's interesting to note that self.pop instead of A.pop works as > expected. > But I don't know why A.pop doesn't. Because the name 'A' is no longer associated with the class object. However, self has a reference to the cla

Re: __del__ and reference count problem

2005-04-21 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > it looks like we have to use other way, hold the data we want to > preseve in an object, because it is possible the class is removed > before the instance cleaned, What is removed first is the binding between name A and the class obje

Re: __del__ and reference count problem

2005-04-21 Thread flupke
[EMAIL PROTECTED] wrote: look at this discussion: http://www.dbforums.com/archive/index.php/t-1100372.html it looks like we have to use other way, hold the data we want to preseve in an object, because it is possible the class is removed before the instance cleaned, and we can not expect __del__ 10

Re: __del__ and reference count problem

2005-04-21 Thread [EMAIL PROTECTED]
look at this discussion: http://www.dbforums.com/archive/index.php/t-1100372.html it looks like we have to use other way, hold the data we want to preseve in an object, because it is possible the class is removed before the instance cleaned, and we can not expect __del__ 100% in handling finalizin

Re: __del__ and reference count problem

2005-04-21 Thread tiissa
[EMAIL PROTECTED] wrote: Your problem can be simplified : class A: pop = 11 def __del__(self): print A.pop if __name__ == '__main__': objA = A() I got the same error message, and I don't know why ? it looks like the class variable can't be accessed from __del__? It's interesting to note t

Re: __del__ and reference count problem

2005-04-21 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Your problem can be simplified : class A: pop = 11 def __del__(self): print A.pop if __name__ == '__main__': objA = A() Exception exceptions.AttributeError: "'NoneType' object has no attribute 'pop'" in > ignored I got the same error message, and I don't know why ? it

Re: __del__ and reference count problem

2005-04-21 Thread [EMAIL PROTECTED]
Your problem can be simplified : class A: pop = 11 def __del__(self): print A.pop if __name__ == '__main__': objA = A() Exception exceptions.AttributeError: "'NoneType' object has no attribute 'pop'" in > ignored I got the same error message, and I don't know why ? it looks like the c

__del__ and reference count problem

2005-04-21 Thread flupke
Hi, i'm starting work and a simple database layer and wanted to use the __del__ to open and close a connection. However, i get an erro when executing this script: class Table: refcount = 0 def __init__(self, name): self.name = name print "table %s " % repr(self) T

Re: Reference count question

2005-02-02 Thread Fredrik Lundh
John Machin wrote: >> you should check the return value, though. PyList_SetItem may (in >> theory) fail. > > :-) > Only a bot could say that. We mere mortals have been known to do things > like (a) pass a non-list as the first argument (b) pass an out-of-range > value for the second argument. ev

Re: Reference count question

2005-02-02 Thread John Machin
Fredrik Lundh wrote: > > >PyList_SetItem(List,i,Str); > > you should check the return value, though. PyList_SetItem may (in > theory) fail. > :-) Only a bot could say that. We mere mortals have been known to do things like (a) pass a non-list as the first argument (b) pass an out-of-range va

Re: Reference count question

2005-02-02 Thread Fredrik Lundh
"cedric paille" wrote: > I'm making python's modules to extend my application's functions with a built > in script editor. > At now all works very well, but i'd like to know if i'm not forgetting some > references inc/dec > > Here is a portion of my code: > > static PyObject * > Scene_GetNod

Reference count question

2005-02-02 Thread cedric paille
Hi all, i'm working on an app that embed python 2.3 with Gnu/Linux, and i'd like to have some precisions:   I'm making python's modules to extend my application's functions with a built in script editor. At now all works very well, but i'd like to know if i'm not forgetting some references