File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -300,18 +300,26 @@ _PyDict_DebugMallocStats(FILE *out)
300
300
301
301
static void free_keys_object (PyInterpreterState * interp , PyDictKeysObject * keys );
302
302
303
+ // XXX Switch to Py_INCREF()?
303
304
static inline void
304
305
dictkeys_incref (PyDictKeysObject * dk )
305
306
{
307
+ if (dk -> dk_refcnt == _Py_IMMORTAL_REFCNT ) {
308
+ return ;
309
+ }
306
310
#ifdef Py_REF_DEBUG
307
311
_Py_IncRefTotal (_PyInterpreterState_GET ());
308
312
#endif
309
313
dk -> dk_refcnt ++ ;
310
314
}
311
315
316
+ // XXX Switch to Py_DECREF()?
312
317
static inline void
313
318
dictkeys_decref (PyInterpreterState * interp , PyDictKeysObject * dk )
314
319
{
320
+ if (dk -> dk_refcnt == _Py_IMMORTAL_REFCNT ) {
321
+ return ;
322
+ }
315
323
assert (dk -> dk_refcnt > 0 );
316
324
#ifdef Py_REF_DEBUG
317
325
_Py_DecRefTotal (_PyInterpreterState_GET ());
@@ -447,7 +455,7 @@ estimate_log2_keysize(Py_ssize_t n)
447
455
* (which cannot fail and thus can do no allocation).
448
456
*/
449
457
static PyDictKeysObject empty_keys_struct = {
450
- 1 , /* dk_refcnt */
458
+ _Py_IMMORTAL_REFCNT , /* dk_refcnt */
451
459
0 , /* dk_log2_size */
452
460
0 , /* dk_log2_index_bytes */
453
461
DICT_KEYS_UNICODE , /* dk_kind */
You can’t perform that action at this time.
0 commit comments