[Python-checkins] r76647 - in python/branches/release31-maint: Misc/NEWS Modules/_testcapimodule.c Python/getargs.c
mark.dickinson
python-checkins at python.org
Thu Dec 3 12:01:53 CET 2009
Author: mark.dickinson
Date: Thu Dec 3 12:01:53 2009
New Revision: 76647
Log:
Merged revisions 76646 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r76646 | mark.dickinson | 2009-12-03 10:59:46 +0000 (Thu, 03 Dec 2009) | 6 lines
Issue #7414: Add missing 'case 'C'' to skipitem() in getargs.c. This
was causing PyArg_ParseTupleAndKeywords(args, kwargs, "|CC", ...) to
fail with a RuntimeError. Thanks Case Van Horsen for tracking down
the source of this error.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Misc/NEWS
python/branches/release31-maint/Modules/_testcapimodule.c
python/branches/release31-maint/Python/getargs.c
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Thu Dec 3 12:01:53 2009
@@ -270,6 +270,9 @@
C-API
-----
+- Issue #7414: 'C' code wasn't being skipped properly (for keyword arguments)
+ in PyArg_ParseTupleAndKeywords.
+
- Issue #6624: yArg_ParseTuple with "s" format when parsing argument with
NUL: Bogus TypeError detail string.
Modified: python/branches/release31-maint/Modules/_testcapimodule.c
==============================================================================
--- python/branches/release31-maint/Modules/_testcapimodule.c (original)
+++ python/branches/release31-maint/Modules/_testcapimodule.c Thu Dec 3 12:01:53 2009
@@ -616,6 +616,52 @@
Py_RETURN_NONE;
}
+static PyObject *
+test_bug_7414(PyObject *self)
+{
+ /* Issue #7414: for PyArg_ParseTupleAndKeywords, 'C' code wasn't being
+ skipped properly in skipitem() */
+ int a = 0, b = 0, result;
+ char *kwlist[] = {"a", "b", NULL};
+ PyObject *tuple = NULL, *dict = NULL, *b_str;
+
+ tuple = PyTuple_New(0);
+ if (tuple == NULL)
+ goto failure;
+ dict = PyDict_New();
+ if (dict == NULL)
+ goto failure;
+ b_str = PyUnicode_FromString("b");
+ if (b_str == NULL)
+ goto failure;
+ result = PyDict_SetItemString(dict, "b", b_str);
+ Py_DECREF(b_str);
+ if (result < 0)
+ goto failure;
+
+ result = PyArg_ParseTupleAndKeywords(tuple, dict, "|CC",
+ kwlist, &a, &b);
+ if (!result)
+ goto failure;
+
+ if (a != 0)
+ return raiseTestError("test_bug_7414",
+ "C format code not skipped properly");
+ if (b != 'b')
+ return raiseTestError("test_bug_7414",
+ "C format code returned wrong value");
+
+ Py_DECREF(dict);
+ Py_DECREF(tuple);
+ Py_RETURN_NONE;
+
+ failure:
+ Py_XDECREF(dict);
+ Py_XDECREF(tuple);
+ return NULL;
+}
+
+
static volatile int x;
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
@@ -1457,6 +1503,7 @@
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
{"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
+ {"test_bug_7414", (PyCFunction)test_bug_7414, METH_NOARGS},
{"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS},
{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
{"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS,
Modified: python/branches/release31-maint/Python/getargs.c
==============================================================================
--- python/branches/release31-maint/Python/getargs.c (original)
+++ python/branches/release31-maint/Python/getargs.c Thu Dec 3 12:01:53 2009
@@ -1776,6 +1776,7 @@
case 'D': /* complex double */
#endif
case 'c': /* char */
+ case 'C': /* unicode char */
{
(void) va_arg(*p_va, void *);
break;
More information about the Python-checkins
mailing list