[Python-checkins] cpython (merge 3.6 -> default): Issue #28086: Single var-positional argument of tuple subtype was passed
serhiy.storchaka
python-checkins at python.org
Thu Sep 22 12:44:04 EDT 2016
https://hg.python.org/cpython/rev/858afd17e3ee
changeset: 104017:858afd17e3ee
parent: 104013:e3b59c112ff5
parent: 104016:5324906ae307
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Sep 22 19:43:38 2016 +0300
summary:
Issue #28086: Single var-positional argument of tuple subtype was passed
unscathed to the C-defined function. Now it is converted to exact tuple.
files:
Lib/test/test_getargs2.py | 2 +-
Misc/NEWS | 3 +++
Python/ceval.c | 4 ++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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 --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list