Giter Club home page Giter Club logo

Comments (4)

EliAndrewC avatar EliAndrewC commented on August 28, 2024

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.

ebroder avatar ebroder commented on August 28, 2024

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.

EliAndrewC avatar EliAndrewC commented on August 28, 2024

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.

ebroder avatar ebroder commented on August 28, 2024

Fixed now with many thanks to @EliAndrewC!

from stripe-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.