cpython: 0285173d81b4 (original) (raw)

--- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -16,6 +16,11 @@ except ImportError:

Skip this test if the _testcapi module isn't available.

_testcapi = support.import_module('_testcapi') +class CAPITest(unittest.TestCase): +

+ @unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): @@ -132,7 +137,7 @@ def test_main(): except _testcapi.error: raise support.TestFailed, sys.exc_info()[1]

if name == "main": test_main()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 2.7.12? Core and Builtins ----------------- +- Issue #26168: Fixed possible refleaks in failing Py_BuildValue() with the "N"

--- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -931,6 +931,100 @@ test_L_code(PyObject self) #endif / ifdef HAVE_LONG_LONG */ static PyObject * +return_none(void *unused) +{

+} + +static PyObject * +raise_error(void *unused) +{

+} + +static int +test_buildvalue_N_error(const char *fmt) +{

+

+

+

+} + +static PyObject * +test_buildvalue_N(PyObject *self, PyObject *noargs) +{

+

+

+

+} + + +static PyObject * get_args(PyObject *self, PyObject *args) { if (args == NULL) { @@ -2414,6 +2508,7 @@ static PyMethodDef TestMethods[] = { {"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS, PyDoc_STR("This is a pretty normal docstring.")},

--- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -156,48 +156,83 @@ static PyObject do_mkdict(const char, static PyObject do_mkvalue(const char, va_list *, int); +static void +do_ignore(const char **p_format, va_list *p_va, int endchar, int n, int flags) +{

+} + static PyObject * do_mkdict(const char **p_format, va_list *p_va, int endchar, int n, int flags) { PyObject *d; int i;

+ k = do_mkvalue(p_format, p_va, flags); if (k == NULL) {

@@ -207,29 +242,24 @@ do_mklist(const char **p_format, va_list { PyObject *v; int i;

@@ -257,27 +287,23 @@ do_mktuple(const char **p_format, va_lis { PyObject *v; int i;