Accept bytes object as field name.
diff --git a/python/message.c b/python/message.c
index 46212ac..02fb902 100644
--- a/python/message.c
+++ b/python/message.c
@@ -243,7 +243,12 @@
PyObject* exc_type) {
assert(f || o);
Py_ssize_t size;
- const char* name = PyUnicode_AsUTF8AndSize(py_name, &size);
+ const char* name = NULL;
+ if (PyUnicode_Check(py_name)) {
+ name = PyUnicode_AsUTF8AndSize(py_name, &size);
+ } else if (PyBytes_Check(py_name)) {
+ PyBytes_AsStringAndSize(py_name, (char**)&name, &size);
+ }
if (!name) return NULL;
const upb_msgdef* msgdef = _PyUpb_CMessage_GetMsgdef(self);
diff --git a/python/pb_unit_tests/reflection_test_wrapper.py b/python/pb_unit_tests/reflection_test_wrapper.py
index a2ec36b..1a7cfd4 100644
--- a/python/pb_unit_tests/reflection_test_wrapper.py
+++ b/python/pb_unit_tests/reflection_test_wrapper.py
@@ -33,8 +33,6 @@
reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForOptionalMessage.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForRepeatedMessage.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForRepeatedScalar.__unittest_expecting_failure__ = True
-reflection_test.ReflectionTest.testClearFieldWithUnknownFieldName_proto2.__unittest_expecting_failure__ = True
-reflection_test.ReflectionTest.testClearFieldWithUnknownFieldName_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testDeepCopy_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testDeepCopy_proto3.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testCanonicalSerializationOrder.__unittest_expecting_failure__ = True