From 3e2d4b8800fb0cd0afe4da7ca6537f8f23847879 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 30 Oct 2012 23:41:54 -0400 Subject: initialize map/filter/zip in _PyBuiltin_Init rather than the catch-all function --- Python/bltinmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 0e6e6ff9ff..fac64bcc69 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2405,6 +2405,12 @@ PyObject * _PyBuiltin_Init(void) { PyObject *mod, *dict, *debug; + + if (PyType_Ready(&PyFilter_Type) < 0 || + PyType_Ready(&PyMap_Type) < 0 || + PyType_Ready(&PyZip_Type) < 0) + return NULL; + mod = PyModule_Create(&builtinsmodule); if (mod == NULL) return NULL; -- cgit v1.2.1 From 06d2f1270573c6e8ed5e696c53cadfe59eb31189 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Thu, 13 Dec 2012 15:44:18 -0800 Subject: compile doesn't accept code objects --- Python/bltinmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fac64bcc69..6f52a9a8cf 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -657,7 +657,7 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds) goto finally; } - str = source_as_string(cmd, "compile", "string, bytes, AST or code", &cf); + str = source_as_string(cmd, "compile", "string, bytes or AST", &cf); if (str == NULL) goto error; -- cgit v1.2.1 From a21d99223449b193ac6e4b970048f4c0dac4db6f Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 13 Apr 2013 17:19:01 -0400 Subject: properly lookup the __round__ special method (closes #17722) --- Python/bltinmodule.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a486b4978c..5291565b81 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1810,10 +1810,10 @@ For most object types, eval(repr(object)) == object."); static PyObject * builtin_round(PyObject *self, PyObject *args, PyObject *kwds) { - static PyObject *round_str = NULL; PyObject *ndigits = NULL; static char *kwlist[] = {"number", "ndigits", 0}; - PyObject *number, *round; + PyObject *number, *round, *result; + _Py_IDENTIFIER(__round__); if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:round", kwlist, &number, &ndigits)) @@ -1824,24 +1824,21 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds) return NULL; } - if (round_str == NULL) { - round_str = PyUnicode_InternFromString("__round__"); - if (round_str == NULL) - return NULL; - } - - round = _PyType_Lookup(Py_TYPE(number), round_str); + round = _PyObject_LookupSpecial(number, &PyId___round__); if (round == NULL) { - PyErr_Format(PyExc_TypeError, - "type %.100s doesn't define __round__ method", - Py_TYPE(number)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_TypeError, + "type %.100s doesn't define __round__ method", + Py_TYPE(number)->tp_name); return NULL; } if (ndigits == NULL) - return PyObject_CallFunction(round, "O", number); + result = PyObject_CallFunctionObjArgs(round, NULL); else - return PyObject_CallFunction(round, "OO", number, ndigits); + result = PyObject_CallFunctionObjArgs(round, ndigits, NULL); + Py_DECREF(round); + return result; } PyDoc_STRVAR(round_doc, -- cgit v1.2.1