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

Delta Between Two Patch Sets: Objects/typeobject.c

Issue 27809: _PyObject_FastCall(): add support for keyword arguments
Left Patch Set: Created 3 years, 3 months ago
Right Patch Set: Created 3 years, 3 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:
Right: Side by side diff | Download
« no previous file with change/comment | « Objects/iterobject.c ('k') | Python/ceval.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
(no file at all)
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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 if (args == NULL) { 1443 if (args == NULL) {
1444 Py_DECREF(func); 1444 Py_DECREF(func);
1445 return NULL; 1445 return NULL;
1446 } 1446 }
1447 assert(PyTuple_Check(args)); 1447 assert(PyTuple_Check(args));
1448 1448
1449 retval = PyObject_Call(func, args, NULL); 1449 retval = PyObject_Call(func, args, NULL);
1450 Py_DECREF(args); 1450 Py_DECREF(args);
1451 } 1451 }
1452 else { 1452 else {
1453 retval = _PyObject_FastCall(func, NULL, 0, NULL); 1453 retval = _PyObject_CallNoArg(func);
1454 } 1454 }
1455 1455
1456 Py_DECREF(func); 1456 Py_DECREF(func);
1457 1457
1458 return retval; 1458 return retval;
1459 } 1459 }
1460 1460
1461 /* Clone of call_method() that returns NotImplemented when the lookup fails. */ 1461 /* Clone of call_method() that returns NotImplemented when the lookup fails. */
1462 1462
1463 static PyObject * 1463 static PyObject *
(...skipping 19 matching lines...) Expand all
1483 if (args == NULL) { 1483 if (args == NULL) {
1484 Py_DECREF(func); 1484 Py_DECREF(func);
1485 return NULL; 1485 return NULL;
1486 } 1486 }
1487 assert(PyTuple_Check(args)); 1487 assert(PyTuple_Check(args));
1488 1488
1489 retval = PyObject_Call(func, args, NULL); 1489 retval = PyObject_Call(func, args, NULL);
1490 Py_DECREF(args); 1490 Py_DECREF(args);
1491 } 1491 }
1492 else { 1492 else {
1493 retval = _PyObject_FastCall(func, NULL, 0, NULL); 1493 retval = _PyObject_CallNoArg(func);
1494 } 1494 }
1495 1495
1496 Py_DECREF(func); 1496 Py_DECREF(func);
1497 1497
1498 return retval; 1498 return retval;
1499 } 1499 }
1500 1500
1501 /* 1501 /*
1502 Method resolution order algorithm C3 described in 1502 Method resolution order algorithm C3 described in
1503 "A Monotonic Superclass Linearization for Dylan", 1503 "A Monotonic Superclass Linearization for Dylan",
(...skipping 4323 matching lines...) Expand 10 before | Expand all | Expand 10 after
5827 if (func == NULL) { 5827 if (func == NULL) {
5828 return NULL; 5828 return NULL;
5829 } 5829 }
5830 } 5830 }
5831 5831
5832 ival = PyLong_FromSsize_t(i); 5832 ival = PyLong_FromSsize_t(i);
5833 if (ival == NULL) { 5833 if (ival == NULL) {
5834 goto error; 5834 goto error;
5835 } 5835 }
5836 5836
5837 retval = _PyObject_FastCall(func, &ival, 1, NULL); 5837 retval = _PyObject_CallArg1(func, ival);
5838 Py_DECREF(func); 5838 Py_DECREF(func);
5839 Py_DECREF(ival); 5839 Py_DECREF(ival);
5840 return retval; 5840 return retval;
5841 5841
5842 error: 5842 error:
5843 Py_DECREF(func); 5843 Py_DECREF(func);
5844 return NULL; 5844 return NULL;
5845 } 5845 }
5846 5846
5847 static int 5847 static int
(...skipping 20 matching lines...) Expand all
5868 5868
5869 func = lookup_maybe(self, &PyId___contains__); 5869 func = lookup_maybe(self, &PyId___contains__);
5870 if (func == Py_None) { 5870 if (func == Py_None) {
5871 Py_DECREF(func); 5871 Py_DECREF(func);
5872 PyErr_Format(PyExc_TypeError, 5872 PyErr_Format(PyExc_TypeError,
5873 "'%.200s' object is not a container", 5873 "'%.200s' object is not a container",
5874 Py_TYPE(self)->tp_name); 5874 Py_TYPE(self)->tp_name);
5875 return -1; 5875 return -1;
5876 } 5876 }
5877 if (func != NULL) { 5877 if (func != NULL) {
5878 res = _PyObject_FastCall(func, &value, 1, NULL); 5878 res = _PyObject_CallArg1(func, value);
5879 Py_DECREF(func); 5879 Py_DECREF(func);
5880 if (res != NULL) { 5880 if (res != NULL) {
5881 result = PyObject_IsTrue(res); 5881 result = PyObject_IsTrue(res);
5882 Py_DECREF(res); 5882 Py_DECREF(res);
5883 } 5883 }
5884 } 5884 }
5885 else if (! PyErr_Occurred()) { 5885 else if (! PyErr_Occurred()) {
5886 /* Possible results: -1 and 1 */ 5886 /* Possible results: -1 and 1 */
5887 result = (int)_PySequence_IterSearch(self, value, 5887 result = (int)_PySequence_IterSearch(self, value,
5888 PY_ITERSEARCH_CONTAINS); 5888 PY_ITERSEARCH_CONTAINS);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5960 func = lookup_maybe(self, &PyId___len__); 5960 func = lookup_maybe(self, &PyId___len__);
5961 if (func == NULL) { 5961 if (func == NULL) {
5962 if (PyErr_Occurred()) { 5962 if (PyErr_Occurred()) {
5963 return -1; 5963 return -1;
5964 } 5964 }
5965 return 1; 5965 return 1;
5966 } 5966 }
5967 using_len = 1; 5967 using_len = 1;
5968 } 5968 }
5969 5969
5970 value = _PyObject_FastCall(func, NULL, 0, NULL); 5970 value = _PyObject_CallNoArg(func);
5971 if (value == NULL) { 5971 if (value == NULL) {
5972 goto error; 5972 goto error;
5973 } 5973 }
5974 5974
5975 if (using_len) { 5975 if (using_len) {
5976 /* bool type enforced by slot_nb_len */ 5976 /* bool type enforced by slot_nb_len */
5977 result = PyObject_IsTrue(value); 5977 result = PyObject_IsTrue(value);
5978 } 5978 }
5979 else if (PyBool_Check(value)) { 5979 else if (PyBool_Check(value)) {
5980 result = PyObject_IsTrue(value); 5980 result = PyObject_IsTrue(value);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
6238 static PyObject * 6238 static PyObject *
6239 slot_tp_richcompare(PyObject *self, PyObject *other, int op) 6239 slot_tp_richcompare(PyObject *self, PyObject *other, int op)
6240 { 6240 {
6241 PyObject *func, *res; 6241 PyObject *func, *res;
6242 6242
6243 func = lookup_method(self, &name_op[op]); 6243 func = lookup_method(self, &name_op[op]);
6244 if (func == NULL) { 6244 if (func == NULL) {
6245 PyErr_Clear(); 6245 PyErr_Clear();
6246 Py_RETURN_NOTIMPLEMENTED; 6246 Py_RETURN_NOTIMPLEMENTED;
6247 } 6247 }
6248 res = _PyObject_FastCall(func, &other, 1, NULL); 6248 res = _PyObject_CallArg1(func, other);
6249 Py_DECREF(func); 6249 Py_DECREF(func);
6250 return res; 6250 return res;
6251 } 6251 }
6252 6252
6253 static PyObject * 6253 static PyObject *
6254 slot_tp_iter(PyObject *self) 6254 slot_tp_iter(PyObject *self)
6255 { 6255 {
6256 PyObject *func, *res; 6256 PyObject *func, *res;
6257 _Py_IDENTIFIER(__iter__); 6257 _Py_IDENTIFIER(__iter__);
6258 6258
6259 func = lookup_method(self, &PyId___iter__); 6259 func = lookup_method(self, &PyId___iter__);
6260 if (func == Py_None) { 6260 if (func == Py_None) {
6261 Py_DECREF(func); 6261 Py_DECREF(func);
6262 PyErr_Format(PyExc_TypeError, 6262 PyErr_Format(PyExc_TypeError,
6263 "'%.200s' object is not iterable", 6263 "'%.200s' object is not iterable",
6264 Py_TYPE(self)->tp_name); 6264 Py_TYPE(self)->tp_name);
6265 return NULL; 6265 return NULL;
6266 } 6266 }
6267 6267
6268 if (func != NULL) { 6268 if (func != NULL) {
6269 res = _PyObject_FastCall(func, NULL, 0, NULL); 6269 res = _PyObject_CallNoArg(func);
6270 Py_DECREF(func); 6270 Py_DECREF(func);
6271 return res; 6271 return res;
6272 } 6272 }
6273 6273
6274 PyErr_Clear(); 6274 PyErr_Clear();
6275 func = lookup_method(self, &PyId___getitem__); 6275 func = lookup_method(self, &PyId___getitem__);
6276 if (func == NULL) { 6276 if (func == NULL) {
6277 PyErr_Format(PyExc_TypeError, 6277 PyErr_Format(PyExc_TypeError,
6278 "'%.200s' object is not iterable", 6278 "'%.200s' object is not iterable",
6279 Py_TYPE(self)->tp_name); 6279 Py_TYPE(self)->tp_name);
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
7535 0, /* tp_base */ 7535 0, /* tp_base */
7536 0, /* tp_dict */ 7536 0, /* tp_dict */
7537 super_descr_get, /* tp_descr_get */ 7537 super_descr_get, /* tp_descr_get */
7538 0, /* tp_descr_set */ 7538 0, /* tp_descr_set */
7539 0, /* tp_dictoffset */ 7539 0, /* tp_dictoffset */
7540 super_init, /* tp_init */ 7540 super_init, /* tp_init */
7541 PyType_GenericAlloc, /* tp_alloc */ 7541 PyType_GenericAlloc, /* tp_alloc */
7542 PyType_GenericNew, /* tp_new */ 7542 PyType_GenericNew, /* tp_new */
7543 PyObject_GC_Del, /* tp_free */ 7543 PyObject_GC_Del, /* tp_free */
7544 }; 7544 };
LEFTRIGHT

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