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

Delta Between Two Patch Sets: Objects/enumobject.c

Issue 25958: Implicit ABCs have no means of "anti-registration"
Left Patch Set: Created 4 years, 1 month ago
Right Patch Set: Created 3 years, 6 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_unicode.py ('k') | Objects/typeobject.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 253 if (reversed_meth == Py_None) {
254 Py_DECREF(reversed_meth); 254 Py_DECREF(reversed_meth);
255 PyErr_SetString(PyExc_TypeError, 255 PyErr_Format(PyExc_TypeError,
256 "argument to reversed() must be a sequence"); 256 "'%.200s' object is not reversible",
257 Py_TYPE(seq)->tp_name);
257 return NULL; 258 return NULL;
258 } 259 }
259 if (reversed_meth != NULL) { 260 if (reversed_meth != NULL) {
260 PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL); 261 PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL);
261 Py_DECREF(reversed_meth); 262 Py_DECREF(reversed_meth);
262 return res; 263 return res;
263 } 264 }
264 else if (PyErr_Occurred()) 265 else if (PyErr_Occurred())
265 return NULL; 266 return NULL;
266 267
267 if (!PySequence_Check(seq)) { 268 if (!PySequence_Check(seq)) {
268 PyErr_SetString(PyExc_TypeError, 269 PyErr_Format(PyExc_TypeError,
269 "argument to reversed() must be a sequence"); 270 "'%.200s' object is not reversible",
271 Py_TYPE(seq)->tp_name);
270 return NULL; 272 return NULL;
271 } 273 }
272 274
273 n = PySequence_Size(seq); 275 n = PySequence_Size(seq);
274 if (n == -1) 276 if (n == -1)
275 return NULL; 277 return NULL;
276 278
277 ro = (reversedobject *)type->tp_alloc(type, 0); 279 ro = (reversedobject *)type->tp_alloc(type, 0);
278 if (ro == NULL) 280 if (ro == NULL)
279 return NULL; 281 return NULL;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 0, /* tp_base */ 416 0, /* tp_base */
415 0, /* tp_dict */ 417 0, /* tp_dict */
416 0, /* tp_descr_get */ 418 0, /* tp_descr_get */
417 0, /* tp_descr_set */ 419 0, /* tp_descr_set */
418 0, /* tp_dictoffset */ 420 0, /* tp_dictoffset */
419 0, /* tp_init */ 421 0, /* tp_init */
420 PyType_GenericAlloc, /* tp_alloc */ 422 PyType_GenericAlloc, /* tp_alloc */
421 reversed_new, /* tp_new */ 423 reversed_new, /* tp_new */
422 PyObject_GC_Del, /* tp_free */ 424 PyObject_GC_Del, /* tp_free */
423 }; 425 };
LEFTRIGHT

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