Commit eb6b3320 authored by Jisi Liu's avatar Jisi Liu Committed by GitHub

Merge pull request #3412 from anandolee/3.4.x

Use keys() instead of iterkeys() to be python3 compatbile.
parents 72cc5a6e 9c012ed0
...@@ -819,7 +819,7 @@ def MapEncoder(field_descriptor): ...@@ -819,7 +819,7 @@ def MapEncoder(field_descriptor):
encode_message = MessageEncoder(field_descriptor.number, False, False) encode_message = MessageEncoder(field_descriptor.number, False, False)
def EncodeField(write, value, deterministic): 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: for key in value_keys:
entry_msg = message_type._concrete_class(key=key, value=value[key]) entry_msg = message_type._concrete_class(key=key, value=value[key])
encode_message(write, entry_msg, deterministic) encode_message(write, entry_msg, deterministic)
......
...@@ -166,6 +166,9 @@ class MessageTest(BaseTestCase): ...@@ -166,6 +166,9 @@ class MessageTest(BaseTestCase):
def __nonzero__(self): def __nonzero__(self):
raise BadArgError() raise BadArgError()
def __bool__(self):
raise BadArgError()
with self.assertRaises(BadArgError): with self.assertRaises(BadArgError):
golden_message.SerializeToString(deterministic=BadArg()) golden_message.SerializeToString(deterministic=BadArg())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment