Added missing conversion of message values.

pull/13171/head
Joshua Haberman 3 years ago
parent 80776e363d
commit 55a24d94d3
  1. 6
      python/convert.c
  2. 27
      python/pb_unit_tests/message_test_wrapper.py
  3. 9
      python/pb_unit_tests/reflection_test_wrapper.py
  4. 17
      python/pb_unit_tests/text_format_test_wrapper.py
  5. 1
      python/pb_unit_tests/well_known_types_test_wrapper.py

@ -27,6 +27,7 @@
#include "python/convert.h"
#include "python/message.h"
#include "python/protobuf.h"
#include "upb/reflection.h"
#include "upb/util/compare.h"
@ -53,9 +54,8 @@ PyObject* PyUpb_UpbToPy(upb_msgval val, const upb_fielddef *f, PyObject *arena)
case UPB_TYPE_STRING:
return PyUnicode_DecodeUTF8(val.str_val.data, val.str_val.size, NULL);
case UPB_TYPE_MESSAGE:
PyErr_Format(PyExc_NotImplementedError,
"Conversion of message types not yet implemented");
return NULL;
return PyUpb_CMessage_Get((upb_msg*)val.msg_val,
upb_fielddef_msgsubdef(f), arena);
default:
PyErr_Format(PyExc_SystemError,
"Getting a value from a field of unknown type %d",

@ -26,8 +26,6 @@
from google.protobuf.internal import message_test
import unittest
message_test.MessageTest.testAppendRepeatedCompositeField_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testAppendRepeatedCompositeField_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testBadUtf8String_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testBadUtf8String_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testExtendFloatWithNothing_proto2.__unittest_expecting_failure__ = True
@ -46,38 +44,15 @@ message_test.MessageTest.testHighPrecisionDoublePrinting_proto2.__unittest_expec
message_test.MessageTest.testHighPrecisionDoublePrinting_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testInsertRepeatedCompositeField_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testInsertRepeatedCompositeField_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testLongValuedSlice_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testLongValuedSlice_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFromRepeatedField_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFromRepeatedField_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFromString_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFromString_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFrom_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testMergeFrom_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testOneofMessageMergeFrom_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testOneofMessageMergeFrom_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testOneofNestedMergeFrom_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testOneofNestedMergeFrom_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleNestedMessage_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleNestedMessage_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleNestedNestedMessage_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleNestedNestedMessage_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleSupport_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleSupport_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedCompositeFieldPop_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedCompositeFieldPop_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedCompositeFieldSortArguments_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedCompositeFieldSortArguments_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedContains_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedContains_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedNestedFieldIteration_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testRepeatedNestedFieldIteration_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testSortingRepeatedCompositeFieldsCustomComparator_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testSortingRepeatedCompositeFieldsCustomComparator_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testSortingRepeatedCompositeFieldsStable_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testSortingRepeatedCompositeFieldsStable_proto3.__unittest_expecting_failure__ = True
message_test.Proto2Test.testExtensionsErrors.__unittest_expecting_failure__ = True
message_test.Proto2Test.testFieldPresence.__unittest_expecting_failure__ = True
message_test.Proto2Test.testGoldenExtensions.__unittest_expecting_failure__ = True
message_test.Proto2Test.testGoldenPackedExtensions.__unittest_expecting_failure__ = True
message_test.Proto2Test.testMergeFromExtensions.__unittest_expecting_failure__ = True
@ -87,7 +62,6 @@ message_test.Proto2Test.testPythonicInit.__unittest_expecting_failure__ = True
message_test.Proto2Test.testUnknownEnumMap.__unittest_expecting_failure__ = True
message_test.Proto2Test.test_documentation.__unittest_expecting_failure__ = True
message_test.Proto3Test.testCopyFromBadType.__unittest_expecting_failure__ = True
message_test.Proto3Test.testFieldPresence.__unittest_expecting_failure__ = True
message_test.Proto3Test.testIntegerMapWithLongs.__unittest_expecting_failure__ = True
message_test.Proto3Test.testMapAssignmentCausesPresence.__unittest_expecting_failure__ = True
message_test.Proto3Test.testMapAssignmentCausesPresenceForSubmessages.__unittest_expecting_failure__ = True
@ -116,7 +90,6 @@ message_test.Proto3Test.testMessageMapItemValidAfterTopMessageCleared.__unittest
message_test.Proto3Test.testMessageMapValidAfterFieldCleared.__unittest_expecting_failure__ = True
message_test.Proto3Test.testModifyMapWhileIterating.__unittest_expecting_failure__ = True
message_test.Proto3Test.testNestedMessageMapItemDelete.__unittest_expecting_failure__ = True
message_test.Proto3Test.testProto3Optional.__unittest_expecting_failure__ = True
message_test.Proto3Test.testProto3ParserDropDefaultScalar.__unittest_expecting_failure__ = True
message_test.Proto3Test.testScalarMap.__unittest_expecting_failure__ = True
message_test.Proto3Test.testScalarMapDefaults.__unittest_expecting_failure__ = True

@ -42,21 +42,17 @@ reflection_test.MutualRecursionEqualityTest.testEqualityWithMutualRecursion.__un
reflection_test.OptionsTest.testMessageOptions.__unittest_expecting_failure__ = True
reflection_test.OptionsTest.testPackedOptions.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testClear.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testDisconnectingInOneof.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testDisconnectionAfterClearingEmptyMessage.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testExtensionContainsError.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testExtensionDelete.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testExtensionFailureModes.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testExtensionIter.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testHasBitsForAncestorsOfExtendedMessage.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testHasBitsForManyLevelsOfNesting.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testHasBitsWhenModifyingRepeatedFields.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testIsInitialized.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testListFieldsAndExtensions.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testMergeFromExtensionsNestedMessage.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testMergeFromExtensionsRepeated.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testMergeFromExtensionsSingular.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testMergeFromOptionalGroup.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testNestedExtensions.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testRegisteredExtensions.__unittest_expecting_failure__ = True
reflection_test.Proto2ReflectionTest.testRepeatedCompositeConstructor.__unittest_expecting_failure__ = True
@ -95,12 +91,8 @@ reflection_test.ReflectionTest.testIllegalValuesForIntegers_proto2.__unittest_ex
reflection_test.ReflectionTest.testIllegalValuesForIntegers_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMergeFromAllFields_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMergeFromAllFields_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMergeFromRepeatedNestedMessage_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMergeFromRepeatedNestedMessage_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMixedConstructor_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testMixedConstructor_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testOneOf_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testOneOf_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testRepeatedListFields_proto2.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testRepeatedListFields_proto3.__unittest_expecting_failure__ = True
reflection_test.ReflectionTest.testRepeatedScalarTypeSafety_proto2.__unittest_expecting_failure__ = True
@ -122,7 +114,6 @@ reflection_test.SerializationTest.testInitKwargs.__unittest_expecting_failure__
reflection_test.SerializationTest.testInitRepeatedKwargs.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testInitRequiredForeignKwargs.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testInitRequiredKwargs.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testMergeFromStringWhenFieldsAlreadySet.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testMessageSetWireFormat.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testMessageSetWireFormatUnknownExtension.__unittest_expecting_failure__ = True
reflection_test.SerializationTest.testParsePackedFromUnpacked.__unittest_expecting_failure__ = True

@ -74,7 +74,6 @@ text_format_test.Proto3Tests.testMergeExpandedAnyDescriptorPoolMissingType.__uni
text_format_test.Proto3Tests.testMergeExpandedAnyPointyBrackets.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testMergeExpandedAnyRepeated.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testMergeMissingAnyEndToken.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testMergeUnexpandedAny.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testPrintAndParseMessageInvalidAny.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testPrintMessageExpandAny.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testPrintMessageExpandAnyAsOneLine.__unittest_expecting_failure__ = True
@ -85,14 +84,6 @@ text_format_test.Proto3Tests.testPrintMessageExpandAnyRepeated.__unittest_expect
text_format_test.Proto3Tests.testProto3Optional.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testTopAnyMessage.__unittest_expecting_failure__ = True
text_format_test.Proto3Tests.testUnknownEnums.__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "0").__unittest_expecting_failure__ = True
@ -181,14 +172,6 @@ getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "0").__
getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "1").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "0").__unittest_expecting_failure__ = True
getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "1").__unittest_expecting_failure__ = True
# We must skip these tests entirely (rather than running them with
# __unittest_expecting_failure__) because they error out in setUp():

@ -29,7 +29,6 @@ import unittest
well_known_types_test.AnyTest.testAnyMessage.__unittest_expecting_failure__ = True
well_known_types_test.AnyTest.testPackDeterministic.__unittest_expecting_failure__ = True
well_known_types_test.AnyTest.testPackWithCustomTypeUrl.__unittest_expecting_failure__ = True
well_known_types_test.AnyTest.testUnpackWithNoSlashInTypeUrl.__unittest_expecting_failure__ = True
well_known_types_test.FieldMaskTest.testMergeMessageWithMapField.__unittest_expecting_failure__ = True
well_known_types_test.FieldMaskTest.testMergeMessageWithoutMapFields.__unittest_expecting_failure__ = True
well_known_types_test.StructTest.testMergeFrom.__unittest_expecting_failure__ = True

Loading…
Cancel
Save