You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/02/11 10:21:00 UTC

[jira] [Commented] (AVRO-3380) Byte reading in avro.io does not assert read bytes to requested nbytes

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

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

Commit 5c645aefadaadacaa19c268db46df5c20e7908af in avro's branch refs/heads/master from Jarkko Jaakola
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=5c645ae ]

AVRO-3380: Raise an exception if invalid number of bytes read (#1529)

* AVRO-3380: Raise an exception if invalid number of bytes read

The Python Avro 1.10.0 Python 3 compatibility layer had assertion
for read bytes to match the expected number of bytes.
In cases where schema is incompatible between reader and writer,
or something unexpected happens, the bytes read is less than
expected and BytesIO position can be at the end of the buffer.
This causes for example a TypeError if field expected is int/long
as ord() is called with zero data.

* AVRO-3380: Rename InvalidBytesRead error to InvalidAvroBinaryEncoding

* AVRO-3380: Raise InvalidAvroByteEncoding if < 0 bytes requested for read

* AVRO-3380: Remove InvalidAvroByteEncoding catch in read_data

> Byte reading in avro.io does not assert read bytes to requested nbytes
> ----------------------------------------------------------------------
>
>                 Key: AVRO-3380
>                 URL: https://issues.apache.org/jira/browse/AVRO-3380
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: python
>    Affects Versions: 1.11.0
>            Reporter: Jarkko Jaakola
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> The Python 3 compatibility layer in version 1.10.0 asserted the number of read bytes to match the requested number.
> In version 1.11.0 the read returns what is available and just progresses. This can be problem when having incompatible schemas or some other unexpected condition.
> 1.10.0 implementation: [https://github.com/apache/avro/blob/release-1.10.0/lang/py3/avro/io.py#L158]
> 1.11.0 implementation: [https://github.com/apache/avro/blob/443614c12a15bb58fcf2487eb67ca6f885a68f96/lang/py/avro/io.py#L225]
>  



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