On Sun, Jun 26, 2011 at 04:02:00AM +0200, Bram Moolenaar wrote:
> 
> Patch 7.3.232
> Problem:    Python doesn't compile without +multi_byte
> Solution:   Use "latin1" when MULTI_BYTE is not defined.
> Files:      src/if_py_both.h
> 
> 
> *** ../vim-7.3.231/src/if_py_both.h   2011-06-19 00:27:46.000000000 +0200
> --- src/if_py_both.h  2011-06-26 03:58:07.000000000 +0200
> ***************
> *** 12,17 ****
> --- 12,23 ----
>    * Common code for if_python.c and if_python3.c.
>    */
>   
> + #ifdef FEAT_MBYTE
> + # define ENC_OPT p_enc
> + #else
> + # define ENC_OPT "latin1"
> + #endif
> + 
>   /*
>    * obtain a lock on the Vim data structures
>    */
> ***************
> *** 68,74 ****
>       char *str = NULL;
>       int error = ((OutputObject *)(self))->error;
>   
> !     if (!PyArg_ParseTuple(args, "es#", p_enc, &str, &len))
>       return NULL;
>   
>       Py_BEGIN_ALLOW_THREADS
> --- 74,80 ----
>       char *str = NULL;
>       int error = ((OutputObject *)(self))->error;
>   
> !     if (!PyArg_ParseTuple(args, "es#", ENC_OPT, &str, &len))
>       return NULL;
>   
>       Py_BEGIN_ALLOW_THREADS
> ***************
> *** 108,114 ****
>       char *str = NULL;
>       PyInt len;
>   
> !     if (!PyArg_Parse(line, "es#", p_enc, &str, &len)) {
>           PyErr_SetString(PyExc_TypeError, _("writelines() requires list of 
> strings"));
>           Py_DECREF(list);
>           return NULL;
> --- 114,120 ----
>       char *str = NULL;
>       PyInt len;
>   
> !     if (!PyArg_Parse(line, "es#", ENC_OPT, &str, &len)) {
>           PyErr_SetString(PyExc_TypeError, _("writelines() requires list of 
> strings"));
>           Py_DECREF(list);
>           return NULL;
> *** ../vim-7.3.231/src/version.c      2011-06-26 03:16:58.000000000 +0200
> --- src/version.c     2011-06-26 04:00:40.000000000 +0200
> ***************
> *** 711,712 ****
> --- 711,714 ----
>   {   /* Add new patch number below this line */
> + /**/
> +     232,
>   /**/
> 

Hi Bram,

There are more 'p_enc's in if_python3.c that needs the change. See the
attachment.

-- 
Best regards,
lilydjwg

Linux Vim Python 我的博客
http://bit.ly/lilydjwg or http://goo.gl/y4Gsy

-- 
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 --git a/src/if_python3.c b/src/if_python3.c
index e9b5ec7..01d7370 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -77,7 +77,7 @@ static void init_structs(void);
 
 #define PyInt Py_ssize_t
 #define PyString_Check(obj) PyUnicode_Check(obj)
-#define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)p_enc, 
CODEC_ERROR_HANDLER);
+#define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, 
CODEC_ERROR_HANDLER);
 #define PyString_FreeBytes(obj) Py_XDECREF(bytes)
 #define PyString_AsString(obj) PyBytes_AsString(obj)
 #define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
@@ -668,7 +668,7 @@ DoPy3Command(exarg_T *eap, const char *cmd)
 
     /* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause
      * SyntaxError (unicode error). */
-    cmdstr = PyUnicode_Decode(cmd, strlen(cmd), (char *)p_enc, 
CODEC_ERROR_HANDLER);
+    cmdstr = PyUnicode_Decode(cmd, strlen(cmd), (char *)ENC_OPT, 
CODEC_ERROR_HANDLER);
     cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER);
     Py_XDECREF(cmdstr);
     PyRun_SimpleString(PyBytes_AsString(cmdbytes));
@@ -1470,7 +1470,7 @@ LineToString(const char *str)
     }
     *p = '\0';
 
-    result = PyUnicode_Decode(tmp, len, (char *)p_enc, CODEC_ERROR_HANDLER);
+    result = PyUnicode_Decode(tmp, len, (char *)ENC_OPT, CODEC_ERROR_HANDLER);
 
     vim_free(tmp);
     return result;

Raspunde prin e-mail lui