[pypy-commit] pypy stdlib-2.7.3: Install new version of _testcapimodule.c
amauryfa
noreply at buildbot.pypy.org
Tue Jun 12 21:21:55 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: stdlib-2.7.3
Changeset: r55627:ef130e60c494
Date: 2012-06-12 21:16 +0200
http://bitbucket.org/pypy/pypy/changeset/ef130e60c494/
Log: Install new version of _testcapimodule.c
diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c
--- a/lib_pypy/_testcapimodule.c
+++ b/lib_pypy/_testcapimodule.c
@@ -1107,6 +1107,41 @@
}
static PyObject *
+unicode_encodedecimal(PyObject *self, PyObject *args)
+{
+ Py_UNICODE *unicode;
+ int length;
+ char *errors = NULL;
+ PyObject *decimal;
+ Py_ssize_t decimal_length, new_length;
+ int res;
+
+ if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length, &errors))
+ return NULL;
+
+ decimal_length = length * 7; /* len('€') */
+ decimal = PyBytes_FromStringAndSize(NULL, decimal_length);
+ if (decimal == NULL)
+ return NULL;
+
+ res = PyUnicode_EncodeDecimal(unicode, length,
+ PyBytes_AS_STRING(decimal),
+ errors);
+ if (res < 0) {
+ Py_DECREF(decimal);
+ return NULL;
+ }
+
+ new_length = strlen(PyBytes_AS_STRING(decimal));
+ assert(new_length <= decimal_length);
+ res = _PyBytes_Resize(&decimal, new_length);
+ if (res < 0)
+ return NULL;
+
+ return decimal;
+}
+
+static PyObject *
test_empty_argparse(PyObject *self)
{
/* Test that formats can begin with '|'. See issue #4720. */
@@ -1640,6 +1675,19 @@
return PyErr_NewExceptionWithDoc(name, doc, base, dict);
}
+static PyObject *
+sequence_delitem(PyObject *self, PyObject *args)
+{
+ PyObject *seq;
+ Py_ssize_t i;
+
+ if (!PyArg_ParseTuple(args, "On", &seq, &i))
+ return NULL;
+ if (PySequence_DelItem(seq, i) < 0)
+ return NULL;
+ Py_RETURN_NONE;
+}
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
@@ -1686,6 +1734,7 @@
#ifdef Py_USING_UNICODE
{"test_u_code", (PyCFunction)test_u_code, METH_NOARGS},
{"test_widechar", (PyCFunction)test_widechar, METH_NOARGS},
+ {"unicode_encodedecimal", unicode_encodedecimal, METH_VARARGS},
#endif
#ifdef WITH_THREAD
{"_test_thread_state", test_thread_state, METH_VARARGS},
@@ -1696,6 +1745,7 @@
{"code_newempty", code_newempty, METH_VARARGS},
{"make_exception_with_doc", (PyCFunction)make_exception_with_doc,
METH_VARARGS | METH_KEYWORDS},
+ {"sequence_delitem", (PyCFunction)sequence_delitem, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
More information about the pypy-commit
mailing list