[Twisted-Python] Errors after upgrading to 2.0.1

snacktime snacktime at gmail.com
Sun Jul 31 01:52:27 EDT 2005

I'm testing out an application I wrote in 1.3.  In 2.0.1 I get a
warning and an exception.

The UserWarning about SSL I looked up on the list and I understand why
it's there, although I think it's a bad idea.  The warning is about a
bug in pyopenssl that hasn't been fixed in pyopenssl.  In addition
there is no reason to think it will ever be fixed after being ignored
for this long.  Maybe someone could find a better solution for this
warning other then leaving it to end user to find the patch on the
mailing list, which for all I know might not even work at this point. 
 Maybe put up a patched copy of pyopenssl on twistedmatrix.com?  Seems
better than having an unmaintained dependancy in twisted.

The exception I really have no clue about, maybe someone could point
out where the problem is?

from OpenSSL import SSL
import sys
import time

from twisted.internet.protocol import ClientFactory
from twisted.protocols.basic import LineReceiver
from twisted.internet import ssl, reactor
from curses.ascii import STX,ETX,FS

STX =  chr(STX)
ETX =  chr(ETX)
FS =  chr(FS)

class EchoClient(LineReceiver):
    def connectionMade(self):
        transaction = self.factory.trans
        self.sendLine("%s" % transaction)

    def connectionLost(self, reason):
        #print 'connection lost (protocol)'

    def lineReceived(self, line):
        print "receive:", line

class EchoClientFactory(ClientFactory):
    protocol = EchoClient

    def clientConnectionFailed(self, connector, reason):
        print 'connection failed:', reason.getErrorMessage()

    def clientConnectionLost(self, connector, reason):
        #print 'connection lost:', reason.getErrorMessage()

    def SetTransaction(self,id,a,b,c,d,e,f,g,h,i,j,k,l):
      self.trans = STX + id + FS + a + FS + b + FS + c + FS + d + FS +
e + FS + f + FS + g + FS + h + FS + i + FS + j + FS + k + FS + l + ETX

    def GetTransaction(self):
      return self.trans

def main():
    factory = EchoClientFactory()
abc street','98034','','','id1')
    reactor.connectSSL('localhost', 8000, factory, ssl.ClientContextFactory())

if __name__ == '__main__':

receive: id1:APPROVED::TRANSACTION PRESENT:::0000123456789
UserWarning: SSL connection shutdown possibly unreliable, please
upgrade to ver 0.XX
  "please upgrade to ver 0.XX", category=UserWarning)
Traceback (most recent call last):
  File "./error", line 55, in ?
  File "./error", line 51, in main
  File "/usr/local/lib/python2.4/site-packages/twisted/internet/posixbase.py",
line 199, in run
  File "/usr/local/lib/python2.4/site-packages/twisted/internet/posixbase.py",
line 207, in mainLoop
--- <exception caught here> ---
  File "/usr/local/lib/python2.4/site-packages/twisted/internet/base.py",
line 533, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "/usr/local/lib/python2.4/site-packages/twisted/internet/base.py",
line 389, in _continueSystemEvent
    for callList in sysEvtTriggers[1], sysEvtTriggers[2]:
exceptions.TypeError: unsubscriptable object

More information about the Twisted-Python mailing list