On Friday, June 29, 2012 12:13:34 PM UTC-4, 依云 wrote:
> On Fri, Jun 29, 2012 at 08:01:29AM -0700, Raymond Ko wrote:
> > Hello all,
> > 
> > I am trying to build the newest version of VIM on Windows with MinGW 4.7.1 
> > and Python 2.7.3 and Python 3.23 bindings. Everything was compiling fined 
> > before, but as of this patch (probably) it no longer compiles because the 
> > following linker error:
> > 
> > C:\Users\root\AppData\Local\Temp\ccClQZVw.ltrans16.ltrans.o:ccClQZVw.ltrans16.o:(.text+0x6aab):
> >  undefined reference to `_imp__PyUnicodeUCS2_AsEncodedString'
> > 
> > Is this because UCS4 string stuff was introduced (and assumed to be 
> > default) in this patch in if_python3.c?
> > Official Windows distribution of latest Python 3 Py_UNICODE_SIZE in 
> > include/pyconfig.h to be "2".
> > I'm guessing this could be the issue?
> 
> No, it's in if_python.c. if_python3.c handles these PyUnicodeUCSX_*
> functions well. The attached patch will handle the same for that
> function in if_python.c, please try it out.
> 
> -- 
> Best regards,
> lilydjwg
> 
> Linux Vim Python 我的博客:
> http://lilydjwg.is-programmer.com/
> -- 
> A: Because it obfuscates the reading.
> Q: Why is top posting so bad?
> 
> 
> diff -Nuar vim_old/src/if_python.c vim_new/src/if_python.c
> --- vim_old/src/if_python.c   2012-06-30 00:09:17.060163310 +0800
> +++ vim_new/src/if_python.c   2012-06-30 00:09:46.603636044 +0800
> @@ -192,7 +192,8 @@
>  # define PyString_Size dll_PyString_Size
>  # define PyString_Type (*dll_PyString_Type)
>  # define PyUnicode_Type (*dll_PyUnicode_Type)
> -# define PyUnicodeUCS4_AsEncodedString (*dll_PyUnicodeUCS4_AsEncodedString)
> +# undef PyUnicode_AsEncodedString
> +# define PyUnicode_AsEncodedString py_PyUnicode_AsEncodedString
>  # define PyFloat_AsDouble dll_PyFloat_AsDouble
>  # define PyFloat_FromDouble dll_PyFloat_FromDouble
>  # define PyFloat_Type (*dll_PyFloat_Type)
> @@ -281,7 +282,7 @@
>  static PyInt(*dll_PyString_Size)(PyObject *);
>  static PyTypeObject* dll_PyString_Type;
>  static PyTypeObject* dll_PyUnicode_Type;
> -static PyObject *(*PyUnicodeUCS4_AsEncodedString)(PyObject *, char *, char 
> *);
> +static PyObject *(*py_PyUnicode_AsEncodedString)(PyObject *, char *, char *);
>  static double(*dll_PyFloat_AsDouble)(PyObject *);
>  static PyObject*(*dll_PyFloat_FromDouble)(double);
>  static PyTypeObject* dll_PyFloat_Type;
> @@ -392,7 +393,6 @@
>      {"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
>      {"PyString_Type", (PYTHON_PROC*)&dll_PyString_Type},
>      {"PyUnicode_Type", (PYTHON_PROC*)&dll_PyUnicode_Type},
> -    {"PyUnicodeUCS4_AsEncodedString", 
> (PYTHON_PROC*)&dll_PyUnicodeUCS4_AsEncodedString},
>      {"PyFloat_Type", (PYTHON_PROC*)&dll_PyFloat_Type},
>      {"PyFloat_AsDouble", (PYTHON_PROC*)&dll_PyFloat_AsDouble},
>      {"PyFloat_FromDouble", (PYTHON_PROC*)&dll_PyFloat_FromDouble},
> @@ -451,6 +451,7 @@
>  python_runtime_link_init(char *libname, int verbose)
>  {
>      int i;
> +    void *ucs_as_encoded_string;
>  
>  #if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && 
> defined(UNIX) && defined(FEAT_PYTHON3)
>      /* Can't have Python and Python3 loaded at the same time.
> @@ -486,6 +487,25 @@
>           return FAIL;
>       }
>      }
> +
> +    /* Load unicode functions separately as only the ucs2 or the ucs4 
> functions
> +     * will be present in the library. */
> +    ucs_as_encoded_string = symbol_from_dll(hinstPython,
> +         "PyUnicodeUCS2_AsEncodedString");
> +    if (!ucs_as_encoded_string)
> +     ucs_as_encoded_string = symbol_from_dll(hinstPython,
> +             "PyUnicodeUCS4_AsEncodedString");
> +    if (ucs_as_encoded_string)
> +     py_PyUnicode_AsEncodedString = ucs_as_encoded_string;
> +    else
> +    {
> +     close_dll(hinstPython);
> +     hinstPython = 0;
> +     if (verbose)
> +         EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*");
> +     return FAIL;
> +    }
> +
>      return OK;
>  }

After compiling with this patch and trying :python print "Hello, World", 
:python3 print("Hello, World"), and my Python 2.X plugin, I can confirm that 
this patch works fine.

-- 
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