Problems with telnetlib

Jan-Fredrik Braseth janfbr at sex.ifi.uio.no
Sat Feb 16 07:56:35 EST 2002


Hi, there.

I'm having a little problem with a bot I'm making. It uses
telnetlib to connect to a chatserver (not irc) and works
fine for a period, but after some time I get this error message:

Traceback (most recent call last):
  File "./quizbot.py", line 366, in ?
    foo = QuizBot(name,password,channel)
  File "./quizbot.py", line 28, in __init__
    line = self.tn.read_until("\n").split()
  File "/usr/lib/python2.2/telnetlib.py", line 297, in read_until
    self.process_rawq()
  File "/usr/lib/python2.2/telnetlib.py", line 424, in process_rawq
    self.msg('IAC %d not recognized' % ord(opt))
UnboundLocalError: local variable 'opt' referenced before assignment

The main loop of the bot is just a while(1) which reads a line at the
time from the connection: line =self.tn.read_until("\n").split()
and it looks like this fails after some time.

tn is initiated like this:

tn = telnetlib.Telnet(server,port)

I really hope someone can help me with this problem

-- 
Jan-Fredrik Braseth		www.ifi.uio.no/~janfbr/
2B|!2B



More information about the Python-list mailing list