You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2010/10/08 23:21:05 UTC
svn commit: r1006028 - in /avro/branches/branch-1.4: ./ CHANGES.txt
lang/py/src/avro/io.py lang/py/test/test_io.py
Author: cutting
Date: Fri Oct 8 21:21:04 2010
New Revision: 1006028
URL: http://svn.apache.org/viewvc?rev=1006028&view=rev
Log:
Merge r1006021 and 1006025 from trunk to 1.4 branch. Fixes: AVRO-673.
Modified:
avro/branches/branch-1.4/ (props changed)
avro/branches/branch-1.4/CHANGES.txt
avro/branches/branch-1.4/lang/py/src/avro/io.py
avro/branches/branch-1.4/lang/py/test/test_io.py
Propchange: avro/branches/branch-1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 8 21:21:04 2010
@@ -1 +1 @@
-/avro/trunk:990852,990860,990867,990871,990878,991031,991423,992146,992149,992167,996640,996642,996649,996877,997962,998347,998354,999554,999556,1006019
+/avro/trunk:990852,990860,990867,990871,990878,991031,991423,992146,992149,992167,996640,996642,996649,996877,997962,998347,998354,999554,999556,1006019,1006021,1006025
Modified: avro/branches/branch-1.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/CHANGES.txt?rev=1006028&r1=1006027&r2=1006028&view=diff
==============================================================================
--- avro/branches/branch-1.4/CHANGES.txt (original)
+++ avro/branches/branch-1.4/CHANGES.txt Fri Oct 8 21:21:04 2010
@@ -9,6 +9,11 @@ Avro 1.4.1 (unreleased)
AVRO-634. Java: Add support for reading Hadoop sequence files as
Avro data to MapReduce API. (cutting)
+ OPTIMIZATIONS
+
+ AVRO-673. Python: Remove unneeded schema validations.
+ (Erik Frey via cutting)
+
IMPROVEMENTS
AVRO-655. Change build so that 'dist' target no longer also runs C
Modified: avro/branches/branch-1.4/lang/py/src/avro/io.py
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/py/src/avro/io.py?rev=1006028&r1=1006027&r2=1006028&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/py/src/avro/io.py (original)
+++ avro/branches/branch-1.4/lang/py/src/avro/io.py Fri Oct 8 21:21:04 2010
@@ -743,13 +743,13 @@ class DatumWriter(object):
set_writers_schema)
def write(self, datum, encoder):
+ # validate datum
+ if not validate(self.writers_schema, datum):
+ raise AvroTypeException(self.writers_schema, datum)
+
self.write_data(self.writers_schema, datum, encoder)
def write_data(self, writers_schema, datum, encoder):
- # validate datum
- if not validate(writers_schema, datum):
- raise AvroTypeException(writers_schema, datum)
-
# function dispatch to write datum
if writers_schema.type == 'null':
encoder.write_null(datum)
Modified: avro/branches/branch-1.4/lang/py/test/test_io.py
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/py/test/test_io.py?rev=1006028&r1=1006027&r2=1006028&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/py/test/test_io.py (original)
+++ avro/branches/branch-1.4/lang/py/test/test_io.py Fri Oct 8 21:21:04 2010
@@ -324,5 +324,14 @@ class TestIO(unittest.TestCase):
print 'Datum Read: %s' % datum_read
self.assertEquals(datum_to_read, datum_read)
+ def test_type_exception(self):
+ print_test_name('TEST TYPE EXCEPTION')
+ writers_schema = schema.parse("""\
+ {"type": "record", "name": "Test",
+ "fields": [{"name": "F", "type": "int"},
+ {"name": "E", "type": "int"}]}""")
+ datum_to_write = {'E': 5, 'F': 'Bad'}
+ self.assertRaises(io.AvroTypeException, write_datum, datum_to_write, writers_schema)
+
if __name__ == '__main__':
unittest.main()