Commits


Michael A. Smith authored and GitHub committed c8f953bc5e6
AVRO-3146: Fix Decimal Scale Exception Handling (#1228) Avro is supposed to check if the scale for a decimal logical schema is large enough for the datum to be written. But Python provides the exponent as negative, so the exponent is always less than the scale. This change corrects the comparison by ensuring scale and exponent have the same sign. In testing the above, avro attempts to raise AvroTypeException with improper arguments, leading to a secondary exception within the first. This change also fixes AvroTypeException so that it is flexible and won't crash when invoked with different arguments. It also adds a special AvroTypeException subtype to provide useful debugging details when a decimal schema tries to write a datum with an exponent that is too large. Finally, many test cases in Avro consist of running the same code over variations on pairs of schema and datum. But unittest exits at the first test failure! To get a comprehensive view of tests, even when some fail, I have refactored test_io so that individual test methods are generated over the set of test cases.