On Sunday, September 9, 2012 12:15:15 AM UTC+4, Sean Estabrooks wrote:
> ----------------------------------------
> 
> >
> 
> > Finally I get it =) Since vim may load libpython dynamically, 
> > PY_SSIZE_T_CLEAN doesn't do its macro magic, namely it doesn't change 
> > PyArg_ParseTuple symbol name to _PyArg_ParseTuple_SizeT (as You can see in 
> > /usr/include/python*/modsupport.h).
> 
> >
> 
> > Now patch is a bit more complicated, please look attached 
> > py_sizet_syms.patch
> 
> 
> 
> Maxim,
> 
> 
> 
> You're on the right track obviously, but I don't really understand why the 
> patch you've given is required.  How does loading libpython dynamically 
> affect this sitation?  On line 45 of if_python.c we define PY_SSIZE_T_CLEAN 
> just before including Python.h which will then subsequently load modsupport.h 
> where the proper defines should happen.  Where does this fall down for you 
> when you're compiling?
> 
> 
> 
> Sean

Sean,

Because vim loads these symbols explicitly, like dlopen/dlsym. For example, 
lets trace how vim loads PyArg_ParseTuple:

if_python.c:143, substitute PyArg_ParseTuple for dll_PyArg_ParseTuple
# define PyArg_ParseTuple dll_PyArg_ParseTuple

if_python.c:243, define pointer to a function, each PyArg_ParseTuple call will 
be indirect through this pointer
static int(*dll_PyArg_ParseTuple)(PyObject *, char *, ...);

if_python.c:355, define array of pairs (symbol name, pointer to a function 
pointer) for dynamic loading. Look at a symbol name, "PyArg_ParseTuple", it is 
not affected by PY_SSIZE_T_CLEAN macro, this function always expects length as 
int, we need to call _PyArg_ParseTuple_SizeT to use Py_ssize_t
static struct
{
    char *name;
    PYTHON_PROC *ptr;
} python_funcname_table[] =
{
...
    {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},

if_python.c:507, load each symbol by its name and set corresponding dll_* 
function pointers
for (i = 0; python_funcname_table[i].ptr; ++i)
...

Regards,
Maxim

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui