Comments (4)
For what it's worth, this looks at a glance like a very achievable goal. I ran 2to3 on the stripe code and I only had to make two changes to get a test credit card payment to go through:
- json.loads cannot take bytestrings in Python3, so I had to add a call to .decode() in APIRequestor.interpret_resonse
- APIRequestor.handle_requests_error uses e.message on exception objects, so I had to replace that with str(e)
I also ran 2to3 on the tests/ directory and then ran the tests, and after one minor manual fix (string.lowercase becomes string.ascii_lowercase), there were 12 failures, but at a glance most of them look like simple bytes/unicode fixes where we just need to call encode or decode appropriately.
I'll take a stab at this later this week.
from stripe-python.
Eli, that sounds awesome!
We've definitely talked about Python 3 support before, and we haven't been ignoring it. We were mostly approaching with the goal of a codebase that executes on both py2 and py3 without having to run through 2to3, but we concluded at the time that we weren't really happy with the compatibility we could offer if we did that.
We still have a number of users on Python 2.5, and given that we add new API features to our bindings, we didn't want to cut them out of access to those updates.
If 2to3 makes this simpler, I'm totally in favor! I don't have any personal experience with 2to3-driven projects, so I'm not sure how much concrete help I can offer, but I'm definitely happy to review pull requests.
from stripe-python.
Thanks for answering my next question in advance, which was what is the earliest version of Python that you want to support. It sounds like for now Python 2.5 is a must, so I'll make sure that when I put together a pull request, whatever I do will still be compatible with that. This makes things little harder since there are a bunch of future imports that we can't do, but it's not a fundamentally difficult problem.
What might end up being best is what I did for one of my own projects, where you include something like this in your setup.py:
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
So that you can basically just run setup.py with different versions of Python to generate a Python 2 and a Python 3 package from the same codebase by having distribute run 2to3 while doing the packaging. But your codebase is small enough that it may be just as easy to carefully craft the code such that it ends up working on both Python 2 and Python 3.
Regardless, I'll play around with it some more, and hopefully send you a pull request sometime this week or next week.
from stripe-python.
Fixed now with many thanks to @EliAndrewC!
from stripe-python.
Related Issues (20)
- Official Python docs out of date HOT 3
- AttributeError: service_agreement HOT 14
- AttributeError: 'CustomerService' object has no attribute 'modify' with StripeClient HOT 1
- Incorrect annotation on `ErrorOrbject.code` HOT 3
- Unable to remove metadata from PaymentIntent.modify HOT 2
- Missing `convert_to_dict` export HOT 3
- Typing issue: `CreateParams` for `StripeObject`s should allow for Optional values HOT 3
- `HTTPXClient` `allow_sync_requests` != `allow_sync_methods` HOT 1
- Quote PDF endpoint does not work HOT 4
- Typing issue: additional_verifications missing in `stripe.Account.CreateParams` HOT 1
- Create a type alias for `stripe.TaxId.type` and others HOT 3
- unknown parameter: stripe_acccount when creating subscription for a connected account HOT 2
- calling stripe.treasury.Transaction.list Method raises Unrecognized request URL exception HOT 1
- OSS-Fuzz Integration HOT 1
- There doesn't seem to be a way of robustly relying on library's types for API responses HOT 2
- Expading list-items doesn't work with retrieve_async HOT 2
- Ability to query for previous API requests HOT 1
- Can't expand invoice from quote HOT 2
- TaxRate.list does not return any TaxRates, even when I can look them up with TaxRate.retrieve HOT 1
- Webhook "Unable to connect" even though it connects successfully
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stripe-python.