On Jun 28, 2012, at 4:35 PM, ecir hana wrote:
>
> - How to build Python myself? "./configure" and "make" works but
> I'm afraid to do "make install" as it might mess with pre-installed Python,
> am I right? And it creates lots of .so, and no .a's.
Hi Ecir,
It's been a while since I compiled Python, but in the README supplied with the source code it talks about installation options. By default it installs in the /usr/local tree which should not interfere with your system Python.
> Even if I somehow
> manage to build Python and test.c what if it uses some libraries? Do I have
> to somehow compile and link them to the one big executable as well or is it
> just matter of packing the libraries along the binary and setting the
> Python find path?
Installing Python will put the runtime libraries on your system. If you want to run your program on a system where Python isn't installed, you need a 3rd party program like PyInstaller, Py2App, Py2Exe, bbfreeze, cx_freeze, etc.
Hope this helps
Philip
>
>
>
>
> On Thu, Jun 28, 2012 at 2:27 PM, Henrique <typoon(a)gmail.com> wrote:
>
>> Hey Ecir,
>>
>> By reading your email, I think you might want to first learn some basic
>> concepts about C programming and how a program can be linked to dynamic or
>> static libraries.
>> When Python is compiled in your machine, a dynamic or a static (or both)
>> library built, which you use to link with your program (your test.c). If
>> MacOS provides binaries for Python, I believe the libraries might alreayd
>> be there, and you might not need to compile it manually. (based on what you
>> are saying, you are only trying to compile it because you thought that is
>> how it should be done to have your test.c file to work). If you are still
>> interested in compiling it yourself, I believe there should be instructions
>> with the source (perhaps an INSTALL file there, explaining it). I am not
>> sure as I do not currently have the source here with me (but it should be
>> as simple as running ./configure && make && make install).
>> After you have Python compiled and running on your machine, you will write
>> source that will use the functions provided by the Python library in your
>> application, that is where your 'test.c' program comes into play.
>>
>> Some time ago I wrote some introduction blog posts about the Python C API.
>> If you are interested, this might help you a little bit
>> http://www.gilgalab.com.br/2011/05/03/python-c-api-first-step/
>> http://www.gilgalab.com.br/2011/05/03/python-c-api-second-step/
>>
>> But again, I really think you should look up some basics on C development
>> in a Unix platform :)
>>
>> Regards,
>>
>> Henrique
>>
>>
>> On Thu, Jun 28, 2012 at 6:08 AM, ecir hana <ecir.hana(a)gmail.com> wrote:
>>
>>> Hello,
>>>
>>> please, I have a bit of trouble grasping a few very basic concepts related
>>> to Python embedding, could someone explain those to me?
>>>
>>> What I try to achieve is to have single one (big) binary, which contains
>>> my
>>> Python script, the wrapper and Python interpreter itself, I'm on MacOS
>>> 10.6. My questions are:
>>>
>>> - I would like to build Python myself. I downloaded Python 3.3 beta source
>>> code, extracted it in a folder. Next to "Python-3.3.0b1" folder, there is
>>> a
>>> file "test.c" which contains:
>>>
>>> #include <Python.h>
>>>
>>> int
>>> main(int argc, char *argv[])
>>> {
>>> Py_Initialize();
>>> PyRun_SimpleString("from time import time,ctime\n"
>>> "print('Today is', ctime(time()))\n");
>>> Py_Finalize();
>>> return 0;
>>> }
>>>
>>> Now, what should I do next? I though I would just "somehow" compile and
>>> link Python source code with test.c and that's it but when I do "gcc -I
>>> ./Python-3.3.0b1 -o test test.c" I get lots of errors. (Note: I'm total
>>> noob what this whole gcc and static linking and .a files goes...)
>>>
>>> - Next I tried to run "./configure" and "make". It finished without errors
>>> and it creates "build/lib.macosx-10.6-x86_64-3.3" folder with lots of *.so
>>> (?) files but I'm not sure how to make use of them.
>>>
>>> If building everything from scratch (the first step above) is not an
>>> option, what do I need to build? A "framework"? .dylib? .a? And than link
>>> test.o against that?
>>>
>>> - How does Python from python.org get build? Do they use the same
>>> "./configure" and "make" as I can? Do they use any special option?
>>>
>>> To summarize, I have Python source code and test.c and I would like to
>>> have
>>> one executable which says "Today is ....". Could someone, please, explain
>>> in layman terms, the necessary steps?
>>>
>>> Thanks you very much in advance!
>>>
>>> Ecir Hana
>>> _______________________________________________
>>> capi-sig mailing list
>>> capi-sig(a)python.org
>>> http://mail.python.org/mailman/listinfo/capi-sig
>>>
>>
>>
> _______________________________________________
> capi-sig mailing list
> capi-sig(a)python.org
> http://mail.python.org/mailman/listinfo/capi-sig
Hello Henrique, Mateusz,
thank you both for the replies!
Yes, I would like to compile it myself (as opposite to using the libraries
already installed).
I don't really have a problem with Python C API, ref counting, creating
Python objects in C and such stuff. My problem is perhaps two fold:
- I don't know how is it called what I need to do in order to have one big
fat executable. Do I need a library which I can statically link agains? Is
this the "libpython.a" on some systems? From what I understood, if I want
to have just one binary I have to link "statically", correct? That is, I
have to have this ".a" file (what is it called on MacOS?) because .dll (on
Windows?) is used dynamically. So, either do I need ".a" (or
MacOS equivalent) or is it possible to somehow compile Python source
together with test.c in one go, avoiding the creation of Python library? Or
do I have to do it completely different of MacOS (frameworks et al.)?
- How to build Python myself? "./configure" and "make" works but
I'm afraid to do "make install" as it might mess with pre-installed Python,
am I right? And it creates lots of .so, and no .a's. Even if I somehow
manage to build Python and test.c what if it uses some libraries? Do I have
to somehow compile and link them to the one big executable as well or is it
just matter of packing the libraries along the binary and setting the
Python find path?
On Thu, Jun 28, 2012 at 2:27 PM, Henrique <typoon(a)gmail.com> wrote:
> Hey Ecir,
>
> By reading your email, I think you might want to first learn some basic
> concepts about C programming and how a program can be linked to dynamic or
> static libraries.
> When Python is compiled in your machine, a dynamic or a static (or both)
> library built, which you use to link with your program (your test.c). If
> MacOS provides binaries for Python, I believe the libraries might alreayd
> be there, and you might not need to compile it manually. (based on what you
> are saying, you are only trying to compile it because you thought that is
> how it should be done to have your test.c file to work). If you are still
> interested in compiling it yourself, I believe there should be instructions
> with the source (perhaps an INSTALL file there, explaining it). I am not
> sure as I do not currently have the source here with me (but it should be
> as simple as running ./configure && make && make install).
> After you have Python compiled and running on your machine, you will write
> source that will use the functions provided by the Python library in your
> application, that is where your 'test.c' program comes into play.
>
> Some time ago I wrote some introduction blog posts about the Python C API.
> If you are interested, this might help you a little bit
> http://www.gilgalab.com.br/2011/05/03/python-c-api-first-step/
> http://www.gilgalab.com.br/2011/05/03/python-c-api-second-step/
>
> But again, I really think you should look up some basics on C development
> in a Unix platform :)
>
> Regards,
>
> Henrique
>
>
> On Thu, Jun 28, 2012 at 6:08 AM, ecir hana <ecir.hana(a)gmail.com> wrote:
>
>> Hello,
>>
>> please, I have a bit of trouble grasping a few very basic concepts related
>> to Python embedding, could someone explain those to me?
>>
>> What I try to achieve is to have single one (big) binary, which contains
>> my
>> Python script, the wrapper and Python interpreter itself, I'm on MacOS
>> 10.6. My questions are:
>>
>> - I would like to build Python myself. I downloaded Python 3.3 beta source
>> code, extracted it in a folder. Next to "Python-3.3.0b1" folder, there is
>> a
>> file "test.c" which contains:
>>
>> #include <Python.h>
>>
>> int
>> main(int argc, char *argv[])
>> {
>> Py_Initialize();
>> PyRun_SimpleString("from time import time,ctime\n"
>> "print('Today is', ctime(time()))\n");
>> Py_Finalize();
>> return 0;
>> }
>>
>> Now, what should I do next? I though I would just "somehow" compile and
>> link Python source code with test.c and that's it but when I do "gcc -I
>> ./Python-3.3.0b1 -o test test.c" I get lots of errors. (Note: I'm total
>> noob what this whole gcc and static linking and .a files goes...)
>>
>> - Next I tried to run "./configure" and "make". It finished without errors
>> and it creates "build/lib.macosx-10.6-x86_64-3.3" folder with lots of *.so
>> (?) files but I'm not sure how to make use of them.
>>
>> If building everything from scratch (the first step above) is not an
>> option, what do I need to build? A "framework"? .dylib? .a? And than link
>> test.o against that?
>>
>> - How does Python from python.org get build? Do they use the same
>> "./configure" and "make" as I can? Do they use any special option?
>>
>> To summarize, I have Python source code and test.c and I would like to
>> have
>> one executable which says "Today is ....". Could someone, please, explain
>> in layman terms, the necessary steps?
>>
>> Thanks you very much in advance!
>>
>> Ecir Hana
>> _______________________________________________
>> capi-sig mailing list
>> capi-sig(a)python.org
>> http://mail.python.org/mailman/listinfo/capi-sig
>>
>
>
Hey Ecir,
By reading your email, I think you might want to first learn some basic
concepts about C programming and how a program can be linked to dynamic or
static libraries.
When Python is compiled in your machine, a dynamic or a static (or both)
library built, which you use to link with your program (your test.c). If
MacOS provides binaries for Python, I believe the libraries might alreayd
be there, and you might not need to compile it manually. (based on what you
are saying, you are only trying to compile it because you thought that is
how it should be done to have your test.c file to work). If you are still
interested in compiling it yourself, I believe there should be instructions
with the source (perhaps an INSTALL file there, explaining it). I am not
sure as I do not currently have the source here with me (but it should be
as simple as running ./configure && make && make install).
After you have Python compiled and running on your machine, you will write
source that will use the functions provided by the Python library in your
application, that is where your 'test.c' program comes into play.
Some time ago I wrote some introduction blog posts about the Python C API.
If you are interested, this might help you a little bit
http://www.gilgalab.com.br/2011/05/03/python-c-api-first-step/http://www.gilgalab.com.br/2011/05/03/python-c-api-second-step/
But again, I really think you should look up some basics on C development
in a Unix platform :)
Regards,
Henrique
On Thu, Jun 28, 2012 at 6:08 AM, ecir hana <ecir.hana(a)gmail.com> wrote:
> Hello,
>
> please, I have a bit of trouble grasping a few very basic concepts related
> to Python embedding, could someone explain those to me?
>
> What I try to achieve is to have single one (big) binary, which contains my
> Python script, the wrapper and Python interpreter itself, I'm on MacOS
> 10.6. My questions are:
>
> - I would like to build Python myself. I downloaded Python 3.3 beta source
> code, extracted it in a folder. Next to "Python-3.3.0b1" folder, there is a
> file "test.c" which contains:
>
> #include <Python.h>
>
> int
> main(int argc, char *argv[])
> {
> Py_Initialize();
> PyRun_SimpleString("from time import time,ctime\n"
> "print('Today is', ctime(time()))\n");
> Py_Finalize();
> return 0;
> }
>
> Now, what should I do next? I though I would just "somehow" compile and
> link Python source code with test.c and that's it but when I do "gcc -I
> ./Python-3.3.0b1 -o test test.c" I get lots of errors. (Note: I'm total
> noob what this whole gcc and static linking and .a files goes...)
>
> - Next I tried to run "./configure" and "make". It finished without errors
> and it creates "build/lib.macosx-10.6-x86_64-3.3" folder with lots of *.so
> (?) files but I'm not sure how to make use of them.
>
> If building everything from scratch (the first step above) is not an
> option, what do I need to build? A "framework"? .dylib? .a? And than link
> test.o against that?
>
> - How does Python from python.org get build? Do they use the same
> "./configure" and "make" as I can? Do they use any special option?
>
> To summarize, I have Python source code and test.c and I would like to have
> one executable which says "Today is ....". Could someone, please, explain
> in layman terms, the necessary steps?
>
> Thanks you very much in advance!
>
> Ecir Hana
> _______________________________________________
> capi-sig mailing list
> capi-sig(a)python.org
> http://mail.python.org/mailman/listinfo/capi-sig
>
Hello,
please, I have a bit of trouble grasping a few very basic concepts related
to Python embedding, could someone explain those to me?
What I try to achieve is to have single one (big) binary, which contains my
Python script, the wrapper and Python interpreter itself, I'm on MacOS
10.6. My questions are:
- I would like to build Python myself. I downloaded Python 3.3 beta source
code, extracted it in a folder. Next to "Python-3.3.0b1" folder, there is a
file "test.c" which contains:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print('Today is', ctime(time()))\n");
Py_Finalize();
return 0;
}
Now, what should I do next? I though I would just "somehow" compile and
link Python source code with test.c and that's it but when I do "gcc -I
./Python-3.3.0b1 -o test test.c" I get lots of errors. (Note: I'm total
noob what this whole gcc and static linking and .a files goes...)
- Next I tried to run "./configure" and "make". It finished without errors
and it creates "build/lib.macosx-10.6-x86_64-3.3" folder with lots of *.so
(?) files but I'm not sure how to make use of them.
If building everything from scratch (the first step above) is not an
option, what do I need to build? A "framework"? .dylib? .a? And than link
test.o against that?
- How does Python from python.org get build? Do they use the same
"./configure" and "make" as I can? Do they use any special option?
To summarize, I have Python source code and test.c and I would like to have
one executable which says "Today is ....". Could someone, please, explain
in layman terms, the necessary steps?
Thanks you very much in advance!
Ecir Hana
Hi,
I'm really having trouble understanding the python threading model.
It's clear to me from the docs,
http://docs.python.org/py3k/c-api/init.html?highlight=initthread
that I need to initialize python as so when requiring the use of
threads,
Py_Initialize();
PyEval_InitThreads();
Then, after that point, in each new thread, I should use
PyGILState_STATE state = PyGILState_Ensure();
// python code
PyGILState_Release(state);
A few questions arise which do not seem to be documented clearly.
It's not clear to me if a call to Ensure locks python into
executing only in that thread until Release is called, or if it's just
a registration function which then allows python to choose which
python code it would like to execute in which thread at which time.
Can anyone answer this?
Based on my confusion above, I'm wondering if I can
wrap the Ensure/Release calls around the entire new thread,
or should this be done around a small snippet of python code?
What are the trade offs?
Finally, I notice that after my call to PyEval_InitThreads() I
had to call
PyEval_SaveThread();
in order to allow other threads to call PyGILState_Ensure() with
out blocking forever. This is not documented. I'm not sure I'm
doing the correct thing here. Any ideas?
Thanks,
Bob
[changed the citation order to fix the top-post]
Ian Miers, 22.06.2012 04:37:
> On Thu, Jun 21, 2012 at 8:46 AM, Andrei Paraschivescu wrote:
>
>> Ian, do you have other Python interpreters running? I don't know if that
>> can cause the behavior you describe, but as some information is shared
>> across interpreters (e.g. you can unpickle a class you have not imported if
>> another interpreter has), it could potentially be relevant.
>>
>> I have not been able to find where the documentation describes what is
>> shared across interpreters, but perhaps someone who understands that issue
>> can chime in.
>
> I have python2.7, 3.2 and 3.2 debug installed. Python 2.7 was likely
> running as part of some deamons in ubuntu( at least they are running
> now) . Funnily, I have these environments all inside virtualenv ( which
> appears to just sym lin the system python(in this case 3.2) interpreter
> and I believe changes the paths for site packages and such) and yet the
> errors don't seem to propagate back to the system interpreter or across
> virtualenv environments.
I'm sure that's not what Andrei meant. He likely referred to starting up
multiple interpreters within the *same* process. Separate processes don't
interfere with each other. From your answer, I take it that you're not
using this feature (which is not commonly used anyway).
In any case, you might have more luck asking on the general Python mailing
list (aka. comp.lang.python). It has a lot more listeners (aka. eyeballs).
As a general remark: yes, it's very possible that a C extension crashes
Python. In almost all cases, it's due to a bug in the C extension, of which
the vast majority are reference counting bugs. That's why I keep
encouraging users to write their extensions in Cython instead of C, because
it makes these things just so much easier - most of it happens
automatically. And it's a lot more pleasant for Python programmers to write
Cython code than to step down into C all on your own.
Stefan
Hello,
Test runs of the project I work on have been seeing intermittent,
usually non reproducible, errors that strongly sugest we are
somehow corrupting parts of the python interpreter. I suspect rather
strongly that the issue is caused by an error in some c extension we
wrote. However, I am unsure if this is actually possible, and if it is ,
how to actually look for the error. Moreover, I'm not even sure what state
python keeps around between runs (i've seen some errors persist across
deleting pyc files, which on face, would make my hypothesis unlikely). Can
someone enlighten on any or all of this ?
Details follow:
Some of the errors we have seen:
> import os.path
E TypeError: __import__() argument 1 must be str without null bytes, not
str
Of course, there isn't a null there and the import works when run on its
own.
Another error :functions failing to load from c extensions that when
examined, the output of help(module) showing random non asci
characters around that function definition. In short, it looks like
something (the pyc file, some internal state, maybe the actual .so file
though it didn't look like it and that seems unlikely ) got corrupted.
Some code causing sigabort from obmalloc. ( the trace of which is bellow)
These errors happen even if we set PYTHONDONTWRITEBYTECODE.
More perplexingly, in the case of one I am dealing with now who's trace is
below , it appears to persist across removing all __pycache__ and pyc
iles from the project . Is there some other state the python interpreter
keeps across runs?
My best guess is we are writing to something we aren't supposed to in one
of the c extensions and messing things up from there. However, I'm not
really sure how to track this down. Valgrind, even on a python debug
build, seems to produce a lot of noise and its not clear what I should
actually look for in the output.
Bellow is the gdb trace for a test run using pytest against python3.2
inside virtualenv on ubuntu 11.04
Thanks,
Ian Miers
GDB trace :
#0 0x00007ffff67acd05 in raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff67b0ab6 in abort () at abort.c:92
#2 0x00000000004c1504 in Py_FatalError (msg=0x7ffffffcc820 "bad ID:
Allocated using API '")
at ../Python/pythonrun.c:2119
#3 0x0000000000421b0a in _PyObject_DebugCheckAddressApi (api=111 'o',
p=0x15d3980) at ../Objects/obmalloc.c:1591
#4 0x0000000000421839 in _PyObject_DebugReallocApi (api=111 'o',
p=0x15d3980, nbytes=28)
at ../Objects/obmalloc.c:1498
#5 0x0000000000421635 in _PyObject_DebugRealloc (p=0x15d3980, nbytes=28)
at ../Objects/obmalloc.c:1417
#6 0x000000000044620c in unicode_resize (unicode=0x15a4930, length=6) at
../Objects/unicodeobject.c:285
#7 0x00000000004463ad in _PyUnicode_New (length=6) at
../Objects/unicodeobject.c:339
#8 0x000000000044c269 in PyUnicodeUCS4_DecodeUTF8Stateful (
s=0x127bd88 "append\373\373\373\373\373\373\373", <incomplete sequence
\373>, size=6,
errors=0x64b6ae "surrogatepass", consumed=0x0) at
../Objects/unicodeobject.c:2531
#9 0x000000000044c20b in PyUnicodeUCS4_DecodeUTF8 (
s=0x127bd88 "append\373\373\373\373\373\373\373", <incomplete sequence
\373>, size=6,
errors=0x64b6ae "surrogatepass") at ../Objects/unicodeobject.c:2495
#10 0x00000000004b3e66 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:818
#11 0x00000000004b3f31 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:837
#12 0x00000000004b4876 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:968
#13 0x00000000004b3f31 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:837
#14 0x00000000004b4852 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:965
#15 0x00000000004b3f31 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:837
#16 0x00000000004b4852 in r_object (p=0x7ffffffcdae0) at
../Python/marshal.c:965
#17 0x00000000004b5204 in PyMarshal_ReadObjectFromString (str=0x16d3b30
"c", len=8715) at ../Python/marshal.c:1133
#18 0x00000000004b50e8 in PyMarshal_ReadLastObjectFromFile (fp=0x1668680)
at ../Python/marshal.c:1094
#19 0x00000000004a92d0 in read_compiled_module (
cpathname=0x7ffffffcdc80
"/home/ian/code/venv_valgrind/charm/charm/toolbox/__pycache__/secretutil.cpython-32.pyc",
fp=0x1668680) at ../Python/import.c:1058
#20 0x00000000004a9c8e in load_source_module (name=0x7ffffffcfe40
"charm.toolbox.secretutil",
pathname=0x7ffffffced50
"/home/ian/code/venv_valgrind/charm/charm/toolbox/secretutil.py",
fp=0x16c8c10)
at ../Python/import.c:1315
#21 0x00000000004ab7fa in load_module (name=0x7ffffffcfe40
"charm.toolbox.secretutil", fp=0x16c8c10,
pathname=0x7ffffffced50
"/home/ian/code/venv_valgrind/charm/charm/toolbox/secretutil.py", type=1,
loader=0x0)
---Type <return> to continue, or q <return> to quit---
at ../Python/import.c:2102
#22 0x00000000004adbfe in import_submodule (mod=0x168b3a8,
subname=0x7ffffffcfe4e "secretutil",
fullname=0x7ffffffcfe40 "charm.toolbox.secretutil") at
../Python/import.c:2894
#23 0x00000000004ad077 in load_next (mod=0x168b3a8, altmod=0x168b3a8,
p_name=0x7ffffffcfe08,
buf=0x7ffffffcfe40 "charm.toolbox.secretutil", p_buflen=0x7ffffffcfe18)
at ../Python/import.c:2706
#24 0x00000000004ac2f0 in import_module_level (name=0x0, globals=0x16c9760,
locals=0x16c9760, fromlist=0x15ccae0,
level=0) at ../Python/import.c:2430
#25 0x00000000004ac776 in PyImport_ImportModuleLevel (name=0x15c7a80
"charm.toolbox.secretutil",
globals=0x16c9760, locals=0x16c9760, fromlist=0x15ccae0, level=0) at
../Python/import.c:2474
#26 0x0000000000473d0c in builtin___import__ (self=0x7ffff7fc8f60,
args=0x16893c0, kwds=0x0)
at ../Python/bltinmodule.c:168
#27 0x000000000060ad2e in PyCFunction_Call (func=0x7ffff7fce0d8,
arg=0x16893c0, kw=0x0)
at ../Objects/methodobject.c:84
#28 0x00000000005b580f in PyObject_Call (func=0x7ffff7fce0d8,
arg=0x16893c0, kw=0x0) at ../Objects/abstract.c:2149
#29 0x000000000048d510 in PyEval_CallObjectWithKeywords
(func=0x7ffff7fce0d8, arg=0x16893c0, kw=0x0)
at ../Python/ceval.c:3755
#30 0x00000000004863b5 in PyEval_EvalFrameEx (f=0x1604560, throwflag=0) at
../Python/ceval.c:2332
#31 0x000000000048be4c in PyEval_EvalCodeEx (_co=0x169d998,
globals=0x16c9760, locals=0x16c9760, args=0x0,
argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#32 0x000000000047bf3a in PyEval_EvalCode (co=0x169d998, globals=0x16c9760,
locals=0x16c9760)
at ../Python/ceval.c:761
#33 0x00000000004a8cb7 in PyImport_ExecCodeModuleWithPathnames
(name=0x7ffffffd3ef0 "schemes.abenc.abenc_bsw07",
co=0x169d998,
pathname=0x7ffffffd1d30
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_bsw07.cpython-32.pyc",
cpathname=0x7ffffffd1d30
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_bsw07.cpython-32.pyc")
at ../Python/import.c:809
#34 0x00000000004a9df6 in load_source_module (name=0x7ffffffd3ef0
"schemes.abenc.abenc_bsw07",
pathname=0x7ffffffd1d30
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_bsw07.cpython-32.pyc",
fp=0x16c9de0) at ../Python/import.c:1339
#35 0x00000000004ab7fa in load_module (name=0x7ffffffd3ef0
"schemes.abenc.abenc_bsw07", fp=0x16c9de0,
pathname=0x7ffffffd2e00
"/home/ian/code/venv_valgrind/charm/schemes/abenc/abenc_bsw07.py", type=1,
loader=0x0)
at ../Python/import.c:2102
After this point i think its irrelevant.
#35 0x00000000004ab7fa in load_module (name=0x7ffffffd3ef0
"schemes.abenc.abenc_bsw07", fp=0x16c9de0,
pathname=0x7ffffffd2e00
"/home/ian/code/venv_valgrind/charm/schemes/abenc/abenc_bsw07.py", type=1,
loader=0x0)
at ../Python/import.c:2102
---Type <return> to continue, or q <return> to quit---
#36 0x00000000004adbfe in import_submodule (mod=0x15cfc18,
subname=0x7ffffffd3efe "abenc_bsw07",
fullname=0x7ffffffd3ef0 "schemes.abenc.abenc_bsw07") at
../Python/import.c:2894
#37 0x00000000004ad077 in load_next (mod=0x15cfc18, altmod=0x15cfc18,
p_name=0x7ffffffd3eb8,
buf=0x7ffffffd3ef0 "schemes.abenc.abenc_bsw07",
p_buflen=0x7ffffffd3ec8) at ../Python/import.c:2706
#38 0x00000000004ac2f0 in import_module_level (name=0x0, globals=0x166d0d0,
locals=0x166d0d0, fromlist=0x15cc220,
level=0) at ../Python/import.c:2430
#39 0x00000000004ac776 in PyImport_ImportModuleLevel (name=0x15cc5b0
"schemes.abenc.abenc_bsw07",
globals=0x166d0d0, locals=0x166d0d0, fromlist=0x15cc220, level=0) at
../Python/import.c:2474
#40 0x0000000000473d0c in builtin___import__ (self=0x7ffff7fc8f60,
args=0x1689060, kwds=0x0)
at ../Python/bltinmodule.c:168
#41 0x000000000060ad2e in PyCFunction_Call (func=0x7ffff7fce0d8,
arg=0x1689060, kw=0x0)
at ../Objects/methodobject.c:84
#42 0x00000000005b580f in PyObject_Call (func=0x7ffff7fce0d8,
arg=0x1689060, kw=0x0) at ../Objects/abstract.c:2149
#43 0x000000000048d510 in PyEval_CallObjectWithKeywords
(func=0x7ffff7fce0d8, arg=0x1689060, kw=0x0)
at ../Python/ceval.c:3755
#44 0x00000000004863b5 in PyEval_EvalFrameEx (f=0x1684fb0, throwflag=0) at
../Python/ceval.c:2332
#45 0x000000000048be4c in PyEval_EvalCodeEx (_co=0x16876b8,
globals=0x166d0d0, locals=0x166d0d0, args=0x0,
argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#46 0x000000000047bf3a in PyEval_EvalCode (co=0x16876b8, globals=0x166d0d0,
locals=0x166d0d0)
at ../Python/ceval.c:761
#47 0x00000000004a8cb7 in PyImport_ExecCodeModuleWithPathnames (
name=0x7ffffffd7fa0 "schemes.abenc.abenc_adapt_hybrid", co=0x16876b8,
pathname=0x7ffffffd5de0
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_adapt_hybrid.cpython-32.pyc",
cpathname=0x7ffffffd5de0
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_adapt_hybrid.cpython-32.pyc")
at ../Python/import.c:809
#48 0x00000000004a9df6 in load_source_module (name=0x7ffffffd7fa0
"schemes.abenc.abenc_adapt_hybrid",
pathname=0x7ffffffd5de0
"/home/ian/code/venv_valgrind/charm/schemes/abenc/__pycache__/abenc_adapt_hybrid.cpython-32.pyc",
fp=0x1674450) at ../Python/import.c:1339
#49 0x00000000004ab7fa in load_module (name=0x7ffffffd7fa0
"schemes.abenc.abenc_adapt_hybrid", fp=0x1674450,
pathname=0x7ffffffd6eb0
"/home/ian/code/venv_valgrind/charm/schemes/abenc/abenc_adapt_hybrid.py",
type=1,
loader=0x0) at ../Python/import.c:2102
#50 0x00000000004adbfe in import_submodule (mod=0x15cfc18,
subname=0x7ffffffd7fae "abenc_adapt_hybrid",
---Type <return> to continue, or q <return> to quit---
fullname=0x7ffffffd7fa0 "schemes.abenc.abenc_adapt_hybrid") at
../Python/import.c:2894
#51 0x00000000004ad077 in load_next (mod=0x15cfc18, altmod=0x15cfc18,
p_name=0x7ffffffd7f68,
buf=0x7ffffffd7fa0 "schemes.abenc.abenc_adapt_hybrid",
p_buflen=0x7ffffffd7f78) at ../Python/import.c:2706
#52 0x00000000004ac2f0 in import_module_level (name=0x0, globals=0x166f180,
locals=0x166f180, fromlist=0x1549ca0,
level=0) at ../Python/import.c:2430
#53 0x00000000004ac776 in PyImport_ImportModuleLevel (name=0x15cfac0
"schemes.abenc.abenc_adapt_hybrid",
globals=0x166f180, locals=0x166f180, fromlist=0x1549ca0, level=0) at
../Python/import.c:2474
#54 0x0000000000473d0c in builtin___import__ (self=0x7ffff7fc8f60,
args=0x14e3840, kwds=0x0)
at ../Python/bltinmodule.c:168
#55 0x000000000060ad2e in PyCFunction_Call (func=0x7ffff7fce0d8,
arg=0x14e3840, kw=0x0)
at ../Objects/methodobject.c:84
#56 0x00000000005b580f in PyObject_Call (func=0x7ffff7fce0d8,
arg=0x14e3840, kw=0x0) at ../Objects/abstract.c:2149
#57 0x000000000048d510 in PyEval_CallObjectWithKeywords
(func=0x7ffff7fce0d8, arg=0x14e3840, kw=0x0)
at ../Python/ceval.c:3755
#58 0x00000000004863b5 in PyEval_EvalFrameEx (f=0x1671cb0, throwflag=0) at
../Python/ceval.c:2332
#59 0x000000000048be4c in PyEval_EvalCodeEx (_co=0x1536d30,
globals=0x166f180, locals=0x166f180, args=0x0,
argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#60 0x000000000047bf3a in PyEval_EvalCode (co=0x1536d30, globals=0x166f180,
locals=0x166f180)
at ../Python/ceval.c:761
#61 0x000000000047529b in builtin_exec (self=0x7ffff7fc8f60,
args=0x15a6c90) at ../Python/bltinmodule.c:813
#62 0x000000000060ad10 in PyCFunction_Call (func=0x7ffff7fce6f0,
arg=0x15a6c90, kw=0x0)
at ../Objects/methodobject.c:81
#63 0x000000000048dd01 in call_function (pp_stack=0x7ffffffd9ef0, oparg=2)
at ../Python/ceval.c:3875
#64 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1671730, throwflag=0) at
../Python/ceval.c:2673
#65 0x000000000048be4c in PyEval_EvalCodeEx (_co=0x1419828,
globals=0x1469780, locals=0x0, args=0x154a5b0,
argcount=2, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#66 0x00000000005ec861 in function_call (func=0x14eec98, arg=0x154a588,
kw=0x0) at ../Objects/funcobject.c:629
#67 0x00000000005b580f in PyObject_Call (func=0x14eec98, arg=0x154a588,
kw=0x0) at ../Objects/abstract.c:2149
#68 0x00000000005d166a in method_call (func=0x14eec98, arg=0x154a588,
kw=0x0) at ../Objects/classobject.c:319
#69 0x00000000005b580f in PyObject_Call (func=0x159c9c0, arg=0x15a73e0,
kw=0x0) at ../Objects/abstract.c:2149
#70 0x00000000005b599c in call_function_tail (callable=0x159c9c0,
args=0x15a73e0) at ../Objects/abstract.c:2181
#71 0x00000000005b5dce in PyObject_CallMethod (o=0x14f1760, name=0x64a99a
"load_module", format=0x64a87e "s")
at ../Objects/abstract.c:2258
---Type <return> to continue, or q <return> to quit---
#72 0x00000000004ab8bf in load_module (name=0x7ffffffdbeb0
"schemes.test.abenc_test", fp=0x0,
pathname=0x7ffffffdadc0 "", type=9, loader=0x14f1760) at
../Python/import.c:2130
#73 0x00000000004adbfe in import_submodule (mod=0x15cf768,
subname=0x7ffffffdbebd "abenc_test",
fullname=0x7ffffffdbeb0 "schemes.test.abenc_test") at
../Python/import.c:2894
#74 0x00000000004ad077 in load_next (mod=0x15cf768, altmod=0x15cf768,
p_name=0x7ffffffdbe78,
buf=0x7ffffffdbeb0 "schemes.test.abenc_test", p_buflen=0x7ffffffdbe88)
at ../Python/import.c:2706
#75 0x00000000004ac2f0 in import_module_level (name=0x0, globals=0x0,
locals=0x0, fromlist=0x0, level=-1)
at ../Python/import.c:2430
#76 0x00000000004ac776 in PyImport_ImportModuleLevel (name=0x1529480
"schemes.test.abenc_test", globals=0x0,
locals=0x0, fromlist=0x0, level=-1) at ../Python/import.c:2474
#77 0x0000000000473d0c in builtin___import__ (self=0x7ffff7fc8f60,
args=0x15a0760, kwds=0x0)
at ../Python/bltinmodule.c:168
#78 0x000000000060ad2e in PyCFunction_Call (func=0x7ffff7fce0d8,
arg=0x15a0760, kw=0x0)
at ../Objects/methodobject.c:84
#79 0x000000000048dd01 in call_function (pp_stack=0x7ffffffdd0c0, oparg=1)
at ../Python/ceval.c:3875
#80 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166df40, throwflag=0) at
../Python/ceval.c:2673
#81 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xf60a50,
globals=0xecf240, locals=0x0, args=0x166de98,
argcount=1, kws=0x166dea0, kwcount=1, defs=0xf7f4c0, defcount=2,
kwdefs=0x0, closure=0x0)
at ../Python/ceval.c:3311
#82 0x000000000048e2f9 in fast_function (func=0xf81568,
pp_stack=0x7ffffffddda0, n=3, na=1, nk=1)
at ../Python/ceval.c:3973
#83 0x000000000048ded1 in call_function (pp_stack=0x7ffffffddda0,
oparg=256) at ../Python/ceval.c:3896
#84 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166dcf0, throwflag=0) at
../Python/ceval.c:2673
#85 0x000000000048e1d6 in fast_function (func=0x1027568,
pp_stack=0x7ffffffde910, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#86 0x000000000048ded1 in call_function (pp_stack=0x7ffffffde910, oparg=0)
at ../Python/ceval.c:3896
#87 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166da90, throwflag=0) at
../Python/ceval.c:2673
#88 0x000000000048e1d6 in fast_function (func=0xf82be0,
pp_stack=0x7ffffffdf480, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#89 0x000000000048ded1 in call_function (pp_stack=0x7ffffffdf480, oparg=2)
at ../Python/ceval.c:3896
#90 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166d890, throwflag=0) at
../Python/ceval.c:2673
#91 0x000000000048e1d6 in fast_function (func=0x10274b0,
pp_stack=0x7ffffffdfff0, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
---Type <return> to continue, or q <return> to quit---
#92 0x000000000048ded1 in call_function (pp_stack=0x7ffffffdfff0, oparg=0)
at ../Python/ceval.c:3896
#93 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166d650, throwflag=0) at
../Python/ceval.c:2673
#94 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xfc7b08,
globals=0xff8a10, locals=0x0, args=0x15242b8,
argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#95 0x00000000005ec861 in function_call (func=0x1026c98, arg=0x1524290,
kw=0x0) at ../Objects/funcobject.c:629
#96 0x00000000005b580f in PyObject_Call (func=0x1026c98, arg=0x1524290,
kw=0x0) at ../Objects/abstract.c:2149
#97 0x00000000005b6565 in PyObject_CallFunctionObjArgs (callable=0x1026c98)
at ../Objects/abstract.c:2372
#98 0x00000000005d8c93 in property_descr_get (self=0xfeada8, obj=0x153cf40,
type=0x1006600)
at ../Objects/descrobject.c:1199
#99 0x000000000041e05d in _PyObject_GenericGetAttrWithDict (obj=0x153cf40,
name=0x7ffff7e778c8, dict=0x0)
at ../Objects/object.c:986
#100 0x000000000041e4c6 in PyObject_GenericGetAttr (obj=0x153cf40,
name=0x7ffff7e778c8)
at ../Objects/object.c:1048
#101 0x000000000041d98b in PyObject_GetAttr (v=0x153cf40,
name=0x7ffff7e778c8) at ../Objects/object.c:833
#102 0x0000000000485cfe in PyEval_EvalFrameEx (f=0x166ce80, throwflag=0) at
../Python/ceval.c:2278
#103 0x000000000048e1d6 in fast_function (func=0x10271d0,
pp_stack=0x7ffffffe19f0, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#104 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe19f0, oparg=0)
at ../Python/ceval.c:3896
#105 0x0000000000488839 in PyEval_EvalFrameEx (f=0x156bbd0, throwflag=0) at
../Python/ceval.c:2673
#106 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xf076b8,
globals=0xe01830, locals=0x0, args=0x156bb30,
argcount=0, kws=0x156bb30, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x15247d0)
at ../Python/ceval.c:3311
#107 0x000000000048e2f9 in fast_function (func=0x14f6060,
pp_stack=0x7ffffffe26d0, n=0, na=0, nk=0)
at ../Python/ceval.c:3973
#108 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe26d0, oparg=0)
at ../Python/ceval.c:3896
#109 0x0000000000488839 in PyEval_EvalFrameEx (f=0x156b970, throwflag=0) at
../Python/ceval.c:2673
#110 0x000000000048e1d6 in fast_function (func=0xf82be0,
pp_stack=0x7ffffffe3240, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#111 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe3240, oparg=2)
at ../Python/ceval.c:3896
#112 0x0000000000488839 in PyEval_EvalFrameEx (f=0x156b760, throwflag=0) at
../Python/ceval.c:2673
#113 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xf07770,
globals=0xe01830, locals=0x0, args=0x156b680,
argcount=1, kws=0x156b688, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#114 0x000000000048e2f9 in fast_function (func=0xf83288,
pp_stack=0x7ffffffe3f20, n=1, na=1, nk=0)
---Type <return> to continue, or q <return> to quit---
at ../Python/ceval.c:3973
#115 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe3f20, oparg=0)
at ../Python/ceval.c:3896
#116 0x0000000000488839 in PyEval_EvalFrameEx (f=0x156b4e0, throwflag=0) at
../Python/ceval.c:2673
#117 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xfb9b08,
globals=0xf47e40, locals=0x0, args=0x14fb908,
argcount=3, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#118 0x00000000005ec861 in function_call (func=0xfcdbe0, arg=0x14fb8e0,
kw=0x0) at ../Objects/funcobject.c:629
#119 0x00000000005b580f in PyObject_Call (func=0xfcdbe0, arg=0x14fb8e0,
kw=0x0) at ../Objects/abstract.c:2149
#120 0x00000000005d166a in method_call (func=0xfcdbe0, arg=0x14fb8e0,
kw=0x0) at ../Objects/classobject.c:319
#121 0x00000000005b580f in PyObject_Call (func=0x159c420, arg=0x15183a8,
kw=0x0) at ../Objects/abstract.c:2149
#122 0x0000000000444231 in slot_tp_init (self=0x15248b0, args=0x15183a8,
kwds=0x0) at ../Objects/typeobject.c:5278
#123 0x0000000000433f91 in type_call (type=0xff5db0, args=0x15183a8,
kwds=0x0) at ../Objects/typeobject.c:691
#124 0x00000000005b580f in PyObject_Call (func=0xff5db0, arg=0x15183a8,
kw=0x0) at ../Objects/abstract.c:2149
#125 0x000000000048eb38 in do_call (func=0xff5db0, pp_stack=0x7ffffffe4de0,
na=2, nk=0) at ../Python/ceval.c:4095
#126 0x000000000048deed in call_function (pp_stack=0x7ffffffe4de0, oparg=2)
at ../Python/ceval.c:3898
#127 0x0000000000488839 in PyEval_EvalFrameEx (f=0x156b290, throwflag=0) at
../Python/ceval.c:2673
#128 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xfc0a50,
globals=0xf47e40, locals=0x0, args=0x7ffff7f96088,
argcount=0, kws=0x154a808, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#129 0x00000000005ec861 in function_call (func=0xfd0288,
arg=0x7ffff7f96060, kw=0x1473960)
at ../Objects/funcobject.c:629
#130 0x00000000005b580f in PyObject_Call (func=0xfd0288,
arg=0x7ffff7f96060, kw=0x1473960)
at ../Objects/abstract.c:2149
#131 0x000000000048f1ab in ext_do_call (func=0xfd0288,
pp_stack=0x7ffffffe5af0, flags=2, na=0, nk=0)
at ../Python/ceval.c:4190
#132 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x166cc70, throwflag=0) at
../Python/ceval.c:2714
#133 0x000000000048e1d6 in fast_function (func=0xdb7a70,
pp_stack=0x7ffffffe6660, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#134 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe6660, oparg=0)
at ../Python/ceval.c:3896
#135 0x0000000000488839 in PyEval_EvalFrameEx (f=0x105e7a0, throwflag=0) at
../Python/ceval.c:2673
#136 0x000000000048be4c in PyEval_EvalCodeEx (_co=0x10fa600,
globals=0x111b430, locals=0x0, args=0x151f6a8,
argcount=1, kws=0x15096e8, kwcount=2, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#137 0x00000000005ec861 in function_call (func=0x1100f78, arg=0x151f680,
kw=0x1565d60)
at ../Objects/funcobject.c:629
#138 0x00000000005b580f in PyObject_Call (func=0x1100f78, arg=0x151f680,
kw=0x1565d60)
---Type <return> to continue, or q <return> to quit---
at ../Objects/abstract.c:2149
#139 0x000000000048f1ab in ext_do_call (func=0x1100f78,
pp_stack=0x7ffffffe7370, flags=2, na=1, nk=0)
at ../Python/ceval.c:4190
#140 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x166ca60, throwflag=0) at
../Python/ceval.c:2714
#141 0x000000000048e1d6 in fast_function (func=0xdb7a70,
pp_stack=0x7ffffffe7ee0, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#142 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe7ee0, oparg=0)
at ../Python/ceval.c:3896
#143 0x0000000000488839 in PyEval_EvalFrameEx (f=0x105e200, throwflag=0) at
../Python/ceval.c:2673
#144 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xfd9bc0,
globals=0xfac190, locals=0x0, args=0x7ffff7f96088,
argcount=0, kws=0x14f4cc0, kwcount=2, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#145 0x00000000005ec861 in function_call (func=0x102d4b0,
arg=0x7ffff7f96060, kw=0x1566eb0)
at ../Objects/funcobject.c:629
#146 0x00000000005b580f in PyObject_Call (func=0x102d4b0,
arg=0x7ffff7f96060, kw=0x1566eb0)
at ../Objects/abstract.c:2149
#147 0x000000000048f1ab in ext_do_call (func=0x102d4b0,
pp_stack=0x7ffffffe8bf0, flags=2, na=0, nk=0)
at ../Python/ceval.c:4190
#148 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x162a360, throwflag=0) at
../Python/ceval.c:2714
#149 0x000000000048e1d6 in fast_function (func=0xdb7a70,
pp_stack=0x7ffffffe9760, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#150 0x000000000048ded1 in call_function (pp_stack=0x7ffffffe9760, oparg=0)
at ../Python/ceval.c:3896
#151 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1615390, throwflag=0) at
../Python/ceval.c:2673
#152 0x000000000048e1d6 in fast_function (func=0xdb8118,
pp_stack=0x7ffffffea2d0, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#153 0x000000000048ded1 in call_function (pp_stack=0x7ffffffea2d0, oparg=2)
at ../Python/ceval.c:3896
#154 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1596aa0, throwflag=0) at
../Python/ceval.c:2673
#155 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xc99b08,
globals=0xaf8b80, locals=0x0, args=0x1418358,
argcount=2, kws=0x1500f88, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#156 0x00000000005ec861 in function_call (func=0xdb8060, arg=0x1418330,
kw=0x14ae360)
at ../Objects/funcobject.c:629
#157 0x00000000005b580f in PyObject_Call (func=0xdb8060, arg=0x1418330,
kw=0x14ae360)
at ../Objects/abstract.c:2149
#158 0x000000000048f1ab in ext_do_call (func=0xdb8060,
pp_stack=0x7ffffffeafe0, flags=2, na=2, nk=0)
at ../Python/ceval.c:4190
---Type <return> to continue, or q <return> to quit---
#159 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x161e660, throwflag=0) at
../Python/ceval.c:2714
#160 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xf01320,
globals=0xe01830, locals=0x0, args=0x166c618,
argcount=0, kws=0x166c618, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x1518330)
at ../Python/ceval.c:3311
#161 0x000000000048e2f9 in fast_function (func=0x14f64b0,
pp_stack=0x7ffffffebcc0, n=2, na=0, nk=1)
at ../Python/ceval.c:3973
#162 0x000000000048ded1 in call_function (pp_stack=0x7ffffffebcc0,
oparg=256) at ../Python/ceval.c:3896
#163 0x0000000000488839 in PyEval_EvalFrameEx (f=0x166c460, throwflag=0) at
../Python/ceval.c:2673
#164 0x00000000005e0d36 in gen_send_ex (gen=0x1520760, arg=0x0, exc=0) at
../Objects/genobject.c:82
#165 0x00000000005e1660 in gen_iternext (gen=0x1520760) at
../Objects/genobject.c:279
#166 0x00000000005eff93 in listextend (self=0x142e2b8, b=0x1520760) at
../Objects/listobject.c:831
#167 0x000000000048dadb in call_function (pp_stack=0x7ffffffec860, oparg=1)
at ../Python/ceval.c:3863
#168 0x0000000000488839 in PyEval_EvalFrameEx (f=0x15654f0, throwflag=0) at
../Python/ceval.c:2673
#169 0x000000000048e1d6 in fast_function (func=0xf83be0,
pp_stack=0x7ffffffed3d0, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#170 0x000000000048ded1 in call_function (pp_stack=0x7ffffffed3d0, oparg=2)
at ../Python/ceval.c:3896
#171 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1565280, throwflag=0) at
../Python/ceval.c:2673
#172 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xf103d8,
globals=0xe01830, locals=0x0, args=0x1565220,
argcount=1, kws=0x1565228, kwcount=0, defs=0xf7f628, defcount=2,
kwdefs=0x0, closure=0x0)
at ../Python/ceval.c:3311
#173 0x000000000048e2f9 in fast_function (func=0xf83b28,
pp_stack=0x7ffffffee0b0, n=1, na=1, nk=0)
at ../Python/ceval.c:3973
#174 0x000000000048ded1 in call_function (pp_stack=0x7ffffffee0b0, oparg=0)
at ../Python/ceval.c:3896
#175 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1565090, throwflag=0) at
../Python/ceval.c:2673
#176 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xefaea0,
globals=0xe01830, locals=0x0, args=0x7ffff7f96088,
argcount=0, kws=0x1518f10, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#177 0x00000000005ec861 in function_call (func=0xf17e08,
arg=0x7ffff7f96060, kw=0x14b6aa0)
at ../Objects/funcobject.c:629
#178 0x00000000005b580f in PyObject_Call (func=0xf17e08,
arg=0x7ffff7f96060, kw=0x14b6aa0)
at ../Objects/abstract.c:2149
#179 0x000000000048f1ab in ext_do_call (func=0xf17e08,
pp_stack=0x7ffffffeedc0, flags=2, na=0, nk=0)
at ../Python/ceval.c:4190
#180 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x15642c0, throwflag=0) at
../Python/ceval.c:2714
---Type <return> to continue, or q <return> to quit---
#181 0x000000000048e1d6 in fast_function (func=0xdb7a70,
pp_stack=0x7ffffffef930, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#182 0x000000000048ded1 in call_function (pp_stack=0x7ffffffef930, oparg=0)
at ../Python/ceval.c:3896
#183 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1564060, throwflag=0) at
../Python/ceval.c:2673
#184 0x000000000048e1d6 in fast_function (func=0xdb8118,
pp_stack=0x7fffffff04a0, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#185 0x000000000048ded1 in call_function (pp_stack=0x7fffffff04a0, oparg=2)
at ../Python/ceval.c:3896
#186 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1563e50, throwflag=0) at
../Python/ceval.c:2673
#187 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xc99a50,
globals=0xaf8b80, locals=0x0, args=0x142f6a8,
argcount=1, kws=0x1224880, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#188 0x00000000005ec861 in function_call (func=0xdb7f78, arg=0x142f680,
kw=0x1473c00)
at ../Objects/funcobject.c:629
#189 0x00000000005b580f in PyObject_Call (func=0xdb7f78, arg=0x142f680,
kw=0x1473c00)
at ../Objects/abstract.c:2149
#190 0x00000000005d166a in method_call (func=0xdb7f78, arg=0x142f680,
kw=0x1473c00)
at ../Objects/classobject.c:319
#191 0x00000000005b580f in PyObject_Call (func=0x14181c8,
arg=0x7ffff7f96060, kw=0x1473c00)
at ../Objects/abstract.c:2149
#192 0x00000000004436e8 in slot_tp_call (self=0xdbaa70,
args=0x7ffff7f96060, kwds=0x1473c00)
at ../Objects/typeobject.c:5040
#193 0x00000000005b580f in PyObject_Call (func=0xdbaa70,
arg=0x7ffff7f96060, kw=0x1473c00)
at ../Objects/abstract.c:2149
#194 0x000000000048eb38 in do_call (func=0xdbaa70, pp_stack=0x7fffffff1320,
na=0, nk=1) at ../Python/ceval.c:4095
#195 0x000000000048deed in call_function (pp_stack=0x7fffffff1320,
oparg=256) at ../Python/ceval.c:3898
#196 0x0000000000488839 in PyEval_EvalFrameEx (f=0x14ca620, throwflag=0) at
../Python/ceval.c:2673
#197 0x000000000048e1d6 in fast_function (func=0xf179b8,
pp_stack=0x7fffffff1e90, n=2, na=2, nk=0)
at ../Python/ceval.c:3963
#198 0x000000000048ded1 in call_function (pp_stack=0x7fffffff1e90, oparg=2)
at ../Python/ceval.c:3896
#199 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1492290, throwflag=0) at
../Python/ceval.c:2673
#200 0x000000000048e1d6 in fast_function (func=0xf17288,
pp_stack=0x7fffffff2a00, n=2, na=2, nk=0)
at ../Python/ceval.c:3963
#201 0x000000000048ded1 in call_function (pp_stack=0x7fffffff2a00, oparg=2)
at ../Python/ceval.c:3896
#202 0x0000000000488839 in PyEval_EvalFrameEx (f=0x14714c0, throwflag=0) at
../Python/ceval.c:2673
---Type <return> to continue, or q <return> to quit---
#203 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xef6de8,
globals=0xe01830, locals=0x0, args=0x7ffff7f96088,
argcount=0, kws=0x1224bc8, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#204 0x00000000005ec861 in function_call (func=0xf17790,
arg=0x7ffff7f96060, kw=0x148f570)
at ../Objects/funcobject.c:629
#205 0x00000000005b580f in PyObject_Call (func=0xf17790,
arg=0x7ffff7f96060, kw=0x148f570)
at ../Objects/abstract.c:2149
#206 0x000000000048f1ab in ext_do_call (func=0xf17790,
pp_stack=0x7fffffff3710, flags=2, na=0, nk=0)
at ../Python/ceval.c:4190
#207 0x0000000000488c75 in PyEval_EvalFrameEx (f=0x1475b50, throwflag=0) at
../Python/ceval.c:2714
#208 0x000000000048e1d6 in fast_function (func=0xdb7a70,
pp_stack=0x7fffffff4280, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#209 0x000000000048ded1 in call_function (pp_stack=0x7fffffff4280, oparg=0)
at ../Python/ceval.c:3896
#210 0x0000000000488839 in PyEval_EvalFrameEx (f=0x125d580, throwflag=0) at
../Python/ceval.c:2673
#211 0x000000000048e1d6 in fast_function (func=0xdb8118,
pp_stack=0x7fffffff4df0, n=3, na=3, nk=0)
at ../Python/ceval.c:3963
#212 0x000000000048ded1 in call_function (pp_stack=0x7fffffff4df0, oparg=2)
at ../Python/ceval.c:3896
#213 0x0000000000488839 in PyEval_EvalFrameEx (f=0x125d370, throwflag=0) at
../Python/ceval.c:2673
#214 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xc99a50,
globals=0xaf8b80, locals=0x0, args=0x7ffff7e4a408,
argcount=1, kws=0x121d880, kwcount=1, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#215 0x00000000005ec861 in function_call (func=0xdb7f78,
arg=0x7ffff7e4a3e0, kw=0xd4b020)
at ../Objects/funcobject.c:629
#216 0x00000000005b580f in PyObject_Call (func=0xdb7f78,
arg=0x7ffff7e4a3e0, kw=0xd4b020)
at ../Objects/abstract.c:2149
#217 0x00000000005d166a in method_call (func=0xdb7f78, arg=0x7ffff7e4a3e0,
kw=0xd4b020)
at ../Objects/classobject.c:319
#218 0x00000000005b580f in PyObject_Call (func=0xc00c18,
arg=0x7ffff7f96060, kw=0xd4b020)
at ../Objects/abstract.c:2149
#219 0x00000000004436e8 in slot_tp_call (self=0xdbafb0,
args=0x7ffff7f96060, kwds=0xd4b020)
at ../Objects/typeobject.c:5040
#220 0x00000000005b580f in PyObject_Call (func=0xdbafb0,
arg=0x7ffff7f96060, kw=0xd4b020)
at ../Objects/abstract.c:2149
#221 0x000000000048eb38 in do_call (func=0xdbafb0, pp_stack=0x7fffffff5c70,
na=0, nk=1) at ../Python/ceval.c:4095
#222 0x000000000048deed in call_function (pp_stack=0x7fffffff5c70,
oparg=256) at ../Python/ceval.c:3898
---Type <return> to continue, or q <return> to quit---
#223 0x0000000000488839 in PyEval_EvalFrameEx (f=0x1241a60, throwflag=0) at
../Python/ceval.c:2673
#224 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xc99ea0,
globals=0xaf8b80, locals=0x0, args=0xc63bf0,
argcount=0, kws=0xc63bf0, kwcount=0, defs=0xd26bc8, defcount=2,
kwdefs=0x0, closure=0x0)
at ../Python/ceval.c:3311
#225 0x000000000048e2f9 in fast_function (func=0xdb8288,
pp_stack=0x7fffffff6950, n=0, na=0, nk=0)
at ../Python/ceval.c:3973
#226 0x000000000048ded1 in call_function (pp_stack=0x7fffffff6950, oparg=0)
at ../Python/ceval.c:3896
#227 0x0000000000488839 in PyEval_EvalFrameEx (f=0xc63a60, throwflag=0) at
../Python/ceval.c:2673
#228 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xb2fd30,
globals=0xaf16a0, locals=0xaf16a0, args=0x0,
argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#229 0x000000000047bf3a in PyEval_EvalCode (co=0xb2fd30, globals=0xaf16a0,
locals=0xaf16a0)
at ../Python/ceval.c:761
#230 0x00000000004a8cb7 in PyImport_ExecCodeModuleWithPathnames
(name=0x7fffffff97f0 "test", co=0xb2fd30,
pathname=0x7fffffff8700 "test.py", cpathname=0x7fffffff7630
"__pycache__/test.cpython-32.pyc")
at ../Python/import.c:809
#231 0x00000000004a9df6 in load_source_module (name=0x7fffffff97f0 "test",
pathname=0x7fffffff8700 "test.py",
fp=0xc8a8e0) at ../Python/import.c:1339
#232 0x00000000004ab7fa in load_module (name=0x7fffffff97f0 "test",
fp=0xc8a8e0,
pathname=0x7fffffff8700 "test.py", type=1, loader=0x0) at
../Python/import.c:2102
#233 0x00000000004adbfe in import_submodule (mod=0x8b9180,
subname=0x7fffffff97f0 "test",
fullname=0x7fffffff97f0 "test") at ../Python/import.c:2894
#234 0x00000000004ad077 in load_next (mod=0x8b9180, altmod=0x8b9180,
p_name=0x7fffffff97b8,
buf=0x7fffffff97f0 "test", p_buflen=0x7fffffff97c8) at
../Python/import.c:2706
#235 0x00000000004ac268 in import_module_level (name=0x0, globals=0x0,
locals=0x0, fromlist=0x0, level=-1)
at ../Python/import.c:2422
#236 0x00000000004ac776 in PyImport_ImportModuleLevel (name=0x7ffff7f086f8
"test", globals=0x0, locals=0x0,
fromlist=0x0, level=-1) at ../Python/import.c:2474
#237 0x0000000000473d0c in builtin___import__ (self=0x7ffff7fc8f60,
args=0x7ffff7f6c4c0, kwds=0x0)
at ../Python/bltinmodule.c:168
#238 0x000000000060ad2e in PyCFunction_Call (func=0x7ffff7fce0d8,
arg=0x7ffff7f6c4c0, kw=0x0)
at ../Objects/methodobject.c:84
#239 0x000000000048dd01 in call_function (pp_stack=0x7fffffffaa00, oparg=1)
at ../Python/ceval.c:3875
#240 0x0000000000488839 in PyEval_EvalFrameEx (f=0xc8a6f0, throwflag=0) at
../Python/ceval.c:2673
---Type <return> to continue, or q <return> to quit---
#241 0x00000000005e0d36 in gen_send_ex (gen=0x7ffff60b40e0, arg=0x0, exc=0)
at ../Objects/genobject.c:82
#242 0x00000000005e1660 in gen_iternext (gen=0x7ffff60b40e0) at
../Objects/genobject.c:279
#243 0x0000000000487b3f in PyEval_EvalFrameEx (f=0xb06530, throwflag=0) at
../Python/ceval.c:2496
#244 0x000000000048e1d6 in fast_function (func=0xc2b9b8,
pp_stack=0x7fffffffc010, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#245 0x000000000048ded1 in call_function (pp_stack=0x7fffffffc010, oparg=1)
at ../Python/ceval.c:3896
#246 0x0000000000488839 in PyEval_EvalFrameEx (f=0xc880a0, throwflag=0) at
../Python/ceval.c:2673
#247 0x000000000048e1d6 in fast_function (func=0xc2b900,
pp_stack=0x7fffffffcb80, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#248 0x000000000048ded1 in call_function (pp_stack=0x7fffffffcb80, oparg=1)
at ../Python/ceval.c:3896
#249 0x0000000000488839 in PyEval_EvalFrameEx (f=0xaf88e0, throwflag=0) at
../Python/ceval.c:2673
#250 0x000000000048e1d6 in fast_function (func=0xc2c060,
pp_stack=0x7fffffffd6f0, n=1, na=1, nk=0)
at ../Python/ceval.c:3963
#251 0x000000000048ded1 in call_function (pp_stack=0x7fffffffd6f0, oparg=1)
at ../Python/ceval.c:3896
#252 0x0000000000488839 in PyEval_EvalFrameEx (f=0xaf1cd0, throwflag=0) at
../Python/ceval.c:2673
#253 0x000000000048be4c in PyEval_EvalCodeEx (_co=0xc0c770,
globals=0xc5f410, locals=0x0, args=0xc1e970,
argcount=2, kws=0x0, kwcount=0, defs=0xc221d8, defcount=1, kwdefs=0x0,
closure=0x0) at ../Python/ceval.c:3311
#254 0x00000000005ec861 in function_call (func=0xc2c118, arg=0xc1e948,
kw=0x0) at ../Objects/funcobject.c:629
#255 0x00000000005b580f in PyObject_Call (func=0xc2c118, arg=0xc1e948,
kw=0x0) at ../Objects/abstract.c:2149
#256 0x00000000004d9204 in RunModule (modname=0x7ffff7f95040 L"test.py",
set_argv0=1) at ../Modules/main.c:189
#257 0x00000000004da307 in Py_Main (argc=3, argv=0x7ffff7f92040) at
../Modules/main.c:636
#258 0x000000000041bd77 in main (argc=3, argv=0x7fffffffe608) at
../Modules/python.c:59
Hi,
I'm reading PEP-253 on Subtyping Built-in Types [1] which by the way has been
extremely helpful to understand details of handling types using Python C API.
In the "Creating a subtype of a built-in type in C" section, the document
includes the following note on the two slots arguments:
"Both tp_new() and tp_init() should receive exactly the same 'args'
and 'kwds' arguments, and both should check that the arguments are
acceptable, because they may be called independently."
I can understand what it says, but I'm unsure about how to interpret it.
Let's consider a simple case of custom type definition,
without subclassing involved.
Does this note recommend to simply repeat the whole args and kwds
parsing and checking in both, tp_new and tp_init?
Like this Noddy example from the Python 3 documentation [2]:
static PyTypeObject noddy_NoddyType = { ... };
int Noddy_init(Noddy* self, PyObject* args, PyObject* kwds);
{
PyObject *first=NULL, *last=NULL, *tmp;
static char *kwlist[] = {"first", "last", "number", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
&first, &last,
&self->number))
return -1;
/* check args, initialise Noddy members, etc. */
}
Now as per the PEP-253 "both should check that the arguments are acceptable",
so tp_new gets the very same arguments parsing/checking copied & pasted:
PyObject* Noddy_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
PyObject *first=NULL, *last=NULL, *tmp;
static char *kwlist[] = {"first", "last", "number", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
&first, &last,
&self->number))
return -1;
/* Now, what to do with the args?
Ignore?
DO or DO NOT repeat the tp_init work of Noddy members initialization?
*/
Noddy *self;
self = (Noddy *)type->tp_alloc(type, 0);
if (self != NULL) {
self->first = PyUnicode_FromString("");
if (self->first == NULL)
{
Py_DECREF(self);
return NULL;
}
self->last = PyUnicode_FromString("");
if (self->last == NULL)
{
Py_DECREF(self);
return NULL;
}
self->number = 0;
}
return (PyObject *)self;
}
Repeating the question from the comment above,
what tp_new is supposed to do with the arguments?
The Noddy example from the manual simply ignores args and kwds,
it does not even perform the checks recommended by the PEP-253.
What the Noddy_new should look like to conform with the PEP-253
recommendations?
The PEP-253 also includes this recommendation related to my question:
"This should first call the base type's tp_new() slot and
then initialize the subtype's additional data members. To further
initialize the instance, the tp_init() slot is typically called.
Note that the tp_new() slot should *not* call the tp_init() slot;"
In the context of the Noddy example, the "initialize the subtype's additional
data members" means zero-initialisation with empty strings. Makes sense.
Then "To further initialize the instance", tp_init is called of course,
so calling tp_init from tp_new is not advised, this is clear.
So, AFAIU, the PEP-253 suggests to make tp_new check the args and kwds,
report (early) any unacceptable arguments, but not necessarily to
use the values to initialise the instance, as that is tp_init's job.
Does it sound right?
BTW, I understand role of tp_new and tp_init for initialising object would
be different depending if noddy_NoddyType is considered as immutable
object type or not.
But, let's simplify and say noddy_NoddyType is a typical Python object type.
[1] http://www.python.org/dev/peps/pep-0253/
[2] http://docs.python.org/py3k/extending/newtypes.html
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net