Skip to content

Python 2 and 3, str and bytes compatibility #38

Description

@slezica

To make the library run under both Python versions with the same code, we need to address the str vs bytes problem.

In Python 2, bytes is an alias for str. In Python 3, bytes is a separate class. These two, despite having the same name, behave completely different: they take different arguments to construct, they return different types when indexed and str and repr don't do the same.

Possible solutions:

  • Use the bytes class in future.builtins, from pip install future
  • Use the six bridging library (undesireable, it cannot be exposed to the API user)

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