File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -227,26 +227,27 @@ specialize_module_load_attr(
227
227
_PyAdaptiveEntry * cache0 , _PyLoadAttrCache * cache1 )
228
228
{
229
229
PyModuleObject * m = (PyModuleObject * )owner ;
230
- PyObject * attr , * getattr ;
230
+ PyObject * value = NULL ;
231
+ PyObject * getattr ;
231
232
_Py_IDENTIFIER (__getattr__ );
232
233
PyDictObject * dict = (PyDictObject * )m -> md_dict ;
233
234
if (dict == NULL ) {
234
235
return -1 ;
235
236
}
236
- getattr = _PyDict_GetItemIdWithError (m -> md_dict , & PyId___getattr__ );
237
- if (PyErr_Occurred ()) {
238
- PyErr_Clear ();
237
+ if (dict -> ma_keys -> dk_kind != DICT_KEYS_UNICODE ) {
239
238
return -1 ;
240
239
}
241
- if (getattr != NULL ) {
240
+ getattr = _PyUnicode_FromId (& PyId___getattr__ ); /* borrowed */
241
+ if (getattr == NULL ) {
242
+ PyErr_Clear ();
242
243
return -1 ;
243
244
}
244
- Py_hash_t hash = PyObject_Hash ( name );
245
- if ( hash == -1 ) {
246
- PyErr_Clear ();
245
+ Py_ssize_t index = _PyDict_GetItemHint ( dict , getattr , -1 , & value );
246
+ assert ( index != DKIX_ERROR );
247
+ if ( index != DKIX_EMPTY ) {
247
248
return -1 ;
248
249
}
249
- Py_ssize_t index = _Py_dict_lookup (dict , name , hash , & attr );
250
+ index = _PyDict_GetItemHint (dict , name , -1 , & value );
250
251
assert (index != DKIX_ERROR );
251
252
if (index != (uint16_t )index ) {
252
253
return -1 ;
You can’t perform that action at this time.
0 commit comments