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

Side by Side Diff: Objects/typeobject.c

Issue 11477: Bug in code dispatching based on internal slots
Patch Set: Created 2 years, 2 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:
View unified diff | Download patch
« no previous file with comments | « Objects/listobject.c ('k') | Objects/unicodeobject.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Type object implementation */ 1 /* Type object implementation */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include "frameobject.h" 4 #include "frameobject.h"
5 #include "structmember.h" 5 #include "structmember.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 9
10 /* Support type attribute cache */ 10 /* Support type attribute cache */
(...skipping 5448 matching lines...) Expand 10 before | Expand all | Expand 10 after
5459 ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \ 5459 ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \
5460 "x." NAME "(y) <==> " DOC) 5460 "x." NAME "(y) <==> " DOC)
5461 #define RBINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC) \ 5461 #define RBINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC) \
5462 ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \ 5462 ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \
5463 "x." NAME "(y) <==> " DOC) 5463 "x." NAME "(y) <==> " DOC)
5464 5464
5465 static slotdef slotdefs[] = { 5465 static slotdef slotdefs[] = {
5466 SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, 5466 SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc,
5467 "x.__len__() <==> len(x)"), 5467 "x.__len__() <==> len(x)"),
5468 /* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL. 5468 /* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL.
5469 The logic in abstract.c always falls back to nb_add/nb_multiply in 5469 The logic in abstract.c ignores them if nb_add/nb_multiply are
5470 this case. Defining both the nb_* and the sq_* slots to call the 5470 defined anyway. */
5471 user-defined methods has unexpected side-effects, as shown by
5472 test_descr.notimplemented() */
5473 SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc, 5471 SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc,
5474 "x.__add__(y) <==> x+y"), 5472 "x.__add__(y) <==> x+y"),
5475 SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, 5473 SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc,
5476 "x.__mul__(n) <==> x*n"), 5474 "x.__mul__(n) <==> x*n"),
5477 SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, 5475 SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc,
5478 "x.__rmul__(n) <==> n*x"), 5476 "x.__rmul__(n) <==> n*x"),
5479 SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, 5477 SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item,
5480 "x.__getitem__(y) <==> x[y]"), 5478 "x.__getitem__(y) <==> x[y]"),
5481 SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, 5479 SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem,
5482 "x.__setitem__(i, y) <==> x[i]=y"), 5480 "x.__setitem__(i, y) <==> x[i]=y"),
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
6381 0, /* tp_base */ 6379 0, /* tp_base */
6382 0, /* tp_dict */ 6380 0, /* tp_dict */
6383 super_descr_get, /* tp_descr_get */ 6381 super_descr_get, /* tp_descr_get */
6384 0, /* tp_descr_set */ 6382 0, /* tp_descr_set */
6385 0, /* tp_dictoffset */ 6383 0, /* tp_dictoffset */
6386 super_init, /* tp_init */ 6384 super_init, /* tp_init */
6387 PyType_GenericAlloc, /* tp_alloc */ 6385 PyType_GenericAlloc, /* tp_alloc */
6388 PyType_GenericNew, /* tp_new */ 6386 PyType_GenericNew, /* tp_new */
6389 PyObject_GC_Del, /* tp_free */ 6387 PyObject_GC_Del, /* tp_free */
6390 }; 6388 };
OLDNEW
« no previous file with comments | « Objects/listobject.c ('k') | Objects/unicodeobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7