From ideasman42 at gmail.com Wed Apr 1 02:22:13 2009 From: ideasman42 at gmail.com (Campbell Barton) Date: Tue, 31 Mar 2009 17:22:13 -0700 Subject: [capi-sig] Python console in a C application Message-ID: <7c1ab96d0903311722v2c2efd2cqb7dad5b9f59ddedf@mail.gmail.com> Hi there, for blender3d were going to have a built in python console, The console in Blender 2.4x I wrote a while ago and had no clue about the "code" module, or code.interact(), and apparently re-implemented parts of idle :| Ofcourse all the blender specific stuff is our problem, (events, text drawing etc), We can worry about that. Does anyone know of an example of a C application that has a python console? Some basic requirements are... * it runs inside blender (not using the terminal) * It doesn't lock blender IIRC the Gimp has a python console but it uses pygtk for this. -- - Campbell From trigves at yahoo.com Mon Apr 6 17:58:33 2009 From: trigves at yahoo.com (Trigve Siver) Date: Mon, 6 Apr 2009 08:58:33 -0700 (PDT) Subject: [capi-sig] PyFunction_New examples Message-ID: <114153.85374.qm@web110413.mail.gq1.yahoo.com> Hi, I'm trying to use PyFunction_New() function but I've problem finding out how it works. What I'm trying to do is to create python function on the fly and then trying to create function object from if via PyFunction_New. My problems are similar to this: http://article.gmane.org/gmane.comp.python.general/548300/match=pyfunction_new Please CC me. thanks Trigve From ideasman42 at gmail.com Tue Apr 7 04:20:48 2009 From: ideasman42 at gmail.com (Campbell Barton) Date: Mon, 6 Apr 2009 19:20:48 -0700 Subject: [capi-sig] PyFunction_New examples In-Reply-To: <114153.85374.qm@web110413.mail.gq1.yahoo.com> References: <114153.85374.qm@web110413.mail.gq1.yahoo.com> Message-ID: <7c1ab96d0904061920u3cda1007i1be7763260582e66@mail.gmail.com> Hi there, I never used PyFunction_New() If you can make the code object on the fly this should be no problem. I have only used PyCFunction_New(), you can set "self" to be any PyObject you like (or a tuple of them) Then your C function will get self as an argument, which can be different for every instance of your PyCFunction and decide what to do based on that. The main problem with PyCFunction_New is that your tied to predefined C functions. Another option is to define your own callable PyType. Sorry I didn't really answer your question but maybe this helps still. On Mon, Apr 6, 2009 at 8:58 AM, Trigve Siver wrote: > > Hi, > I'm trying to use PyFunction_New() function but I've problem finding out how it > works. What I'm trying to do is to create python function on the fly and then > trying to create function object from if via PyFunction_New. > > My problems are similar to this: > > http://article.gmane.org/gmane.comp.python.general/548300/match=pyfunction_new > > Please CC me. > > thanks > > Trigve > > > > _______________________________________________ > capi-sig mailing list > capi-sig at python.org > http://mail.python.org/mailman/listinfo/capi-sig > -- - Campbell From daniel at stutzbachenterprises.com Wed Apr 15 22:54:52 2009 From: daniel at stutzbachenterprises.com (Daniel Stutzbach) Date: Wed, 15 Apr 2009 15:54:52 -0500 Subject: [capi-sig] C API equivalent to abc.ABCMeta.register? Message-ID: I'm the author of an extension module (blist) that provides a type that fits the MutableSequence API. Is there a canonical way for me to register the type as a MutableSequence from the C API? -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC From jardent at ilm.com Thu Apr 30 21:30:50 2009 From: jardent at ilm.com (Joe Ardent) Date: Thu, 30 Apr 2009 12:30:50 -0700 Subject: [capi-sig] An unexpected visit_decref assertion violation (code works with 2.4, not with 2.5) Message-ID: <49F9FC6A.1040803@ilm.com> Hello, I have a Python module here that takes a bunch of C++ classes, and turns them into Python classes. When built against and loaded into Python 2.4, everything is fine. But when built against and loaded into Python 2.5, I get an assert violation from Python's gc module. Here is the code that is failing: klass = PyClass_New(bases, classDict, className); if (klass && methods) { /* add methods to class */ for (def = methods; def->ml_name != NULL; def++) { printf( "IlmPyClass: %d, def = %s\n", __LINE__, def->ml_name); PyObject *func = IlmPyClass_NewFunction(def); if (!func) { Py_XDECREF(klass); return NULL; } printf( "We get here\n" ); func = PyMethod_New(func, NULL, klass); //this line fails printf( "We don't get here\n" ); # ....... } } The output of 'python2.5 -c "import mymod"' is: """ [.... snip a bunch of "we get here, we don't get here" etc. as things fail to fail...] IlmPyClass: 197, def = __init__ We get here python2: Modules/gcmodule.c:276: visit_decref: Assertion `gc->gc.gc_refs != 0' failed. Abort """ The obvious things, such as Py_INCREFing klass or func, do not work. What's extra strange, in addition to this code working fine in an earlier python version, is that this code works fine for most of the classes that are instantiated. What I really want to do, though, is see what exactly is being decref'd. Does anyone have any tips for doing this? I've already tried using a debug build of Python; it doesn't seem to provide that type of ref tracing. Thanks in advance for any tips or insights. -- Joe Ardent