]>
Commit | Line | Data |
---|---|---|
5a088057 KK |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.658 | |
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.658 | |
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 | |
14 | ||
15 | ||
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 | |
18 | *************** | |
19 | *** 2530,2537 **** | |
20 | #if PY_MAJOR_VERSION >= 3 | |
21 | else if (PyBytes_Check(obj)) | |
22 | { | |
23 | ! char_u *result = (char_u *) PyBytes_AsString(obj); | |
24 | ||
25 | if (result == NULL) | |
26 | return -1; | |
27 | ||
28 | --- 2530,2539 ---- | |
29 | #if PY_MAJOR_VERSION >= 3 | |
30 | else if (PyBytes_Check(obj)) | |
31 | { | |
32 | ! char_u *result; | |
33 | ||
34 | + if (PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1) | |
35 | + return -1; | |
36 | if (result == NULL) | |
37 | return -1; | |
38 | ||
39 | *************** | |
40 | *** 2549,2555 **** | |
41 | if (bytes == NULL) | |
42 | return -1; | |
43 | ||
44 | ! result = (char_u *) PyBytes_AsString(bytes); | |
45 | if (result == NULL) | |
46 | return -1; | |
47 | ||
48 | --- 2551,2558 ---- | |
49 | if (bytes == NULL) | |
50 | return -1; | |
51 | ||
52 | ! if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1) | |
53 | ! return -1; | |
54 | if (result == NULL) | |
55 | return -1; | |
56 | ||
57 | *************** | |
58 | *** 2572,2578 **** | |
59 | if (bytes == NULL) | |
60 | return -1; | |
61 | ||
62 | ! result=(char_u *) PyString_AsString(bytes); | |
63 | if (result == NULL) | |
64 | return -1; | |
65 | ||
66 | --- 2575,2582 ---- | |
67 | if (bytes == NULL) | |
68 | return -1; | |
69 | ||
70 | ! if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1) | |
71 | ! return -1; | |
72 | if (result == NULL) | |
73 | return -1; | |
74 | ||
75 | *************** | |
76 | *** 2587,2594 **** | |
77 | } | |
78 | else if (PyString_Check(obj)) | |
79 | { | |
80 | ! char_u *result = (char_u *) PyString_AsString(obj); | |
81 | ||
82 | if (result == NULL) | |
83 | return -1; | |
84 | ||
85 | --- 2591,2600 ---- | |
86 | } | |
87 | else if (PyString_Check(obj)) | |
88 | { | |
89 | ! char_u *result; | |
90 | ||
91 | + if(PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1) | |
92 | + return -1; | |
93 | if (result == NULL) | |
94 | return -1; | |
95 | ||
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 | |
98 | *************** | |
99 | *** 85,90 **** | |
100 | --- 85,91 ---- | |
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) | |
105 | ||
106 | #if defined(DYNAMIC_PYTHON3) || defined(PROTO) | |
107 | ||
108 | *************** | |
109 | *** 552,558 **** | |
110 | #define DICTKEY_GET(err) \ | |
111 | if (PyBytes_Check(keyObject)) \ | |
112 | { \ | |
113 | ! if (PyBytes_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \ | |
114 | return err; \ | |
115 | } \ | |
116 | else if (PyUnicode_Check(keyObject)) \ | |
117 | --- 553,559 ---- | |
118 | #define DICTKEY_GET(err) \ | |
119 | if (PyBytes_Check(keyObject)) \ | |
120 | { \ | |
121 | ! if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \ | |
122 | return err; \ | |
123 | } \ | |
124 | else if (PyUnicode_Check(keyObject)) \ | |
125 | *************** | |
126 | *** 560,566 **** | |
127 | bytes = PyString_AsBytes(keyObject); \ | |
128 | if (bytes == NULL) \ | |
129 | return err; \ | |
130 | ! if (PyBytes_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \ | |
131 | return err; \ | |
132 | } \ | |
133 | else \ | |
134 | --- 561,567 ---- | |
135 | bytes = PyString_AsBytes(keyObject); \ | |
136 | if (bytes == NULL) \ | |
137 | return err; \ | |
138 | ! if (PyString_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \ | |
139 | return err; \ | |
140 | } \ | |
141 | else \ | |
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 | |
144 | *************** | |
145 | *** 721,722 **** | |
146 | --- 721,724 ---- | |
147 | { /* Add new patch number below this line */ | |
148 | + /**/ | |
149 | + 658, | |
150 | /**/ | |
151 | ||
152 | -- | |
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) | |
155 | ||
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 /// |