]>
Commit | Line | Data |
---|---|---|
bd12edf3 | 1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.250 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.250 | |
11 | Problem: Python: Errors in Unicode characters not handled nicely. | |
12 | Solution: Add the surrogateescape error handler. (lilydjwg) | |
13 | Files: src/if_python3.c | |
14 | ||
15 | ||
16 | *** ../vim-7.3.249/src/if_python3.c 2011-06-26 19:13:33.000000000 +0200 | |
17 | --- src/if_python3.c 2011-07-15 15:50:01.000000000 +0200 | |
18 | *************** | |
19 | *** 68,76 **** | |
20 | ||
21 | static void init_structs(void); | |
22 | ||
23 | #define PyInt Py_ssize_t | |
24 | #define PyString_Check(obj) PyUnicode_Check(obj) | |
25 | ! #define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, NULL); | |
26 | #define PyString_FreeBytes(obj) Py_XDECREF(bytes) | |
27 | #define PyString_AsString(obj) PyBytes_AsString(obj) | |
28 | #define PyString_Size(obj) PyBytes_GET_SIZE(bytes) | |
29 | --- 68,83 ---- | |
30 | ||
31 | static void init_structs(void); | |
32 | ||
33 | + /* The "surrogateescape" error handler is new in Python 3.1 */ | |
34 | + #if PY_VERSION_HEX >= 0x030100f0 | |
35 | + # define CODEC_ERROR_HANDLER "surrogateescape" | |
36 | + #else | |
37 | + # define CODEC_ERROR_HANDLER NULL | |
38 | + #endif | |
39 | + | |
40 | #define PyInt Py_ssize_t | |
41 | #define PyString_Check(obj) PyUnicode_Check(obj) | |
42 | ! #define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER); | |
43 | #define PyString_FreeBytes(obj) Py_XDECREF(bytes) | |
44 | #define PyString_AsString(obj) PyBytes_AsString(obj) | |
45 | #define PyString_Size(obj) PyBytes_GET_SIZE(bytes) | |
46 | *************** | |
47 | *** 661,668 **** | |
48 | ||
49 | /* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause | |
50 | * SyntaxError (unicode error). */ | |
51 | ! cmdstr = PyUnicode_Decode(cmd, strlen(cmd), (char *)ENC_OPT, NULL); | |
52 | ! cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", NULL); | |
53 | Py_XDECREF(cmdstr); | |
54 | PyRun_SimpleString(PyBytes_AsString(cmdbytes)); | |
55 | Py_XDECREF(cmdbytes); | |
56 | --- 668,676 ---- | |
57 | ||
58 | /* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause | |
59 | * SyntaxError (unicode error). */ | |
60 | ! cmdstr = PyUnicode_Decode(cmd, strlen(cmd), | |
61 | ! (char *)ENC_OPT, CODEC_ERROR_HANDLER); | |
62 | ! cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER); | |
63 | Py_XDECREF(cmdstr); | |
64 | PyRun_SimpleString(PyBytes_AsString(cmdbytes)); | |
65 | Py_XDECREF(cmdbytes); | |
66 | *************** | |
67 | *** 1463,1469 **** | |
68 | } | |
69 | *p = '\0'; | |
70 | ||
71 | ! result = PyUnicode_Decode(tmp, len, (char *)ENC_OPT, NULL); | |
72 | ||
73 | vim_free(tmp); | |
74 | return result; | |
75 | --- 1471,1477 ---- | |
76 | } | |
77 | *p = '\0'; | |
78 | ||
79 | ! result = PyUnicode_Decode(tmp, len, (char *)ENC_OPT, CODEC_ERROR_HANDLER); | |
80 | ||
81 | vim_free(tmp); | |
82 | return result; | |
83 | *** ../vim-7.3.249/src/version.c 2011-07-15 14:12:25.000000000 +0200 | |
84 | --- src/version.c 2011-07-15 15:46:19.000000000 +0200 | |
85 | *************** | |
86 | *** 711,712 **** | |
87 | --- 711,714 ---- | |
88 | { /* Add new patch number below this line */ | |
89 | + /**/ | |
90 | + 250, | |
91 | /**/ | |
92 | ||
93 | -- | |
94 | DINGO: You must spank her well and after you have spanked her you | |
95 | may deal with her as you like and then ... spank me. | |
96 | AMAZING: And spank me! | |
97 | STUNNER: And me. | |
98 | LOVELY: And me. | |
99 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
100 | ||
101 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
102 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
103 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
104 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |