@@ -481,10 +481,12 @@ struct _odictobject {
481
481
PyDictObject od_dict ; /* the underlying dict */
482
482
_ODictNode * od_first ; /* first node in the linked list, if any */
483
483
_ODictNode * od_last ; /* last node in the linked list, if any */
484
- /* od_fast_nodes and od_resize_sentinel are managed by _odict_resize()
484
+ /* od_fast_nodes, od_fast_nodes_size and od_resize_sentinel are managed
485
+ * by _odict_resize().
485
486
* Note that we rely on implementation details of dict for both. */
486
487
_ODictNode * * od_fast_nodes ; /* hash table that mirrors the dict table */
487
- Py_uintptr_t od_resize_sentinel ; /* changes if odict should be resized */
488
+ Py_ssize_t od_fast_nodes_size ;
489
+ void * od_resize_sentinel ; /* changes if odict should be resized */
488
490
489
491
size_t od_state ; /* incremented whenever the LL changes */
490
492
PyObject * od_inst_dict ; /* OrderedDict().__dict__ */
@@ -573,7 +575,8 @@ _odict_resize(PyODictObject *od) {
573
575
/* Replace the old fast nodes table. */
574
576
_odict_free_fast_nodes (od );
575
577
od -> od_fast_nodes = fast_nodes ;
576
- od -> od_resize_sentinel = (Py_uintptr_t )(((PyDictObject * )od )-> ma_keys );
578
+ od -> od_fast_nodes_size = size ;
579
+ od -> od_resize_sentinel = ((PyDictObject * )od )-> ma_keys ;
577
580
return 0 ;
578
581
}
579
582
@@ -591,7 +594,8 @@ _odict_get_index(PyODictObject *od, PyObject *key)
591
594
keys = ((PyDictObject * )od )-> ma_keys ;
592
595
593
596
/* Ensure od_fast_nodes and dk_entries are in sync. */
594
- if (od -> od_resize_sentinel != (Py_uintptr_t )keys ) {
597
+ if (od -> od_resize_sentinel != keys ||
598
+ od -> od_fast_nodes_size != keys -> dk_size ) {
595
599
int resize_res = _odict_resize (od );
596
600
if (resize_res < 0 )
597
601
return -1 ;
0 commit comments