From jerome.fuselier at free.fr Thu Jul 2 15:30:34 2009 From: jerome.fuselier at free.fr (=?ISO-8859-1?Q?J=E9r=F4me_Fuselier?=) Date: Thu, 02 Jul 2009 14:30:34 +0100 Subject: [capi-sig] Problem with uuid package when embedding a python interpreter Message-ID: <4A4CB67A.2040800@free.fr> Hello, I've sent this message to the c.l.python newsgroup and someone pointed me to this mailing-list to find a solution. (http://groups.google.com/group/comp.lang.python/browse_thread/thread/346d6ebd79c2e284#) I've tried to import a script in an embedded python intrepreter but this script fails when it imports the uuid module. I have a segmentation fault in Py_Finalize(). Here is a simple program which imitate my problem. main.c : #include "Python.h" void test() { Py_Initialize(); PyImport_Import(PyString_FromString("uuid")); Py_Finalize(); } main(int argc, char **argv) { for (i=0 ; i < 10; i++) test(); } For my application, I have to call Py_initialize and Py_Finalize several times so factorizing them in the main function is not an easy solution for me. The core which is produced gives me this error : Program terminated with signal 11, Segmentation fault. #0 0x00190ef6 in type_dealloc (type=0x291320) at Objects/typeobject.c: 2609 2609 _PyObject_GC_UNTRACK(type); Thanks for your help Jerome From philip at semanchuk.com Fri Jul 3 00:16:40 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 2 Jul 2009 18:16:40 -0400 Subject: [capi-sig] Problem with uuid package when embedding a python interpreter In-Reply-To: <4A4CB67A.2040800@free.fr> References: <4A4CB67A.2040800@free.fr> Message-ID: <7BEBE75E-B3F7-49DA-AA16-DC2B6D3D8072@semanchuk.com> On Jul 2, 2009, at 9:30 AM, J?r?me Fuselier wrote: > Hello, > I've sent this message to the c.l.python newsgroup and someone > pointed me to this mailing-list to find a solution. (http://groups.google.com/group/comp.lang.python/browse_thread/thread/346d6ebd79c2e284# > ) > > I've tried to import a script in an embedded python intrepreter but > this script fails when it imports the uuid module. I have a > segmentation fault in Py_Finalize(). Hi J?r?me, Just a debugging idea -- does the same problem happen if you import something other that the uuid module? bye Philip > > Here is a simple program which imitate my problem. > > main.c : > > #include "Python.h" > > void test() { > Py_Initialize(); > PyImport_Import(PyString_FromString("uuid")); > Py_Finalize(); > > } > > main(int argc, char **argv) > { > for (i=0 ; i < 10; i++) > test(); > } > > For my application, I have to call Py_initialize and Py_Finalize > several times so factorizing them in the main function is not an easy > solution for me. > > The core which is produced gives me this error : > Program terminated with signal 11, Segmentation fault. > #0 0x00190ef6 in type_dealloc (type=0x291320) at Objects/ > typeobject.c: > 2609 > 2609 _PyObject_GC_UNTRACK(type); > > > Thanks for your help > Jerome > _______________________________________________ > capi-sig mailing list > capi-sig at python.org > http://mail.python.org/mailman/listinfo/capi-sig From gjcarneiro at gmail.com Sun Jul 12 18:55:50 2009 From: gjcarneiro at gmail.com (Gustavo Carneiro) Date: Sun, 12 Jul 2009 17:55:50 +0100 Subject: [capi-sig] Announce: PyBindGen 0.11 released Message-ID: To integrate some recent contributions, here's a new PyBindGen 0.11 release. About: PyBindGen is a Python bindings generator written in Python. Download: http://code.google.com/p/pybindgen/ Summary of changes: - Generate code that supports GCC's -fvisibility=hidden - Add rudimentary support for std::map containers - Some inplace numeric operators now supported (J. Michael Owen) - Partial sequence protocol support: __len__, __getitem__, and __setitem__ (J. Michael Owen) - Partially support pointer-to-container parameters - Call traceback.extract_stack() less often (faster on win32) - No need for GIL locking in attribute setters (thanks Stuart Stock) - Allow wrapping enum given list of (name, value) pairs - New foreign_cpp_namespace option, for wrapping classes outside our module's C++ namespace - Add a docstring parameter to CppMethod constructor (Robin Gilks) Also add a docstring parameter for CppClass - Better support for typedefs - Implement support for enum reference parameters - Add support for size_t "by-value" type -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert From lanyjie at yahoo.com Tue Jul 21 06:19:10 2009 From: lanyjie at yahoo.com (Yingjie Lan) Date: Mon, 20 Jul 2009 21:19:10 -0700 (PDT) Subject: [capi-sig] expy: an expressway to extend Python Message-ID: <290588.53242.qm@web54205.mail.re2.yahoo.com> Hi All, This is to announce the initial release of expy 0.1.0. More details at http://expy.sourceforge.net/ Thanks! Yingjie From lanyjie at yahoo.com Tue Jul 21 20:22:19 2009 From: lanyjie at yahoo.com (Yingjie Lan) Date: Tue, 21 Jul 2009 11:22:19 -0700 (PDT) Subject: [capi-sig] [Python-Dev] expy: an expressway to extend Python Message-ID: <765806.59082.qm@web54202.mail.re2.yahoo.com> Hi, Here is a brief example on how to use expy to implement the math module: (for more details, see http://expy.sf.net/) """Python math module by expy-cxpy.""" from expy import * expymodule(__name__) #includes, defines, etc. @prologue def myprolog(): return """ #include """ @function(double) #return type: double def sqrt(x=double): #argument x: double """sqrt(x) --> the square root of x.""" return "sqrt(x)" #as an expression #a more terse way @function(double) def sin(x=double): """sin(x) --> the sin of x.""" pass #the deduced call: sin(x) #more functions ... expymodule(__name__) #end of module From philip at semanchuk.com Wed Jul 22 16:11:58 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 22 Jul 2009 10:11:58 -0400 Subject: [capi-sig] expy: an expressway to extend Python In-Reply-To: <290588.53242.qm@web54205.mail.re2.yahoo.com> References: <290588.53242.qm@web54205.mail.re2.yahoo.com> Message-ID: On Jul 21, 2009, at 12:19 AM, Yingjie Lan wrote: > > Hi All, > > This is to announce the initial release of expy 0.1.0. > > More details at http://expy.sourceforge.net/ Hi Yingjie, Well done; this looks interesting. There is a lot of repetition involved in building a Python extension and anything that reduces that is worth a look. BTW there's a typo here: http://expy.sourceforge.net/extypes.html#defining-a-new-extension-type "imetohd to decalre" should be "imethod to declare". You're typing too fast. =) Thanks for sharing your work Philip From lanyjie at yahoo.com Wed Jul 22 20:43:36 2009 From: lanyjie at yahoo.com (Yingjie Lan) Date: Wed, 22 Jul 2009 11:43:36 -0700 (PDT) Subject: [capi-sig] expy: an expressway to extend Python Message-ID: <350460.30480.qm@web54206.mail.re2.yahoo.com> --- On Wed, 7/22/09, Philip Semanchuk wrote: > From: Philip Semanchuk > Subject: Re: [capi-sig] expy: an expressway to extend Python > To: capi-sig at python.org > Date: Wednesday, July 22, 2009, 6:11 PM > > On Jul 21, 2009, at 12:19 AM, Yingjie Lan wrote: > > > > > Hi All, > > > > This is to announce the initial release of expy > 0.1.0. > > > > More details at http://expy.sourceforge.net/ > > Hi Yingjie, > Well done; this looks interesting. There is a lot of > repetition involved in building a Python extension and > anything that reduces that is worth a look. > Hi Philip: thanks for the encouraging words, and I also felt the same pain and this is why I wanted to get this done. Hope more people feeling the same pain would also like this project. > BTW there's a typo here: > http://expy.sourceforge.net/extypes.html#defining-a-new-extension-type > > "imetohd to decalre" should be "imethod to declare". You're > typing too fast. =) Thanks, just way too fast, two typos in a row, hoho. Just corrected, might need a reload to see. Regards, Yingjie From shaun.savage at hp.com Wed Jul 22 19:26:56 2009 From: shaun.savage at hp.com (Shaun Savage) Date: Wed, 22 Jul 2009 10:26:56 -0700 Subject: [capi-sig] create a new subclass data type in C Message-ID: <1248283616.4459.61.camel@ssavage> Hi I can create a new object in C. Now I am trying to create a class and sub classes in C. I plan to use PyType_GenericNew() to create the base class. PyTypeObject myClass_Type = { ... }; myClassObj = PyTYpe_GenericNew(myClass, ...); How do I create something like class myNewClass(myClass): in C? From savages at mozapps.org Mon Jul 27 21:58:31 2009 From: savages at mozapps.org (Shaun Savage) Date: Mon, 27 Jul 2009 12:58:31 -0700 Subject: [capi-sig] Create new object Message-ID: <4A6E06E7.70005@mozapps.org> I am trying to create a new python object of type Foo from a C program. typedef struct ( PyObject_HEAD PyObject ...., ... } Foo; static PyTypeObject FooType = { PyObject_HEAD_INIT(NULL) 0, "foo.Foo", sizeof(Foo), 0, ... } in the code i have self = (Foo*) PyObject_CallObject((PyObject*)&FooType, NULL); if (self == NULL) It segFaults when a change the args to Py_None it returns NULL I have tried to create empty tuple args nothing works Any Ideas? shaun From hniksic at xemacs.org Mon Jul 27 23:05:36 2009 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 27 Jul 2009 23:05:36 +0200 Subject: [capi-sig] Create new object In-Reply-To: <4A6E06E7.70005@mozapps.org> (Shaun Savage's message of "Mon, 27 Jul 2009 12:58:31 -0700") References: <4A6E06E7.70005@mozapps.org> Message-ID: <877hxtg7kv.fsf@busola.homelinux.net> Shaun Savage writes: > I am trying to create a new python object of type Foo from a C program. > > typedef struct ( > PyObject_HEAD > PyObject ...., > ... > } Foo; > > static PyTypeObject FooType = { > PyObject_HEAD_INIT(NULL) > 0, > "foo.Foo", > sizeof(Foo), > 0, > ... > } > > in the code i have > > self = (Foo*) PyObject_CallObject((PyObject*)&FooType, NULL); You need to use PyObject_CallFunctionObjArgs, like this: self = (Foo *)PyObject_CallFunctionObjArgs((PyObject*)&FooType, NULL); PyObject_CallObject is when you already have an argument tuple at the ready. From ulf.worsoe at mosek.com Thu Jul 30 21:40:47 2009 From: ulf.worsoe at mosek.com (Ulf Worsoe) Date: Thu, 30 Jul 2009 21:40:47 +0200 Subject: [capi-sig] ctypes on Windows/AMD64 Message-ID: Hi, I currently developing a cross-platform interface using python ctypes, and it looks like all relevant platforms are supported except 64bit Windows. I haven't been able to find any (recent) information on why ctypes is not included in the .MSI and .ZIP archives for win64 from Python.org... Does anybody know why this is the case, and possibly if there's any plans for supporting it? Regards, Ulf Wors?e Mosek ApS