[Twisted-Python] Exception's Implicit Public API, and Python 3

Glyph glyph at twistedmatrix.com
Sat Sep 5 21:07:06 MDT 2015


> On Sep 5, 2015, at 04:03, Amber Hawkie Brown <hawkowl at atleastfornow.net <mailto:hawkowl at atleastfornow.net>> wrote:
> 
> We just ran into an issue in Autobahn|Python where a log message that tried to use the message attribute an Exception subclass (twisted.internet.error.ProcessTerminated). The message attribute was deprecated in Python 2.6, and removed in Python 3 -- but it still "works" in Python 2.7.
> 
> So, this needs the question: Is this breaking Twisted's backwards compat (that .message isn't there on Python 3)? Should we go through and look at our exception subclasses, and look at what makes sense to have a .message attribute (for example, I'd say it makes sense on ProcessTerminated) and then add it? Or is it just a 2/3 change that should be expected during porting? It seems like an interesting edge case (and another example of "Don't use subclassing, kids" ;) ).

It's Python's API which has changed here, so I don't think that it's Twisted's responsibility to replicate this behavior.  Subclassing is bad, and Python's changes of public attributes to such a core language-feature level class as Exception is extra bad, but I think that attempting to simultaneously support every version of Python's public API via Twisted would be a mistake.

For a different example, consider the case of the implicit base of "object".  We could faithfully replicate the semantics of old-style classes for all of Twisted's old-style classes, but instead, they remain old-style on py2 (for now) and new-style on py3.  The "message" attribute seems the same to me, so I think we should say this is a 2/3 change you have to make when porting your own code, and the onus is on Autobahn in this case.

Put differently, Twisted's "the first one's free" policy applies to upgrading Twisted itself, and not to upgrading Python (or any other dependency).  If you upgrade Python and you need to update your code for that, Twisted won't create any additional problems but it won't go out of its way to solve the ones you normally have to deal with.

Sound good?

-glyph

> The Autobahn ticket (which we're fixing as I write this email) is here https://github.com/tavendo/AutobahnPython/issues/479 <https://github.com/tavendo/AutobahnPython/issues/479> .


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20150905/31c853da/attachment.html>


More information about the Twisted-Python mailing list