[Pyrex] [newbie] 3 errors need help

Test Drive testdrive6 at gmail.com
Tue Dec 20 09:54:06 CET 2005


Hi All,

I am using Pyrex version 0.9.3.

for the following pyrex code

====================================================
ctypedef unsigned int size_t
cdef extern from "def.h":
   ctypedef enum RESULT:
      SUCCESS
      FAILURE
   ctypedef enum bool_t:
      FALSE
      TRUE
cdef extern from "client.h":
   ctypedef struct RSA:
      pass
   ctypedef struct xmlrpc_server_info:
      pass
   ctypedef struct xmlrpc_env:
      pass
   ctypedef struct ServerCTX:
      RSA                    *rsaPublicPtr
      xmlrpc_server_info     *ServerInfoPtr
      xmlrpc_env              ClientEnv
      int calloced
   ctypedef struct  SessionCTX:
      ServerCTX *ServerPtr
      unsigned char *keyEnc
      size_t keyEncLen

   RESULT Connect(SessionCTX **Sessionctx, char *serverHost, unsigned short
serverPort,unsigned char *key, size_t keylen)

cdef class MyClass:
   cdef SessionCTX  *___Session___
   def __init__(self,server="127.0.0.1",port=8080,key="abcdefgh0123456789"):
      self.Server=server
      self.Port=port
      self.Key=key
      self.Keylen=len(self.Key)
      self.res=None
   def connect(self):
      self.res=Connect(&self.__Session__,self.Server,self.Port,<unsigned
char *>self.Key,self.Keylen)
      return self.res
==========================================================================================
and ypically while calling Connect ie
self.res=Connect(&self.__Session__,self.Server,self.Port,<unsigned char *>
self.Key,self.Keylen)
i get the following errors/warnings from pyrex
test.pyx:37:23: Cannot take address of Python variable
test.pyx:37:63: Casting temporary Python object to non-Python type
test.pyx:37:45: Obtaining char * from temporary Python value


I have download and searched through the previous mailing list archievs,
however i did not found a post pertaining to same issue, there is one in Jan
2004, which is quite diff.


Here i would like to highlight one thing. the library for which i am writing
the wrapper initializes and uses SessionCTX * automatically, so basically
when i call Connect() SesstionCTX * is initialized.

secondly, the c code is generated and compiles with warning, however when i
import the module in Python and create an instance of MyClass, it raises
AttributeError Exception saying object has no attribute 'Server'.

Can anybody pls point to what i am doing wrong here?

TIA
TD6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20051220/034b44a2/attachment-0001.html


More information about the Pyrex mailing list