Hi,

On Thu, Apr 29, 2010 at 03:22:51PM +0200, Roland Puntaier wrote:
[..]

The patch has
       :py3
for Python 3.x
and legacy
       :py[thon]
for Python 2.x.

Python 3.x is treated as another language.
Both Python 2.x and Python 3.x can be supported at the same time, if vim
is configured accordingly.

I gave this patch a quick testing and the only issue I found so far is a build error if both python2 & 3 are enabled and python3 is compiled with wide-unicode (UCS4) support.

I have attached a patch (on top of Roland's patch) for this situation.

Regards,
Andy
--
To be intoxicated is to feel sophisticated but not be able to say it.
# HG changeset patch
# Parent aea78996afc05dd7ec63dcd833637d4f26ba788a

diff --git a/src/if_python3.c b/src/if_python3.c
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -137,8 +137,10 @@
 # define PyType_GenericAlloc py3_PyType_GenericAlloc
 # define PyType_GenericNew py3_PyType_GenericNew
 # define PyModule_Create2 py3_PyModule_Create2
-# define PyUnicodeUCS2_FromString py3_PyUnicodeUCS2_FromString
-# define PyUnicodeUCS2_FromStringAndSize py3_PyUnicodeUCS2_FromStringAndSize
+#undef PyUnicode_FromString
+# define PyUnicode_FromString py3_PyUnicode_FromString
+#undef PyUnicode_FromStringAndSize
+# define PyUnicode_FromStringAndSize py3_PyUnicode_FromStringAndSize
 
 #ifdef Py_DEBUG
 #undef PyObject_NEW
@@ -176,8 +178,8 @@
 static PyObject* (*py3_Py_BuildValue)(char *, ...);
 static int (*py3_PyType_Ready)(PyTypeObject *type);
 static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject 
*item);
-static PyObject* (*py3_PyUnicodeUCS2_FromString)(const char *u);
-static PyObject* (*py3_PyUnicodeUCS2_FromStringAndSize)(const char *u, 
Py_ssize_t size);
+static PyObject* (*py3_PyUnicode_FromString)(const char *u);
+static PyObject* (*py3_PyUnicode_FromStringAndSize)(const char *u, Py_ssize_t 
size);
 static long (*py3_PyLong_AsLong)(PyObject *);
 static void (*py3_PyErr_SetNone)(PyObject *);
 static void (*py3_PyEval_InitThreads)(void);
@@ -279,8 +281,6 @@
     {"PyModule_Create2", (PYTHON_PROC*)&py3_PyModule_Create2},
     {"PyType_GenericAlloc", (PYTHON_PROC*)&py3_PyType_GenericAlloc},
     {"PyType_GenericNew", (PYTHON_PROC*)&py3_PyType_GenericNew},
-    {"PyUnicodeUCS2_FromString", (PYTHON_PROC*)&py3_PyUnicodeUCS2_FromString},
-    {"PyUnicodeUCS2_FromStringAndSize", 
(PYTHON_PROC*)&py3_PyUnicodeUCS2_FromStringAndSize},
     {"PySlice_Type", (PYTHON_PROC*)&py3_PySlice_Type},
 #ifdef Py_DEBUG
     {"_Py_NegativeRefcount", (PYTHON_PROC*)&py3__Py_NegativeRefcount},
@@ -339,6 +339,36 @@
             return FAIL;
         }
     }
+
+    /* load unicode functions separately as only the ucs2 or the ucs4 functions
+     * will be present in the library
+     */
+    void *ucs_from_string, *ucs_from_string_and_size;
+
+    ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
+    ucs_from_string_and_size = symbol_from_dll(hinstPy3,
+            "PyUnicodeUCS2_FromStringAndSize");
+    if (!ucs_from_string || !ucs_from_string_and_size)
+    {
+        ucs_from_string = symbol_from_dll(hinstPy3,
+                "PyUnicodeUCS4_FromString");
+        ucs_from_string_and_size = symbol_from_dll(hinstPy3,
+                "PyUnicodeUCS4_FromStringAndSize");
+    }
+    if (ucs_from_string && ucs_from_string_and_size)
+    {
+        py3_PyUnicode_FromString = ucs_from_string;
+        py3_PyUnicode_FromStringAndSize = ucs_from_string_and_size;
+    }
+    else
+    {
+        close_dll(hinstPy3);
+        hinstPy3 = 0;
+        if (verbose)
+            EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*");
+        return FAIL;
+    }
+
     return OK;
 }
 

Attachment: pgphFW7qkC78d.pgp
Description: PGP signature

Raspunde prin e-mail lui