[Twisted-Python] The Python 2.7 Plan

Wilfredo Sánchez Vega wsanchez at wsanchez.net
Wed Dec 11 14:06:08 MST 2019


  With Python 2.7 support dropping in a matter of weeks, I'd like to pick up from hawkowl's thread back in March about Python 2.7 support for Twisted.

  hawkowl had shared a plan in a Google Docs document.  That URL has since gone stale but here's a new one (thanks, hawkowl):

  https://docs.google.com/document/d/1lIkg6mYVMxVhh3_U6uSJ1XjllPM92Nf8Zp7b7OZPbIw/edit


  Here's what I got from the prior conversation:


Amber Brown (hawkowl):

> I personally find that Python 2 compat adds a huge amount of overhead 
> when working on and maintaining Twisted, and think that with the current 
> maintainer availability, dropping it sooner rather than later would have 
> a beneficial effect on how much work we spend on shims/compat, 
> complexity, and our ability to ship new features, as well as onboarding 
> people who are interested in the project, but have no interest (or 
> experience!) in Python 2.7.

  As an example here, I'd like us to start adopting type hints.  I find them incredibly valuable as documentation and for catching lots of bugs.

  The best way to adopt them is to use inline syntax supported by Python 3.6+, or slightly less ideal, Python 3.5+.  It looks like pydoctor may have support for this soon, which makes that an increasingly interesting avenue.

  To support Python 2.7, we'd have to use either:

  - the comments-based inline syntax, which is far uglier and leaves us with an extra project of converting those later when we finally do drop 2.7, or

  - stub files, which are considerably less easy to manage over time

  Doing this will also afford us an opportunity to better express the API (do we mean to return a "mutable sequence" or a specifically a list, etc.).

  There's a longer conversation to be had about type hints, and that should be on a separate thread; I only talk about it here to explain why Python 2.7 is in the way.

> One of my rationales is that from some analysis of PyPI download 
> statistics, the vast majority of Python 2 users are using old versions 
> of Twisted, while nearly all our Python 3 users are on the latest 
> version.

  Can you share how you looked up these stats?  I don't see a way to do so with pypistats.


John Santos:

> I hope/expect that none of my code changes to make my source compatible 
> with both 2.7 and 3 will break when Twisted support for 2.7 goes away!  
> (It seems to me the Twisted compatibility policy would guarantee that.)

  To be clear, I would not expect this to be the case if you update Twisted to a version that no longer supports Python 2.7.  You would have to continue using a version that does support Python 2.7. You should have some runway, however, in which your app still works with either Py2.7 and Twisted 19 as well as Py3.8 using Twisted 20, for example.


Glyph, in reference to a maintenance branch for Python 2.7:

> Personally, I'm not willing to commit to this.  I know from experience both on Twisted and other projects that maintaining multiple release branches, even one that's "maintenance only", requires at least one point-person for each branch at all times (usually a "release manager").  And backporting fixes inevitably gets harder and harder as the "maintenance" branch diverges from top-of-tree.  If I have time to work on Twisted in my increasingly scarce spare time, I want it to be on something at least plausibly interesting, and manually backporting manual fixes to an unmaintained py2 branch that I don't even use doesn't qualify.

  I tend to agree.  I think the compromise would be that we could be willing to accept back-ports of certain fixes (presumably limited to security fixes?) to a maintenance branch, but not that we would commit to doing so for any period of time.

  Additionally, we've already supported Python 2.7 for the entirely supported lifetime of Python 2.7.

  Glyph also notes some infrastructure we use that is blocked on code fixes:

  - Trac: https://trac.edgewall.org/ticket/12130
    Looks like we can leave the Trac instance running in a Twisted 19 WCGI server until they fix that.

  - DNS: https://twistedmatrix.com/trac/ticket/9496
    I'd suggest we do the same as with Trac until this is fixed, but Glyph disagrees.


  Back to hawkowl's document:

  - Part 1: I think we should drop the Py2.7 maintenance branch piece per Glyph's comment above.

  - Part 2: Re-introduced modules should go into separate repositories, not back into Twisted proper.

  As to the timeline, Option 1 would be to cut a 2.7 release in a couple of weeks.  I don't know that we need to do this in January, but I would suggest that our next release is the final release for 2.7.  This would require a fix to the DNS issue #9496.

	-wsv



More information about the Twisted-Python mailing list