[Pyrex] Implicit conversions failing

David McNab david at rebirthing.co.nz
Mon May 19 03:15:59 CEST 2003


On Mon, 2003-05-19 at 03:20, Jani Hakala wrote:
> Do you have something like
> 
> cdef extern from "foo.h":
>     long cFunc(long foo)
> 
> in your pyrex-file?

That was the first thing I checked, so the answer is yes.

> It would be easier to determine what is your problem if you posted a
> (minimal) complete pyrex-file.

I doubt that I could cut down my project to a minimal file that reliably
reproduces the problem.

After hacking the EvilWM window manager (ref earlier post) with python
hooks - worked fine - I'm in the middle of applying similar hacks to the
superior FLWM (flwm.sf.net) window manager.

With this, I've seen some strange phenomena. When the FLWM engine fires
up and detects the existing windows, the Pyrex code works fine. But when
I create new windows, various Pyrex functions fail with the implicit
conversions I described in the previous post. It appears that exceptions
may be getting raised and not caught.

Note that the FLWM engine is written in C++. So to take events from it,
and to pass actions to it, I've written a shim of functions in the form:

   extern "C" sometype somefunc(sometype arg1, sometype arg2)

I consider the C++ interfacing to be sane, because only pointers and
ints are getting passed back and forth.

So the call stack is something like:

* regular python method
  -> regular python method
   -> pyrex function
    -> C++ shim function for action
     -> FLWM engine
      -> FLWM Event loop
       -> FLWM event handler callback
        -> C++ shim function for FLWM event
         -> Pyrex function - event dispatcher
          -> regular python method - event handler
           -> regular python method - action
            -> pyrex function - action
             -> C++ shim function - action
              -> FLWM C++ method - action
and possibly, also:
               -> FLWM event handler callback
                -> C++ shim function for FLWM event
                 -> Pyrex function - event dispatcher
                  -> regular python method - event handler
                   -> regular python method - action
                    -> pyrex function - action
                     -> C++ shim function - action
                      -> FLWM C++ method - action

So, it's possible that there's some re-entrancy happening.

I'd be very happy to send a tarball of the complete thing. But I hope
you can understand that it's not too easy to boil down to a minimal
case.

But there's good news - now that I'm explicitly doing teh conversions to
and from with PyLong_(As|From)Long(), everything is working perfectly.

Cheers
David
                      

> Jani Hakala
> 
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
-- 
Kind regards
David

--

leave this line intact so your email gets through my junk mail filter






More information about the Pyrex mailing list