Skip to content

Python 2 support #1

@faassen

Description

@faassen

Would you accept a Python 2 support PR?

It looks like not a lot of code changes are required.

I played around a little, here are my findings:

  • the Cython code just compiles and seems to work on Python 2 unchanged

  • the __all__ in the __init__.py fails, because I think __all__ in Cython is a unicode object, something Python 2 doesn't like. I'd advocate changing the __init__.py to explicitly import everything needed instead of doing a from .. import *. This way you are in full control of what's exposed in the public API.

  • the test suite relies on some features from Python 3:

    • in particular unitest.mock, which is available as mock on PyPI so that's easy
    • assertRaisesRegex which is missing. It'd need to be backported, or the test rewritten
      as the regexes used aren't complicated.
    • subTest, either backported or the test rewritten.

    I'm a fan of pytest myself so alternatively we can port the tests over over to that; it's compatible
    with Python 2 and Python 3. I'd be happier doing that instead.

  • I recommend a tool like tox so we can easily run the tests on both Pythons.

  • the Makefile is geared towards Python 3, but doesn't do all that much. I just called the build_ext command myself with Python 2. We could cruftify the makefile to support Python 2. Alternatively we could also just simply document the few standard Python commands needed; tox should care of building stuff and running stuff anyway and that's a simple command.

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