Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyEval_EvalCode(...) problem

Reply
Thread Tools

PyEval_EvalCode(...) problem

 
 
googler.1.webmaster@spamgourmet.com
Guest
Posts: n/a
 
      03-10-2009
Hi!

I have a problem with PyEval_EvalCode(...)
I compile the following code and execute them with PyEval_EvalCode
(...)


class MyClass(mod.Upper):
pass

register(MyClass) #just the type, not the instance


Thats all. So register(...) is a Python C API method so i take the
type and store
it in a global variable. PyEval_EvalCode(...) returns not NULL and I
do not decref
the dictionary, just the returnvalue.

After PyEval_EvalCode(..) is executed I would like to create an
instance of MyClass
which crashes because information of the inherited types are corrupt.
If I call

PyObject_CallObject(obj, NULL) in register(..) where PyEval_EvalCode
(..) is still active
everything works fine but when I call it after PyEval_EvalCode, even I
did not decref anything)
its not working. Can anyone of you help me? The refcounts of the
MyClass type are > 0.



Thanks.
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-10-2009
En Tue, 10 Mar 2009 12:32:00 -0200, <(E-Mail Removed)>
escribió:

> Hi!
>
> I have a problem with PyEval_EvalCode(...)
> I compile the following code and execute them with PyEval_EvalCode
> (...)
>
>
> class MyClass(mod.Upper):
> pass
>
> register(MyClass) #just the type, not the instance
>
>
> Thats all. So register(...) is a Python C API method so i take the
> type and store
> it in a global variable.


....and increment its reference count, of course, because you store a new
reference, ok?

> PyEval_EvalCode(...) returns not NULL and I
> do not decref
> the dictionary, just the returnvalue.


Which dictionary? The return value should be None, I presume.
You should post the code. By far, the most frequent error using the Python
API is getting reference counts wrong.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
googler.1.webmaster@spamgourmet.com
Guest
Posts: n/a
 
      03-10-2009
http://rafb.net/p/Uyb5Ps45.html

Pelase note, when I call PyObject_CallObject(...) in the wrapped C
register(..) method it works fine.
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-11-2009
En Tue, 10 Mar 2009 13:23:44 -0200, <(E-Mail Removed)>
escribió:

> http://rafb.net/p/Uyb5Ps45.html
>
> Pelase note, when I call PyObject_CallObject(...) in the wrapped C
> register(..) method it works fine.


Sorry, I cannot make any sense of that code and your previous post. Where
is op assigned to? register? what's execute? PyObject_Call takes 3
arguments, not 2 - so that cannot be actual code.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments