File tree 1 file changed +17
-4
lines changed 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -86,18 +86,31 @@ static PyObject *
86
86
dictionary_of (PyObject * self , PyObject * args )
87
87
{
88
88
PyObject * obj , * * dict_ptr , * dict ;
89
+ PyTypeObject * type ;
89
90
90
91
if (!PyArg_ParseTuple (args , "O:dictionary_of" , & obj ))
91
92
return NULL ;
92
93
93
- dict_ptr = _PyObject_GetDictPtr (obj );
94
- if (dict_ptr == NULL ) {
95
- PyErr_SetString (sandbox_error , "Object has no dict" );
96
- return NULL ;
94
+ if (PyType_Check (obj )) {
95
+ type = (PyTypeObject * )obj ;
96
+ if (type -> tp_dict == NULL ) {
97
+ if (PyType_Ready (type ) < 0 )
98
+ return NULL ;
99
+ }
97
100
}
101
+
102
+ dict_ptr = _PyObject_GetDictPtr (obj );
103
+ if (dict_ptr == NULL )
104
+ goto error ;
98
105
dict = * dict_ptr ;
106
+ if (dict == NULL )
107
+ goto error ;
99
108
Py_INCREF (dict );
100
109
return dict ;
110
+
111
+ error :
112
+ PyErr_SetString (sandbox_error , "Object has no dict" );
113
+ return NULL ;
101
114
}
102
115
103
116
static PyMethodDef sandbox_methods [] = {
You can’t perform that action at this time.
0 commit comments