Skip to content

Commit 15d3d04

Browse files
committed
Before calling _PyType_Lookup() the type needs to be initialized.
1 parent 0d94203 commit 15d3d04

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Python/bltinmodule.c

+10
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,11 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
13831383
kwlist, &number, &ndigits))
13841384
return NULL;
13851385

1386+
if (Py_Type(number)->tp_dict == NULL) {
1387+
if (PyType_Ready(Py_Type(number)) < 0)
1388+
return NULL;
1389+
}
1390+
13861391
if (round_str == NULL) {
13871392
round_str = PyUnicode_FromString("__round__");
13881393
if (round_str == NULL)
@@ -1497,6 +1502,11 @@ builtin_trunc(PyObject *self, PyObject *number)
14971502
static PyObject *trunc_str = NULL;
14981503
PyObject *trunc;
14991504

1505+
if (Py_Type(number)->tp_dict == NULL) {
1506+
if (PyType_Ready(Py_Type(number)) < 0)
1507+
return NULL;
1508+
}
1509+
15001510
if (trunc_str == NULL) {
15011511
trunc_str = PyUnicode_FromString("__trunc__");
15021512
if (trunc_str == NULL)

0 commit comments

Comments
 (0)