From 73661563dbb82bf7fdd614dd8da1186c0acc6b17 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Fri, 4 Nov 2022 16:14:00 -0700 Subject: [PATCH] Added is_closed to EnumDescriptor in protobuf python upb PiperOrigin-RevId: 486253678 --- python/descriptor.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/descriptor.c b/python/descriptor.c index f721175d79..c8e72c8b12 100644 --- a/python/descriptor.c +++ b/python/descriptor.c @@ -730,6 +730,12 @@ static PyObject* PyUpb_EnumDescriptor_GetHasOptions(PyObject* _self, return PyBool_FromLong(upb_EnumDef_HasOptions(self->def)); } +static PyObject* PyUpb_EnumDescriptor_GetIsClosed(PyObject* _self, + void* closure) { + const upb_EnumDef* enumdef = PyUpb_EnumDescriptor_GetDef(_self); + return PyBool_FromLong(upb_EnumDef_IsClosed(enumdef)); +} + static PyObject* PyUpb_EnumDescriptor_GetOptions(PyObject* _self, PyObject* args) { PyUpb_DescriptorBase* self = (void*)_self; @@ -758,6 +764,8 @@ static PyGetSetDef PyUpb_EnumDescriptor_Getters[] = { {"containing_type", PyUpb_EnumDescriptor_GetContainingType, NULL, "Containing type"}, {"has_options", PyUpb_EnumDescriptor_GetHasOptions, NULL, "Has Options"}, + {"is_closed", PyUpb_EnumDescriptor_GetIsClosed, NULL, + "Checks if the enum is closed"}, {NULL}}; static PyMethodDef PyUpb_EnumDescriptor_Methods[] = {