Added extension field numbers.
diff --git a/python/message.c b/python/message.c index 02fb902..3c77828 100644 --- a/python/message.c +++ b/python/message.c
@@ -1614,6 +1614,15 @@ 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 @@ // 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); }
diff --git a/python/pb_unit_tests/reflection_test_wrapper.py b/python/pb_unit_tests/reflection_test_wrapper.py index 1a7cfd4..f9765d5 100644 --- a/python/pb_unit_tests/reflection_test_wrapper.py +++ b/python/pb_unit_tests/reflection_test_wrapper.py
@@ -37,7 +37,6 @@ 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