Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Objects/enumobject.c

Issue 25958: Implicit ABCs have no means of "anti-registration"
Patch Set: Created 4 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* enumerate object */ 1 /* enumerate object */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 4
5 typedef struct { 5 typedef struct {
6 PyObject_HEAD 6 PyObject_HEAD
7 Py_ssize_t en_index; /* current index of enumeration */ 7 Py_ssize_t en_index; /* current index of enumeration */
8 PyObject* en_sit; /* secondary iterator of enumeration */ 8 PyObject* en_sit; /* secondary iterator of enumeration */
9 PyObject* en_result; /* result tuple */ 9 PyObject* en_result; /* result tuple */
10 PyObject* en_longindex; /* index for sequences >= PY_SSIZE_T_MAX */ 10 PyObject* en_longindex; /* index for sequences >= PY_SSIZE_T_MAX */
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 reversedobject *ro; 243 reversedobject *ro;
244 _Py_IDENTIFIER(__reversed__); 244 _Py_IDENTIFIER(__reversed__);
245 245
246 if (type == &PyReversed_Type && !_PyArg_NoKeywords("reversed()", kwds)) 246 if (type == &PyReversed_Type && !_PyArg_NoKeywords("reversed()", kwds))
247 return NULL; 247 return NULL;
248 248
249 if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq) ) 249 if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq) )
250 return NULL; 250 return NULL;
251 251
252 reversed_meth = _PyObject_LookupSpecial(seq, &PyId___reversed__); 252 reversed_meth = _PyObject_LookupSpecial(seq, &PyId___reversed__);
253 if (reversed_meth == Py_None) {
254 Py_DECREF(reversed_meth);
255 PyErr_SetString(PyExc_TypeError,
256 "argument to reversed() must be a sequence");
storchaka 2016/01/05 21:48:04 Would be nice to include argument type in the erro
abarnert 2016/01/05 23:28:55 Agreed. And it would be more consistent with __ite
storchaka 2016/01/06 00:04:31 We change some error messages to more informative
257 return NULL;
258 }
253 if (reversed_meth != NULL) { 259 if (reversed_meth != NULL) {
254 PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL); 260 PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL);
255 Py_DECREF(reversed_meth); 261 Py_DECREF(reversed_meth);
256 return res; 262 return res;
257 } 263 }
258 else if (PyErr_Occurred()) 264 else if (PyErr_Occurred())
259 return NULL; 265 return NULL;
260 266
261 if (!PySequence_Check(seq)) { 267 if (!PySequence_Check(seq)) {
262 PyErr_SetString(PyExc_TypeError, 268 PyErr_SetString(PyExc_TypeError,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 0, /* tp_base */ 414 0, /* tp_base */
409 0, /* tp_dict */ 415 0, /* tp_dict */
410 0, /* tp_descr_get */ 416 0, /* tp_descr_get */
411 0, /* tp_descr_set */ 417 0, /* tp_descr_set */
412 0, /* tp_dictoffset */ 418 0, /* tp_dictoffset */
413 0, /* tp_init */ 419 0, /* tp_init */
414 PyType_GenericAlloc, /* tp_alloc */ 420 PyType_GenericAlloc, /* tp_alloc */
415 reversed_new, /* tp_new */ 421 reversed_new, /* tp_new */
416 PyObject_GC_Del, /* tp_free */ 422 PyObject_GC_Del, /* tp_free */
417 }; 423 };
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+