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

Glyph glyph at twistedmatrix.com
Tue Sep 8 00:57:18 MDT 2015


> On Sep 7, 2015, at 10:55 PM, Adi Roiban <adi at roiban.ro> wrote:
> 
>> 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.
> 
> What harmed is done if the twisted.internet.error.ProcessTerminated
> exception has an explicit message attribute?

I don't like the precedent it sets; this is not part of the compatibility contract we provide, and we already spend tons of energy on compatibility :-).  Maintaining stuff like this - and like old-style classes - would be a ton of additional work for no real benefit.
`.message´ and `.args´ are implementation accidents, not things that anyone should be relying on in a public API.  If we wanted to provide some structured information for programs to use from ProcessTerminated, let's actually give it a good API that documents what it means, and not just stick a random string or some tuples on an object.

-glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20150907/2e7d5f8e/attachment.html>


More information about the Twisted-Python mailing list