avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [avro] branch master updated: Fix undefined variable field_desc_list in RecordSchema._MakeFieldMap (#355)
Date Tue, 11 Dec 2018 20:33:30 GMT
This is an automated email from the ASF dual-hosted git repository.

dkulp 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 c011d76  Fix undefined variable field_desc_list in RecordSchema._MakeFieldMap (#355)
c011d76 is described below

commit c011d76436a1c11c614a133ae06abbc19baf2436
Author: Stefaan Lippens <soxofaan@users.noreply.github.com>
AuthorDate: Tue Dec 11 21:33:26 2018 +0100

    Fix undefined variable field_desc_list in RecordSchema._MakeFieldMap (#355)
---
 lang/py3/avro/schema.py            |  2 +-
 lang/py3/avro/tests/test_schema.py | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lang/py3/avro/schema.py b/lang/py3/avro/schema.py
index 2fc7302..7ce2973 100644
--- a/lang/py3/avro/schema.py
+++ b/lang/py3/avro/schema.py
@@ -960,7 +960,7 @@ class RecordSchema(NamedSchema):
     for field in fields:
       if field.name in field_map:
         raise SchemaParseException(
-            'Duplicate field name %r in list %r.' % (field.name, field_desc_list))
+            'Duplicate record field name %r.' % field.name)
       field_map[field.name] = field
     return MappingProxyType(field_map)
 
diff --git a/lang/py3/avro/tests/test_schema.py b/lang/py3/avro/tests/test_schema.py
index fa70567..27b230b 100644
--- a/lang/py3/avro/tests/test_schema.py
+++ b/lang/py3/avro/tests/test_schema.py
@@ -635,6 +635,16 @@ class TestSchema(unittest.TestCase):
         self.assertEqual(type(v), list)
     self.assertEqual(correct,len(OTHER_PROP_EXAMPLES))
 
+  def testDuplicateRecordField(self):
+    schema_string = """{
+      "type": "record",
+      "name": "Test",
+      "fields": [{"name": "foo", "type": "int"}, {"name": "foo", "type": "string"}]
+    }"""
+    with self.assertRaises(schema.SchemaParseException) as e:
+      schema.Parse(schema_string)
+    self.assertRegexpMatches(str(e.exception), 'Duplicate.*field name.*foo')
+
 
 # ------------------------------------------------------------------------------
 


Mime
View raw message