@@ -685,8 +685,10 @@ static void PyUpb_Message_SyncSubobjs(PyUpb_Message* self);
685685 * the set state (having a non-owning pointer to self->ptr.msg).
686686 */
687687static void PyUpb_Message_Reify (PyUpb_Message * self , const upb_FieldDef * f ,
688- upb_Message * msg ) {
688+ upb_Message * msg , PyUpb_WeakMap * subobj_map ,
689+ intptr_t iter ) {
689690 assert (f == PyUpb_Message_GetFieldDef (self ));
691+ PyUpb_WeakMap_DeleteIter (subobj_map , & iter );
690692 if (!msg ) {
691693 const upb_MessageDef * msgdef = PyUpb_Message_GetMsgdef ((PyObject * )self );
692694 const upb_MiniTable * layout = upb_MessageDef_MiniTable (msgdef );
@@ -738,17 +740,18 @@ static void PyUpb_Message_SyncSubobjs(PyUpb_Message* self) {
738740 if (upb_FieldDef_HasPresence (f ) && !upb_Message_HasFieldByDef (msg , f ))
739741 continue ;
740742 upb_MessageValue msgval = upb_Message_GetFieldByDef (msg , f );
741- PyUpb_WeakMap_DeleteIter (subobj_map , & iter );
742743 if (upb_FieldDef_IsMap (f )) {
743744 if (!msgval .map_val ) continue ;
744- PyUpb_MapContainer_Reify (obj , (upb_Map * )msgval .map_val );
745+ PyUpb_MapContainer_Reify (obj , (upb_Map * )msgval .map_val , subobj_map , iter );
745746 } else if (upb_FieldDef_IsRepeated (f )) {
746747 if (!msgval .array_val ) continue ;
747- PyUpb_RepeatedContainer_Reify (obj , (upb_Array * )msgval .array_val );
748+ PyUpb_RepeatedContainer_Reify (obj , (upb_Array * )msgval .array_val ,
749+ subobj_map , iter );
748750 } else {
749751 PyUpb_Message * sub = (void * )obj ;
750752 assert (self == sub -> ptr .parent );
751- PyUpb_Message_Reify (sub , f , (upb_Message * )msgval .msg_val );
753+ PyUpb_Message_Reify (sub , f , (upb_Message * )msgval .msg_val , subobj_map ,
754+ iter );
752755 }
753756 }
754757
@@ -1404,18 +1407,17 @@ static PyObject* PyUpb_Message_Clear(PyUpb_Message* self) {
14041407
14051408 while (PyUpb_WeakMap_Next (subobj_map , & key , & obj , & iter )) {
14061409 const upb_FieldDef * f = key ;
1407- PyUpb_WeakMap_DeleteIter (subobj_map , & iter );
14081410 if (upb_FieldDef_IsMap (f )) {
14091411 assert (upb_Message_GetFieldByDef (msg , f ).map_val == NULL );
1410- PyUpb_MapContainer_Reify (obj , NULL );
1412+ PyUpb_MapContainer_Reify (obj , NULL , subobj_map , iter );
14111413 } else if (upb_FieldDef_IsRepeated (f )) {
14121414 assert (upb_Message_GetFieldByDef (msg , f ).array_val == NULL );
1413- PyUpb_RepeatedContainer_Reify (obj , NULL );
1415+ PyUpb_RepeatedContainer_Reify (obj , NULL , subobj_map , iter );
14141416 } else {
14151417 assert (!upb_Message_HasFieldByDef (msg , f ));
14161418 PyUpb_Message * sub = (void * )obj ;
14171419 assert (self == sub -> ptr .parent );
1418- PyUpb_Message_Reify (sub , f , NULL );
1420+ PyUpb_Message_Reify (sub , f , NULL , subobj_map , iter );
14191421 }
14201422 }
14211423 }
0 commit comments