[Twisted-Python] 17.5.0 _newtls.pu:207 loseConnection signature problem

Jean-Paul Calderone exarkun at twistedmatrix.com
Fri Aug 11 06:12:32 MDT 2017


On Fri, Aug 11, 2017 at 6:46 AM, Barry Scott <barry.scott at forcepoint.com>
wrote:

> I porting some code to latest twisted and I;m seeing the old code expects
> to
> call loseConenction with a reason.
>

This code makes the mistake of treating a peculiarity of a particular
implementation of an interface as the interface itself.


>
> But loseConnection in class ConnectionMixin does not have the parameter.
>

Nor does the definition of loseConnection on the interface:

http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.ITransport.html#loseConnection


>
> Is this an oversight or deliberate?
>

Code that goes beyond the guarantees of the interface is limiting itself to
working with a particular implementation.  Sometimes it is less than clear
whether some behavior is intended to be guaranteed by the interface or not
- but in this case, it's pretty clear.  loseConnection accepts no
arguments.  Code that passes an argument may work with a specific
implementation but there's no guarantee it will work with other
implementations.  And "other implementations" includes "future versions of
a specific implementation".

So, it's deliberate.  If you want to make the application code in question
more portable across implementations, it should stop passing an argument.

Jean-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170811/57b964e5/attachment-0002.html>


More information about the Twisted-Python mailing list