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

ASF subversion and git services commented on AVRO-3252:
-------------------------------------------------------

Commit 895cdc8e2ebbf0341f292ff4ea684bf9cfbc68cb in avro's branch 
refs/heads/master from Chris Johns
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=895cdc8 ]

AVRO-3252: Add hasattr check for mode attr in DataFileReader (#1406)

The DataFileWriter class constructor checks for the presence of a mode 
attribute before accessing it, but the DataFileReader does not. This means that 
it is possible to use the DataFileWriter to write data to in memory binary 
streams using io.BytesIO, but it is not possible to read from them in the same 
manner. This commit adds the same check to the DataFileReader class.

> datafile reader fails with BytesIO stream on version 1.11
> ---------------------------------------------------------
>
>                 Key: AVRO-3252
>                 URL: https://issues.apache.org/jira/browse/AVRO-3252
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: python
>         Environment: Windows and Linux
> Python 3.6 to 3.9
> avro==1.11.0
>            Reporter: Florenz Hollebrandse
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.11.1
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code}
> >>> import io
> >>> import avro.datafile
> >>> import avro.io
> >>> data = io.BytesIO()
> >>> datum_reader = avro.io.DatumReader()
> >>> avro.datafile.DataFileReader(data, datum_reader)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "I:\tmpenv\lib\site-packages\avro\datafile.py", line 318, in __init__
>     if "b" not in reader.mode:
> AttributeError: '_io.BytesIO' object has no attribute 'mode'
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to