changeset: 104017:858afd17e3ee parent: 104013:e3b59c112ff5 parent: 104016:5324906ae307 user: Serhiy Storchaka date: Thu Sep 22 19:43:38 2016 +0300 files: Misc/NEWS description: Issue #28086: Single var-positional argument of tuple subtype was passed unscathed to the C-defined function. Now it is converted to exact tuple. diff -r e3b59c112ff5 -r 858afd17e3ee Lib/test/test_getargs2.py --- a/Lib/test/test_getargs2.py Thu Sep 22 16:50:18 2016 +0200 +++ b/Lib/test/test_getargs2.py Thu Sep 22 19:43:38 2016 +0300 @@ -471,7 +471,7 @@ ret = get_args(*TupleSubclass([1, 2])) self.assertEqual(ret, (1, 2)) - self.assertIsInstance(ret, tuple) + self.assertIs(type(ret), tuple) ret = get_args() self.assertIn(ret, ((), None)) diff -r e3b59c112ff5 -r 858afd17e3ee Misc/NEWS --- a/Misc/NEWS Thu Sep 22 16:50:18 2016 +0200 +++ b/Misc/NEWS Thu Sep 22 19:43:38 2016 +0300 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #28086: Single var-positional argument of tuple subtype was passed + unscathed to the C-defined function. Now it is converted to exact tuple. + - Issue #28214: Now __set_name__ is looked up on the class instead of the instance. diff -r e3b59c112ff5 -r 858afd17e3ee Python/ceval.c --- a/Python/ceval.c Thu Sep 22 16:50:18 2016 +0200 +++ b/Python/ceval.c Thu Sep 22 19:43:38 2016 +0300 @@ -3310,7 +3310,7 @@ } callargs = POP(); func = TOP(); - if (!PyTuple_Check(callargs)) { + if (!PyTuple_CheckExact(callargs)) { if (Py_TYPE(callargs)->tp_iter == NULL && !PySequence_Check(callargs)) { PyErr_Format(PyExc_TypeError, @@ -3327,7 +3327,7 @@ goto error; } } - assert(PyTuple_Check(callargs)); + assert(PyTuple_CheckExact(callargs)); result = do_call_core(func, callargs, kwargs); Py_DECREF(func);