Kaydet (Commit) 8b13b3ed authored tarafından Tim Peters's avatar Tim Peters

SF bug [#466173] unpack TypeError unclear

Replaced 3 instances of "iter() of non-sequence" with
"iteration over non-sequence".
Restored "unpack non-sequence" for stuff like "a, b = 1".
üst d38b1c74
...@@ -1859,7 +1859,7 @@ PyObject_GetIter(PyObject *o) ...@@ -1859,7 +1859,7 @@ PyObject_GetIter(PyObject *o)
if (f == NULL) { if (f == NULL) {
if (PySequence_Check(o)) if (PySequence_Check(o))
return PySeqIter_New(o); return PySeqIter_New(o);
PyErr_SetString(PyExc_TypeError, "iter() of non-sequence"); PyErr_SetString(PyExc_TypeError, "iteration over non-sequence");
return NULL; return NULL;
} }
else { else {
......
...@@ -1839,7 +1839,7 @@ instance_getiter(PyInstanceObject *self) ...@@ -1839,7 +1839,7 @@ instance_getiter(PyInstanceObject *self)
} }
PyErr_Clear(); PyErr_Clear();
if ((func = instance_getattr(self, getitemstr)) == NULL) { if ((func = instance_getattr(self, getitemstr)) == NULL) {
PyErr_SetString(PyExc_TypeError, "iter() of non-sequence"); PyErr_SetString(PyExc_TypeError, "iteration over non-sequence");
return NULL; return NULL;
} }
Py_DECREF(func); Py_DECREF(func);
......
...@@ -3261,7 +3261,7 @@ slot_tp_iter(PyObject *self) ...@@ -3261,7 +3261,7 @@ slot_tp_iter(PyObject *self)
PyErr_Clear(); PyErr_Clear();
func = lookup_method(self, "__getitem__", &getitem_str); func = lookup_method(self, "__getitem__", &getitem_str);
if (func == NULL) { if (func == NULL) {
PyErr_SetString(PyExc_TypeError, "iter() of non-sequence"); PyErr_SetString(PyExc_TypeError, "iteration over non-sequence");
return NULL; return NULL;
} }
Py_DECREF(func); Py_DECREF(func);
......
...@@ -1556,8 +1556,12 @@ eval_frame(PyFrameObject *f) ...@@ -1556,8 +1556,12 @@ eval_frame(PyFrameObject *f)
else if (unpack_iterable(v, oparg, else if (unpack_iterable(v, oparg,
stack_pointer + oparg)) stack_pointer + oparg))
stack_pointer += oparg; stack_pointer += oparg;
else else {
if (PyErr_ExceptionMatches(PyExc_TypeError))
PyErr_SetString(PyExc_TypeError,
"unpack non-sequence");
why = WHY_EXCEPTION; why = WHY_EXCEPTION;
}
Py_DECREF(v); Py_DECREF(v);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment