silverapp / silver

Automated billing and payments for Django with a REST API
https://www.presslabs.com/code/silver/
Other
301 stars 80 forks source link

Python2 and Python3 compatibility. #619

Closed macmichael01 closed 6 years ago

macmichael01 commented 6 years ago

Since future versions of Django will have a python3 requirement, I would attempt to make Silver Python2 and Python3 compatible. Please review!

bogdanpetrea commented 6 years ago

Hi @macmichael01,

This looks like the right approach to me.

Please rebase from master so that linting and testing may run. Although I left some comments, it will be easier for me to review your PR then.

Thanks!

bogdanpetrea commented 6 years ago

Forgot to mention you can remove the allow_failure for python3.6 from the travis build.

For the drone build it should be something similar to https://github.com/drone/drone-python/blob/master/.drone.yml, but it might require some tinkering. You can leave that to me if you want.

bogdanpetrea commented 6 years ago

It seems tests are passing for Python2: https://travis-ci.org/silverapp/silver/jobs/419958428 But they're not passing for Python3: https://travis-ci.org/silverapp/silver/jobs/419958429 Linting fails in both cases, but it should be easy fixing it.

I see the failing tests are related to:

  1. exception.message not being available anymore in Python3. Converting the exception object to string instead (str(exception)) should do the trick.
  2. 'dict' object has no attribute 'iteritems'. Use .items() as discussed previously.
  3. pdf_content = ContentFile(pdf_file_object) error. https://github.com/silverapp/silver/blob/0009ff4ca52dfc711e2f160ad90b449060fc4007/silver/models/documents/pdf.py#L41 should become pdf_file_object = BytesIO().
  4. django.urls.exceptions.NoReverseMatch: Reverse for 'payment' with keyword arguments https://github.com/silverapp/silver/blob/3b718bb7a44c7e1e42479e9f59a0f68c841abda0/silver/utils/payments.py#L33 should become kwargs = {'token': force_text(_get_jwt_token(transaction))}

Let me know if you need any help.