avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kojirom...@apache.org
Subject [avro] branch master updated: AVRO-2741: Fix Protocol.fullname Crash (#812)
Date Sat, 15 Feb 2020 16:30:35 GMT
This is an automated email from the ASF dual-hosted git repository.

kojiromike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new a439bf9  AVRO-2741: Fix Protocol.fullname Crash (#812)
a439bf9 is described below

commit a439bf96f922fb065aed4fa8eb9f0fc43223482b
Author: Michael A. Smith <michael@smith-li.com>
AuthorDate: Sat Feb 15 11:30:26 2020 -0500

    AVRO-2741: Fix Protocol.fullname Crash (#812)
---
 lang/py/avro/protocol.py           | 41 ++++++++++++++++++++++++++++----------
 lang/py/avro/test/test_protocol.py |  1 +
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/lang/py/avro/protocol.py b/lang/py/avro/protocol.py
index c41ad0c..e5dc22e 100644
--- a/lang/py/avro/protocol.py
+++ b/lang/py/avro/protocol.py
@@ -113,16 +113,37 @@ class Protocol(object):
     self._md5 = hashlib.md5(str(self).encode()).digest()
 
   # read-only properties
-  name = property(lambda self: self.get_prop('name'))
-  namespace = property(lambda self: self.get_prop('namespace'))
-  fullname = property(lambda self:
-                      avro.schema.Name(self.name, self.namespace).fullname)
-  types = property(lambda self: self.get_prop('types'))
-  types_dict = property(lambda self: dict([(type.name, type)
-                                           for type in self.types]))
-  messages = property(lambda self: self.get_prop('messages'))
-  md5 = property(lambda self: self._md5)
-  props = property(lambda self: self._props)
+  @property
+  def name(self):
+    return self.get_prop('name')
+
+  @property
+  def namespace(self):
+    return self.get_prop('namespace')
+
+  @property
+  def fullname(self):
+    return avro.schema.Name(self.name, self.namespace, None).fullname
+
+  @property
+  def types(self):
+    return self.get_prop('types')
+
+  @property
+  def types_dict(self):
+    return {type.name: type for type in self.types}
+
+  @property
+  def messages(self):
+    return self.get_prop('messages')
+
+  @property
+  def md5(self):
+    return self._md5
+
+  @property
+  def props(self):
+    return self._props
 
   # utility functions to manipulate properties dict
   def get_prop(self, key):
diff --git a/lang/py/avro/test/test_protocol.py b/lang/py/avro/test/test_protocol.py
index aa24620..551c667 100644
--- a/lang/py/avro/test/test_protocol.py
+++ b/lang/py/avro/test/test_protocol.py
@@ -274,6 +274,7 @@ class TestMisc(unittest.TestCase):
     print('')
     proto = HELLO_WORLD.parse()
     self.assertEqual(proto.namespace, "com.acme")
+    self.assertEqual(proto.fullname, "com.acme.HelloWorld")
     greeting_type = proto.types_dict['Greeting']
     self.assertEqual(greeting_type.namespace, 'com.acme')
 


Mime
View raw message