1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: NUL bytes truncate strings when converted from Python.
12 Solution: Handle truncation as an error. (ZyX)
13 Files: src/if_py_both.h, src/if_python3.c
16 *** ../vim-7.3.657/src/if_py_both.h 2012-09-05 18:45:24.000000000 +0200
17 --- src/if_py_both.h 2012-09-05 19:05:27.000000000 +0200
20 #if PY_MAJOR_VERSION >= 3
21 else if (PyBytes_Check(obj))
23 ! char_u *result = (char_u *) PyBytes_AsString(obj);
29 #if PY_MAJOR_VERSION >= 3
30 else if (PyBytes_Check(obj))
34 + if (PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1)
44 ! result = (char_u *) PyBytes_AsString(bytes);
52 ! if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
62 ! result=(char_u *) PyString_AsString(bytes);
70 ! if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
78 else if (PyString_Check(obj))
80 ! char_u *result = (char_u *) PyString_AsString(obj);
87 else if (PyString_Check(obj))
91 + if(PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1)
96 *** ../vim-7.3.657/src/if_python3.c 2012-09-05 19:03:51.000000000 +0200
97 --- src/if_python3.c 2012-09-05 19:05:27.000000000 +0200
101 #define PyString_AsString(obj) PyBytes_AsString(obj)
102 #define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
103 #define PyString_FromString(repr) PyUnicode_FromString(repr)
104 + #define PyString_AsStringAndSize(obj, buffer, len) PyBytes_AsStringAndSize(obj, buffer, len)
106 #if defined(DYNAMIC_PYTHON3) || defined(PROTO)
110 #define DICTKEY_GET(err) \
111 if (PyBytes_Check(keyObject)) \
113 ! if (PyBytes_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
116 else if (PyUnicode_Check(keyObject)) \
118 #define DICTKEY_GET(err) \
119 if (PyBytes_Check(keyObject)) \
121 ! if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
124 else if (PyUnicode_Check(keyObject)) \
127 bytes = PyString_AsBytes(keyObject); \
130 ! if (PyBytes_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
135 bytes = PyString_AsBytes(keyObject); \
138 ! if (PyString_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
142 *** ../vim-7.3.657/src/version.c 2012-09-05 19:03:51.000000000 +0200
143 --- src/version.c 2012-09-05 19:07:40.000000000 +0200
147 { /* Add new patch number below this line */
153 You know you use Vim too much when you have this alias in your
154 ~/.bashrc file: alias :e=/bin/vim (Eljay Love-Jensen)
156 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
157 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
158 \\\ an exciting new programming language -- http://www.Zimbu.org ///
159 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///