diff -r 10b965d59b49 Objects/odictobject.c --- a/Objects/odictobject.c Thu Oct 22 20:19:14 2015 +0300 +++ b/Objects/odictobject.c Thu Oct 22 22:13:48 2015 +0300 @@ -481,10 +481,12 @@ struct _odictobject { PyDictObject od_dict; /* the underlying dict */ _ODictNode *od_first; /* first node in the linked list, if any */ _ODictNode *od_last; /* last node in the linked list, if any */ - /* od_fast_nodes and od_resize_sentinel are managed by _odict_resize() + /* od_fast_nodes, od_resize_sentinel and od_resize_sentinel2 are managed + * by _odict_resize(). * Note that we rely on implementation details of dict for both. */ _ODictNode **od_fast_nodes; /* hash table that mirrors the dict table */ - Py_uintptr_t od_resize_sentinel; /* changes if odict should be resized */ + void *od_resize_sentinel; /* changes if odict should be resized */ + Py_ssize_t od_resize_sentinel2; /* changes if odict should be resized */ size_t od_state; /* incremented whenever the LL changes */ PyObject *od_inst_dict; /* OrderedDict().__dict__ */ @@ -573,7 +575,8 @@ static int /* Replace the old fast nodes table. */ _odict_free_fast_nodes(od); od->od_fast_nodes = fast_nodes; - od->od_resize_sentinel = (Py_uintptr_t)(((PyDictObject *)od)->ma_keys); + od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys; + od->od_resize_sentinel2 = ((PyDictObject *)od)->ma_keys->dk_size; return 0; } @@ -591,7 +594,8 @@ static Py_ssize_t keys = ((PyDictObject *)od)->ma_keys; /* Ensure od_fast_nodes and dk_entries are in sync. */ - if (od->od_resize_sentinel != (Py_uintptr_t)keys) { + if (od->od_resize_sentinel != keys || + od->od_resize_sentinel2 != keys->dk_size) { int resize_res = _odict_resize(od); if (resize_res < 0) return -1;