On Saturday, September 8, 2012 5:42:45 AM UTC+4, Sean Estabrooks wrote:
> ----------------------------------------
> 
> > Ok. Should I create a new theme in order to submit a patch?
> 
> >
> 
> > I think, I got to the bottom of this problem, "et#" format for 
> > PyArg_ParseTuple expects third parameter to be an int * that is a pointer 
> > to a 4 byte variable, but on Linux x86_64 sizeof(Py_ssize_t) == 8, so after 
> > parsing parameters we got half-initialized half-garbled len. On platforms 
> > where sizeof(Py_ssize_t) == sizeof(int) this bug is unreproducible =)
> 
> 
> 
> Hi Maxim,
> 
> 
> 
> Oh!  Is there any chance you're using a version of python prior to 2.5?
> 
> 
> 
> If i'm correct then instead of Py_ssize_t len = 0,  you should replace that 
> line with PyInt len;
> 
> 
> 
> This will be defined correctly near the top of if_python.c and work in both 
> cases.  In any case, my original patch should have been done that way.  Ugh.
> 
> 
> 
> Thanks,
> 
> Sean.
> 
> 
> 
> 
> 
> >
> 
> > Patch is fairly simple
> 
> >
> 
> > *** /tmp/extdiff.PnMpCM/vim.1052677493be/src/if_py_both.h 2012-09-08 
> > 01:36:57.452192738 +0400
> 
> > --- /home/maxim/Projects/vim/src/if_py_both.h 2012-09-08 01:35:34.074187900 
> > +0400
> 
> > ***************
> 
> > *** 74,80 ****
> 
> > static PyObject *
> 
> > OutputWrite(PyObject *self, PyObject *args)
> 
> > {
> 
> > ! Py_ssize_t len;
> 
> > char *str = NULL;
> 
> > int error = ((OutputObject *)(self))->error;
> 
> >
> 
> > --- 74,80 ----
> 
> > static PyObject *
> 
> > OutputWrite(PyObject *self, PyObject *args)
> 
> > {
> 
> > ! Py_ssize_t len = 0;
> 
> > char *str = NULL;
> 
> > int error = ((OutputObject *)(self))->error;
> 
> >

Hi Sean.

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 

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
diff -r 1052677493be src/if_python.c
--- a/src/if_python.c	Wed Sep 05 19:17:42 2012 +0200
+++ b/src/if_python.c	Sat Sep 08 17:23:50 2012 +0400
@@ -358,8 +358,15 @@
     PYTHON_PROC *ptr;
 } python_funcname_table[] =
 {
+#ifndef PY_SSIZE_T_CLEAN
     {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse},
     {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
+    {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
+#else
+    {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse},
+    {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
+    {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue},
+#endif
     {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free},
     {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
     {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
@@ -422,7 +429,6 @@
     {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
     {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
     {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
-    {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
     {"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
 # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 \
 	&& SIZEOF_SIZE_T != SIZEOF_INT
diff -r 1052677493be src/if_python3.c
--- a/src/if_python3.c	Wed Sep 05 19:17:42 2012 +0200
+++ b/src/if_python3.c	Sat Sep 08 17:23:50 2012 +0400
@@ -328,7 +328,13 @@
     {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv},
     {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome},
     {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
+#ifndef PY_SSIZE_T_CLEAN
     {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
+    {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue},
+#else
+    {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
+    {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&py3_Py_BuildValue},
+#endif
     {"PyMem_Free", (PYTHON_PROC*)&py3_PyMem_Free},
     {"PyMem_Malloc", (PYTHON_PROC*)&py3_PyMem_Malloc},
     {"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
@@ -364,7 +370,6 @@
     {"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter},
     {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong},
     {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New},
-    {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue},
     {"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready},
     {"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString},
     {"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong},

Raspunde prin e-mail lui