PyEval_EvalCode(...) problem

Discussion in 'Python' started by googler.1.webmaster@spamgourmet.com, Mar 10, 2009.

  1. Guest

    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.
    , Mar 10, 2009
    #1
    1. Advertising

  2. En Tue, 10 Mar 2009 12:32:00 -0200, <>
    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
    Gabriel Genellina, Mar 10, 2009
    #2
    1. Advertising

  3. Guest

    , Mar 10, 2009
    #3
  4. En Tue, 10 Mar 2009 13:23:44 -0200, <>
    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
    Gabriel Genellina, Mar 11, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,952
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,140
    Ted Miller
    Sep 13, 2003
  3. Daniel Trstenjak

    'locals' argument of PyEval_EvalCode

    Daniel Trstenjak, Nov 28, 2006, in forum: Python
    Replies:
    0
    Views:
    325
    Daniel Trstenjak
    Nov 28, 2006
  4. Replies:
    9
    Views:
    696
    Gabriel Genellina
    Nov 14, 2007
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    534
    Bullschmidt
    May 11, 2004
Loading...

Share This Page