Embedding: How to set globals for PyObject_Call
Scott Gilbert
xscottgjunk at yahoo.com
Thu Feb 21 20:26:51 EST 2002
Michael Hudson <mwh at python.net> wrote:
> xscottgjunk at yahoo.com (Scott Gilbert) writes:
>
> > // This one breaks
> > Var g = VarEval("globals");
> > g(); // This causes a segfault
>
> Do we get to see the backtrace?
>
- For "globals", it segfaults in builtin_globals(...) where it tries
to Py_INCREF the null result from PyEval_GetGlobals(). The dbx stack
trace is below if you really want it. :-)
- For "locals", it segfaults when trying to Py_INCREF the null return
result from PyEval_GetLocals(). Similar stack trace as below, but
this is on line 1104 of bltinmodule.c
- For "vars", it sets up a Python error of "no locals!?" on line 1992
of bltinmodule.c
- Finally for "dir", PyObject_Dir [object.c, 2085] is called from
builtin_dir [bltinmodule.c, 1992] and returns a null, but doesn't
setup the Python error, so up the call stack PyObject_Call sets up a
system error of "NULL result without error in PyObject_Call"
[abstract.c, 2034].
Many other functions work without a hitch. (For instance, "list" is a
builtin that can take no args, and I correctly get a new list object
when I do my equivalent of apply() on that.)
Well, I hope this is sufficient info if you view this as enough of a
problem to fix it. Thanks for your interest.
0 builtin_globals(self = (nil)) ["Python/bltinmodule.c":665,
0x3ffbffa6814]
1 PyCFunction_Call(func = 0x140006d70, arg = 0x140003398, kw =
0x1400fb2d8) ["Objects/methodobject.c":83, 0x3ffbff61320]
2 PyObject_Call(func = 0x140006d70, arg = 0x140003398, kw =
0x1400fb2d8) ["Objects/abstract.c":1665, 0x3ffbff5bb6c]
// Below here are my wrappers around the standard Python stuff.
3 pv_call(x = 0x140006d70, args = 0x1400e7d98, kwds = 0x1400fb2d8,
err = 0x11fffec20) ["xpyvar.c":572, 0x3ffbff13a5c]
4 VarApply__X3Var(__result_pointer = 0x11fffeca0, x = @140006d70)
["./xpyvar.h~alt~deccxx_945E6458":1433, 0x120001fd8]
5 __cl__3VarXv(__result_pointer = 0x11fffeca0, this = 0x11fffec98)
["./xpyvar.h~alt~deccxx_945E6458":868, 0x120001e20]
6 main() ["main.cc":5, 0x120002204]
More information about the Python-list
mailing list