Skip to content

Commit

Permalink
Before calling _PyType_Lookup() the type needs to be initialized.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Aug 24, 2007
1 parent 0d94203 commit 15d3d04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,11 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
kwlist, &number, &ndigits))
return NULL;

if (Py_Type(number)->tp_dict == NULL) {
if (PyType_Ready(Py_Type(number)) < 0)
return NULL;
}

if (round_str == NULL) {
round_str = PyUnicode_FromString("__round__");
if (round_str == NULL)
Expand Down Expand Up @@ -1497,6 +1502,11 @@ builtin_trunc(PyObject *self, PyObject *number)
static PyObject *trunc_str = NULL;
PyObject *trunc;

if (Py_Type(number)->tp_dict == NULL) {
if (PyType_Ready(Py_Type(number)) < 0)
return NULL;
}

if (trunc_str == NULL) {
trunc_str = PyUnicode_FromString("__trunc__");
if (trunc_str == NULL)
Expand Down

0 comments on commit 15d3d04

Please sign in to comment.