Skip to content

Cleanup InputStream #13

Open
Open
@gsnedders

Description

@gsnedders

InputStream is a mess. We should clean up so the legacy entry-point does all the magic, and all the internal code is clean.

We should have an abstract base class that defines the methods an InputStream must support, including concrete implementations when possible (charsUntil should be implementable based on lower-level APIs, for example). We should have two concrete classes inheriting from this: TextInputStream and BytesInputStream which take as an argument a file-like object (in Python 3, one that inherits from io.IOBase).

We should investigate whether we can get rid of our BufferedStream, relying upon io.BufferedReader (which exists from 2.6, which we now require).

The entry-point will need to:

  • Determine whether it has been passed a file-like object or a string.
  • If it is a file-like object, determine whether it contains Unicode data or not. (In Python 3, this can ordinarily be done by checking whether it inherits from TextIOBase, provided it inherits from IOBase.)
  • If it is a string, check whether it is bytes/unicode, and then wrap it in StringIO/BytesIO to pass on.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions