diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 19:46:01 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 19:46:01 (GMT) |
commit | 21d9f10c9442ba646340913beba8cf73cc77c885 (patch) | |
tree | 177253021450ca18b21878fc16704420c93433ce /Modules | |
parent | c6f9b2b7f5f3640ce8aeac4aff67f75821891d81 (diff) | |
parent | 9c0e1f83af433a9eebb70cd41adcff2b0d608e05 (diff) | |
download | cpython-21d9f10c9442ba646340913beba8cf73cc77c885.zip cpython-21d9f10c9442ba646340913beba8cf73cc77c885.tar.gz cpython-21d9f10c9442ba646340913beba8cf73cc77c885.tar.bz2 |
Merge from 3.5.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index a6cd386..74422a2 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1859,6 +1859,39 @@ unicode_asucs4(PyObject *self, PyObject *args) } static PyObject * +unicode_copycharacters(PyObject *self, PyObject *args) +{ + PyObject *from, *to, *to_copy; + Py_ssize_t from_start, to_start, how_many, copied; + + if (!PyArg_ParseTuple(args, "UnOnn:unicode_copycharacters", &to, &to_start, + &from, &from_start, &how_many)) { + return NULL; + } + + if (PyUnicode_READY(to) < 0) { + return NULL; + } + + if (!(to_copy = PyUnicode_New(PyUnicode_GET_LENGTH(to), + PyUnicode_MAX_CHAR_VALUE(to)))) { + return NULL; + } + if (PyUnicode_Fill(to_copy, 0, PyUnicode_GET_LENGTH(to_copy), 0U) < 0) { + Py_DECREF(to_copy); + return NULL; + } + + if ((copied = PyUnicode_CopyCharacters(to_copy, to_start, from, + from_start, how_many)) < 0) { + Py_DECREF(to_copy); + return NULL; + } + + return Py_BuildValue("(Nn)", to_copy, copied); +} + +static PyObject * unicode_encodedecimal(PyObject *self, PyObject *args) { Py_UNICODE *unicode; @@ -4061,6 +4094,7 @@ static PyMethodDef TestMethods[] = { {"unicode_aswidechar", unicode_aswidechar, METH_VARARGS}, {"unicode_aswidecharstring",unicode_aswidecharstring, METH_VARARGS}, {"unicode_asucs4", unicode_asucs4, METH_VARARGS}, + {"unicode_copycharacters", unicode_copycharacters, METH_VARARGS}, {"unicode_encodedecimal", unicode_encodedecimal, METH_VARARGS}, {"unicode_transformdecimaltoascii", unicode_transformdecimaltoascii, METH_VARARGS}, {"unicode_legacy_string", unicode_legacy_string, METH_VARARGS}, |