Problems with telnetlib

Jan-Fredrik Braseth janfbr at
Sat Feb 16 13:56:35 CET 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 "./", line 366, in ?
    foo = QuizBot(name,password,channel)
  File "./", line 28, in __init__
    line ="\n").split()
  File "/usr/lib/python2.2/", line 297, in read_until
  File "/usr/lib/python2.2/", 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"\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

More information about the Python-list mailing list