From a484794820e3e83caa7ca7e78270c84b75cde21a Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Mon, 24 Jul 2017 15:44:16 -0700 Subject: Use keys() instead of iterkeys() to be python3 compatbile. --- python/google/protobuf/internal/encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') diff --git a/python/google/protobuf/internal/encoder.py b/python/google/protobuf/internal/encoder.py index f8c36390..ebec42e5 100755 --- a/python/google/protobuf/internal/encoder.py +++ b/python/google/protobuf/internal/encoder.py @@ -819,7 +819,7 @@ def MapEncoder(field_descriptor): encode_message = MessageEncoder(field_descriptor.number, False, False) def EncodeField(write, value, deterministic): - value_keys = sorted(value.iterkeys()) if deterministic else value.iterkeys() + value_keys = sorted(value.keys()) if deterministic else value.keys() for key in value_keys: entry_msg = message_type._concrete_class(key=key, value=value[key]) encode_message(write, entry_msg, deterministic) -- cgit v1.2.3 From 9c012ed07d9bea4ac7012a9e697488ccde00c398 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Mon, 24 Jul 2017 16:42:23 -0700 Subject: Add __bool__ as well as __nonzero__ for python3 --- python/google/protobuf/internal/message_test.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'python') diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index 6f60586a..29a515b2 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -166,6 +166,9 @@ class MessageTest(BaseTestCase): def __nonzero__(self): raise BadArgError() + def __bool__(self): + raise BadArgError() + with self.assertRaises(BadArgError): golden_message.SerializeToString(deterministic=BadArg()) -- cgit v1.2.3