Skip to content
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 3 compatibility #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Python 3 compatibility #72

wants to merge 2 commits into from

Conversation

tomassedovic
Copy link

This fixes issue #48. It was surprisingly straightforward.

A few things of note:
0. The aim was to have a single codebase that's compatible with both major versions.

  1. It takes advantage of the py3 syntax backports into 2.6 and 2.7 as well as the reintroduced u'string' literals in 3.3. As such, the code is not compatible with 2.5, 3.1 and 3.2. If that's alright with the community, I'd like to keep it that way because it makes it much easier to maintain. If it is a problem, we should come up with a consensus on the supported versions and I shall attempt to update this.
  2. I didn't get to port the tests yet. That's to come next week if there's an interest the port. I have updated and tested the examples, though, and they work.
  3. Related to that, the "gen" and "ssl_transports" examples didn't work for me out of the box on master so I don't test them on the python3 branch either. I'll look into it next week to see if there are genuine bugs or it's just an issue with my setup.

I tried to follow Armin Ronacher's suggestions:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/

Please do try it out and let me know if you have any issues or concerns over the code.

This changes the syntax and semantics a bit so that the resulting code
is compatible with Python 2.6, 2.7 and 3.3.

These three versions are closer than any other 2/3 combination. 2.6 and
2.7 got a lot of syntax from 3 backported and 3.3 added the u'string'
syntax to make porting easier.

It mostly follows Armin Ronacher's suggestions:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/

The tests are not ported yet, just the library and the examples.

Signed-off-by: Tomas Sedovic <[email protected]>
inspect.ismethod behaves differently for Python 2 and 3 (and it seems that the
Py2 behaviour we're relying on here is actually a bug):

http://bugs.python.org/issue16851

I don't think we *need* to verify that the event is a method. As long as it has
the `_event_name` attribute (which we only set in the decorator), things should
just work.

Signed-off-by: Tomas Sedovic <[email protected]>
jafd added a commit to jafd/tornadio2 that referenced this pull request Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant