Recently I wanted to deprecate some functions in our the C api, and
found that warnings give weired output when running through through
our C api.
A simple test is to do this...
print range(1.5)
When I run this from python I get good output..
test.py:1: DeprecationWarning: integer argument expected, got float
print range(1.5)
But when running from our C api I get
/home/ideasman42/blender-svn/blender/blender.bin:1:
DeprecationWarning: integer argument expected, got float
ELF�p40�"4()&44�4�44�4�����F��F��F�K �K ğ<@G�K �K xxHH�H�
P�td�2?��C ��C L,L,Q�td/lib/ld-linux.so.2GNU����8�1LQ
�U�N�.yH {��d
I thought this was todo with running a compiled string so I tried
PyRun_String() on the text buffer instead of PyEval_EvalCode() but the
same problem.
Id be interested to know if anyones embedded python gives proper warnings.
On Linux testing with python 2.6 here.
--
- Campbell
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
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 <http://stutzbachenterprises.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=pyfunctio...
Please CC me.
thanks
Trigve
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