[Python-bugs-list] [ python-Bugs-593696 ] telnetlib raises UnboundLocalError
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 11 Aug 2002 12:31:36 -0700
Bugs item #593696, was opened at 2002-08-11 12:57
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=593696&group_id=5470
Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Noah Spurrier (noah)
Assigned to: Nobody/Anonymous (nobody)
Summary: telnetlib raises UnboundLocalError
Initial Comment:
I have a tiny test script that causes telnetlib to
crash due to an UnboundLocalError exception.
I tested this on Python 2.2.1 on Linux and OpenBSD.
Here is the uname output of both test machines:
OpenBSD ark2 2.9 GENERIC#653 i386
Linux starship.python.net 2.2.19-6.2.12smp #1 SMP Fri
Oct 26 11:29:57 EDT 2001 i686 unknown
Here is the script:
import telnetlib
tn = telnetlib.Telnet ("surfers.org", 4242)
tn.read_until ("Please enter your name:")
tn.write ("Mongo\n")
tn.read_until ("just connect to Surfers:")
Here is the exact error:
# python term.py
Traceback (most recent call last):
File "term.py", line 6, in ?
tn.read_until ("just connect to Surfers:")
File "/usr/local/lib/python2.2/telnetlib.py", line 297, in
read_until
self.process_rawq()
File "/usr/local/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
Let me know if I can provide more information.
Yours,
Noah
----------------------------------------------------------------------
Comment By: Terry J. Reedy (tjreedy)
Date: 2002-08-11 15:31
Message:
Logged In: YES
user_id=593130
This appears to be trivial fix in telnetlib.py, line 424:
self.msg('IAC %d not recognized' % ord(opt))
I believe 'opt' should be changed to 'c' since it is c that is
not recognized in the if-elif series above this line. Opt is
only set for certain values of c.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=593696&group_id=5470