[ 
https://issues.apache.org/jira/browse/AVRO-2591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16955519#comment-16955519
 ] 

Michael A. Smith commented on AVRO-2591:
----------------------------------------

Tried to make a comment and Jira apparently thought I was typing hotkeys. Sorry 
for the assign/unassign spam. Anyway, I was going to say that this problem 
looks suspiciously like what I see when I try to use BytesIO instead of 
StringIO in the Python 2 code in order to make that codebase more future 
compatible. There's something fishy here and I might end up finding it in the 
python2 codebase.

 

Is there any way you can see if you can reproduce this in the python2 codebase? 
Or, another thing that would be informative is if you can run the python3 unit 
tests in Windows and show the results? I don't have a Windows environment to 
test in.

> Getting error when reading avro message python
> ----------------------------------------------
>
>                 Key: AVRO-2591
>                 URL: https://issues.apache.org/jira/browse/AVRO-2591
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: python
>    Affects Versions: 1.9.1
>         Environment: Windows
>            Reporter: Alperen Koksel
>            Priority: Major
>
> I can't read avro messages in python in windows environment. 
> We 're using avro templates on kafka. I get the avro serialized message using 
> kafkaconsumer but I can't deserialize using avro.io.
>  
> {code:java}
> // code placeholder
> schema_path = "x.avsc"
> schema = avro.schema.Parse(open(schema_path).read())
> def from_avro(msg):
>     bytes_reader = io.BytesIO(msg)
>     decoder = avro.io.BinaryDecoder(bytes_reader)
>     reader = avro.io.DatumReader(schema, schema)
>     user1 = reader.read(decoder)
>     return user1
> consumer = KafkaConsumer('avro_topic',
>                          bootstrap_servers=['0.dual.kafka.qa-us.com:9092',
>                                             '1.dual.kafka.qa-us.com:9092',
>                                             '2.dual.kafka.qa-us.com:9092'],
>                          auto_offset_reset='earliest',
>                          group_id='my_group',
>                          value_deserializer=from_avro
>                          )
> for msg in consumer:
>     print(msg){code}
>  
> {code:java}
> // code placeholder
> File 
> "C:\Users\alpl\PycharmProjects\WorkOn\venv\lib\site-packages\avro\io.py", 
> line 240, in read_bytes
>  assert (nbytes >= 0), nbytes
> AssertionError: -45
> {code}
>  
> I found following stackoverflow post which posted more than a year ago.
> [https://stackoverflow.com/questions/50106662/error-reading-avro-file-in-python/58336209#58336209]
> I tried several versions of avro. Results are same.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to