Added extension field numbers.

pull/13171/head
Joshua Haberman 3 years ago
parent c75b39fc4d
commit 8af637bcd2
  1. 21
      python/message.c
  2. 1
      python/pb_unit_tests/reflection_test_wrapper.py

@ -1614,6 +1614,15 @@ static void PyUpb_MessageMeta_Dealloc(PyObject* self) {
PyUpb_Dealloc(self);
}
void PyUpb_MessageMeta_AddFieldNumber(PyObject* self, const upb_fielddef* f) {
PyObject* name =
PyUnicode_FromFormat("%s_FIELD_NUMBER", upb_fielddef_name(f));
PyObject* upper = PyObject_CallMethod(name, "upper", "");
PyObject_SetAttr(self, upper, PyLong_FromLong(upb_fielddef_number(f)));
Py_DECREF(name);
Py_DECREF(upper);
}
static PyObject* PyUpb_MessageMeta_GetDynamicAttr(PyObject* self,
PyObject* name) {
const char* name_buf = PyUpb_GetStrData(name);
@ -1655,13 +1664,11 @@ static PyObject* PyUpb_MessageMeta_GetDynamicAttr(PyObject* self,
// So we just add all field numbers.
int n = upb_msgdef_fieldcount(msgdef);
for (int i = 0; i < n; i++) {
const upb_fielddef* f = upb_msgdef_field(msgdef, i);
PyObject* name = PyUnicode_FromFormat(
"%s_FIELD_NUMBER", upb_fielddef_name(f));
PyObject* upper = PyObject_CallMethod(name, "upper", "");
PyObject_SetAttr(self, upper, PyLong_FromLong(upb_fielddef_number(f)));
Py_DECREF(name);
Py_DECREF(upper);
PyUpb_MessageMeta_AddFieldNumber(self, upb_msgdef_field(msgdef, i));
}
n = upb_msgdef_nestedextcount(msgdef);
for (int i = 0; i < n; i++) {
PyUpb_MessageMeta_AddFieldNumber(self, upb_msgdef_nestedext(msgdef, i));
}
ret = PyObject_GenericGetAttr(self, name);
}

@ -37,7 +37,6 @@ reflection_test.ReflectionTest.testDeepCopy_proto2.__unittest_expecting_failure_
reflection_test.ReflectionTest.testDeepCopy_proto3.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testCanonicalSerializationOrder.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testCanonicalSerializationOrderSameAsCpp.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testExtensionFieldNumbers.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testFieldDataDescriptor.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testFieldProperties.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testInitArgsUnknownFieldName.__unittest_expecting_failure__ = True

Loading…
Cancel
Save