New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 2 support #1
Comments
OK, you can make a PR.
Good.
Ideally, I'd like to see
We can write a rudimentary version for py2.
OK.
I'd prefer to keep the Makefile as is. Or, you can add a few more targets with a '2' suffix. |
BTW, there is this package: https://github.com/benoitc/http-parser/ |
@faassen Are you working on any PR? Because if not (of if you haven't got too far) I'd like to close this issue. Since there is another similar package for Python 2, I see no point in migrating this one. |
assertRaisesRegex is provided by unittest2, and is only needed for Python <= 2.6 try:
unittest.TestCase.assertRaisesRegex
except AttributeError:
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp Will make it just work. |
Alright, I'm closing this PR. |
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 afrom .. 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:
unitest.mock
, which is available asmock
on PyPI so that's easyassertRaisesRegex
which is missing. It'd need to be backported, or the test rewrittenas 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.
The text was updated successfully, but these errors were encountered: