Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(204571)

Side by Side Diff: Modules/_codecsmodule.c

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* ------------------------------------------------------------------------ 1 /* ------------------------------------------------------------------------
2 2
3 _codecs -- Provides access to the codec registry and the builtin 3 _codecs -- Provides access to the codec registry and the builtin
4 codecs. 4 codecs.
5 5
6 This module should never be imported directly. The standard library 6 This module should never be imported directly. The standard library
7 module "codecs" wraps this builtin module for use within Python. 7 module "codecs" wraps this builtin module for use within Python.
8 8
9 The codec registry is accessible via: 9 The codec registry is accessible via:
10 10
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 v = Py_BuildValue("On", unicode, len); 201 v = Py_BuildValue("On", unicode, len);
202 Py_DECREF(unicode); 202 Py_DECREF(unicode);
203 return v; 203 return v;
204 } 204 }
205 205
206 /* --- String codecs ------------------------------------------------------ */ 206 /* --- String codecs ------------------------------------------------------ */
207 static PyObject * 207 static PyObject *
208 escape_decode(PyObject *self, 208 escape_decode(PyObject *self,
209 PyObject *args) 209 PyObject *args)
210 { 210 {
211 Py_buffer pbuf;
211 const char *errors = NULL; 212 const char *errors = NULL;
212 const char *data; 213 PyObject *result;
213 Py_ssize_t size;
214 214
215 if (!PyArg_ParseTuple(args, "s#|z:escape_decode", 215 if (!PyArg_ParseTuple(args, "s*|z:escape_decode",
216 &data, &size, &errors)) 216 &pbuf, &errors))
217 return NULL; 217 return NULL;
218 return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL), 218 result = codec_tuple(
219 size); 219 PyBytes_DecodeEscape(pbuf.buf, pbuf.len, errors, 0, NULL),
220 pbuf.len);
221 PyBuffer_Release(&pbuf);
222 return result;
220 } 223 }
221 224
222 static PyObject * 225 static PyObject *
223 escape_encode(PyObject *self, 226 escape_encode(PyObject *self,
224 PyObject *args) 227 PyObject *args)
225 { 228 {
226 PyObject *str; 229 PyObject *str;
227 Py_ssize_t size; 230 Py_ssize_t size;
228 Py_ssize_t newsize; 231 Py_ssize_t newsize;
229 const char *errors = NULL; 232 const char *errors = NULL;
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 NULL, 1248 NULL,
1246 NULL, 1249 NULL,
1247 NULL 1250 NULL
1248 }; 1251 };
1249 1252
1250 PyMODINIT_FUNC 1253 PyMODINIT_FUNC
1251 PyInit__codecs(void) 1254 PyInit__codecs(void)
1252 { 1255 {
1253 return PyModule_Create(&codecsmodule); 1256 return PyModule_Create(&codecsmodule);
1254 } 1257 }
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+