PyEval_EvalCode(...) problem

  • Thread starter googler.1.webmaster
  • Start date
G

googler.1.webmaster

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.
 
G

Gabriel Genellina

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.
 
G

Gabriel Genellina

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top