Fixed Python+upb to use ScalarMapContainer when appropriate.

PiperOrigin-RevId: 457980556
pull/13171/head
Joshua Haberman 3 years ago committed by Copybara-Service
parent b6f862bf9f
commit 16daf910cc
  1. 8
      python/map.c

@ -30,6 +30,7 @@
#include "python/convert.h"
#include "python/message.h"
#include "python/protobuf.h"
#include "upb/def.h"
#include "upb/map.h"
// -----------------------------------------------------------------------------
@ -84,8 +85,11 @@ static void PyUpb_MapContainer_Dealloc(void* _self) {
PyTypeObject* PyUpb_MapContainer_GetClass(const upb_FieldDef* f) {
assert(upb_FieldDef_IsMap(f));
PyUpb_ModuleState* state = PyUpb_ModuleState_Get();
return upb_FieldDef_IsSubMessage(f) ? state->message_map_container_type
: state->scalar_map_container_type;
const upb_FieldDef* val =
upb_MessageDef_Field(upb_FieldDef_MessageSubDef(f), 1);
assert(upb_FieldDef_Number(val) == 2);
return upb_FieldDef_IsSubMessage(val) ? state->message_map_container_type
: state->scalar_map_container_type;
}
PyObject* PyUpb_MapContainer_NewStub(PyObject* parent, const upb_FieldDef* f,

Loading…
Cancel
Save