GitHub user zah opened a pull request:
https://github.com/apache/avro/pull/220
Fix an incorrect string comparison in avro-python3 leading to corrupted
files
The corrected code was trying to compare the bytes value returned by
GetMeta against a string.
The if was never taken and this was leading to corrupted files when the
snappy codes is used.
Here is a minimal test case that demonstrates the issue:
``` python
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter
schema_text = """
{
"namespace": "example.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}
]
}
"""
schema = avro.schema.Parse(schema_text)
writer = DataFileWriter(open("users.avro", "wb"), DatumWriter(), schema,
codec="snappy")
writer.append({"name": "Alyssa", "favorite_number": 256})
writer.append({"name": "Ben", "favorite_number": 7, "favorite_color":
"red"})
writer.close()
reader = DataFileReader(open("users.avro", "rb"), DatumReader())
for user in reader:
print(user)
reader.close()
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sixsentsinc/avro avro-python3-snappy-codec-fix
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/avro/pull/220.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #220
----
commit 7469c461022b3e94581821b280f4cb0b6dfc28ad
Author: Zahary Karadjov <[email protected]>
Date: 2017-04-22T17:45:40Z
Fix an incorrect string comparison in avro-python3
The corrected code was trying to compare the bytes value returned by
GetMeta against a string.
The if was never taken and this was leading to corrupted files when the
snappy codes is used.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---