]> granicus.if.org Git - python/commitdiff
Before calling _PyType_Lookup() the type needs to be initialized.
authorGuido van Rossum <guido@python.org>
Fri, 24 Aug 2007 02:02:45 +0000 (02:02 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 Aug 2007 02:02:45 +0000 (02:02 +0000)
Python/bltinmodule.c

index 9bbf64b75bf30912f1fd4b77629070d67ed187e0..d087e9c786df60b1b7d26edc7b0a048001fecd45 100644 (file)
@@ -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)
@@ -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)