jpvanhal / flask-split

A/B testing for your Flask application.
https://flask-split.readthedocs.io/
MIT License
120 stars 37 forks source link

Python 2 -> Python 3 compatability fixes #8

Closed AngusP closed 5 years ago

AngusP commented 5 years ago

Flask_Split should now support both Python 2 and Python 3.

This will introduce a minor performance hit on Py2 as the iterators iterkeys are no-longer used (on Py3 these will be used).

Additionally the correct urlparse for Py2 and urllib.parse will be imported based on a caught ImportError.

The Redis-Py class instance is also started with the arg decode_responses=True, to ensure strs are passed rather than bytes in Python 3. For Python 2 this will return unicode strings - I don't currently have a Python 2 Flask app to play with to check this hasn't broken anything, but from a quick check in Python 2 str(unicode('asdf')) == 'asdf'

AngusP commented 5 years ago

This might also address #1 by using decode_responses by giving unicode strings by default in Python 2 on returning reads from redis.

jpvanhal commented 5 years ago

Thanks! I merged this one manually. I just published v0.4.0 which includes Python 3 support.