Skip to content

ChainedStream.read() with the default size raises TypeError #652

Open

Description

@sophiecarreras

What happens

ChainedStream.read() has size=None as default and the docstring says None reads until EOF. The first condition is if size < 0 or size is None, which evaluates None < 0 first and raises TypeError in Python 3.

Where

b2sdk/_internal/stream/chained.py:100 (ChainedStream.read); docstring at :89 and :93-94.

Why it matters

Impact: Wrong request or result, loud. Severity: Medium, because it hits any caller using the documented default, and read(-1) works as a workaround.

How to check

Build a ChainedStream and call stream.read(); expect TypeError: '<' not supported between instances of 'NoneType' and 'int'. Swapping the order to size is None or size < 0 removes it. Found by reading the code, not reproduced.

Version

Seen at v2.13.4. Present on the default branch: present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions