Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c8f38c

Browse files
committed
-fixes telnetlib constants to be one-length byte arrays instead of ints
-this fixes telnet negotiation (broken in 3.0) -merged/ported telnetlib tests from trunk (below) Merged revisions 71302,71377,71385 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r71302 | jack.diederich | 2009-04-05 22:08:44 -0400 (Sun, 05 Apr 2009) | 1 line test the telnetlib.Telnet interface more thoroughly ........ r71377 | jack.diederich | 2009-04-07 16:22:59 -0400 (Tue, 07 Apr 2009) | 1 line eliminate more race conditions in telnetlib tests ........ r71385 | jack.diederich | 2009-04-07 19:56:57 -0400 (Tue, 07 Apr 2009) | 4 lines - Make timing assertions very generous (a la test_timeout.py) - Break the gc cycle in negotiation tests - test the different guarantees of read_lazy and read_very_lazy ........
1 parent 175cb23 commit 1c8f38c

2 files changed

Lines changed: 367 additions & 76 deletions

File tree

Lib/telnetlib.py

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -47,87 +47,87 @@
4747
TELNET_PORT = 23
4848

4949
# Telnet protocol characters (don't change)
50-
IAC = 255 # "Interpret As Command"
51-
DONT = 254
52-
DO = 253
53-
WONT = 252
54-
WILL = 251
55-
theNULL = 0
56-
57-
SE = 240 # Subnegotiation End
58-
NOP = 241 # No Operation
59-
DM = 242 # Data Mark
60-
BRK = 243 # Break
61-
IP = 244 # Interrupt process
62-
AO = 245 # Abort output
63-
AYT = 246 # Are You There
64-
EC = 247 # Erase Character
65-
EL = 248 # Erase Line
66-
GA = 249 # Go Ahead
67-
SB = 250 # Subnegotiation Begin
50+
IAC = bytes([255]) # "Interpret As Command"
51+
DONT = bytes([254])
52+
DO = bytes([253])
53+
WONT = bytes([252])
54+
WILL = bytes([251])
55+
theNULL = bytes([0])
56+
57+
SE = bytes([240]) # Subnegotiation End
58+
NOP = bytes([241]) # No Operation
59+
DM = bytes([242]) # Data Mark
60+
BRK = bytes([243]) # Break
61+
IP = bytes([244]) # Interrupt process
62+
AO = bytes([245]) # Abort output
63+
AYT = bytes([246]) # Are You There
64+
EC = bytes([247]) # Erase Character
65+
EL = bytes([248]) # Erase Line
66+
GA = bytes([249]) # Go Ahead
67+
SB = bytes([250]) # Subnegotiation Begin
6868

6969

7070
# Telnet protocol options code (don't change)
7171
# These ones all come from arpa/telnet.h
72-
BINARY = 0 # 8-bit data path
73-
ECHO = 1 # echo
74-
RCP = 2 # prepare to reconnect
75-
SGA = 3 # suppress go ahead
76-
NAMS = 4 # approximate message size
77-
STATUS = 5 # give status
78-
TM = 6 # timing mark
79-
RCTE = 7 # remote controlled transmission and echo
80-
NAOL = 8 # negotiate about output line width
81-
NAOP = 9 # negotiate about output page size
82-
NAOCRD = 10 # negotiate about CR disposition
83-
NAOHTS = 11 # negotiate about horizontal tabstops
84-
NAOHTD = 12 # negotiate about horizontal tab disposition
85-
NAOFFD = 13 # negotiate about formfeed disposition
86-
NAOVTS = 14 # negotiate about vertical tab stops
87-
NAOVTD = 15 # negotiate about vertical tab disposition
88-
NAOLFD = 16 # negotiate about output LF disposition
89-
XASCII = 17 # extended ascii character set
90-
LOGOUT = 18 # force logout
91-
BM = 19 # byte macro
92-
DET = 20 # data entry terminal
93-
SUPDUP = 21 # supdup protocol
94-
SUPDUPOUTPUT = 22 # supdup output
95-
SNDLOC = 23 # send location
96-
TTYPE = 24 # terminal type
97-
EOR = 25 # end or record
98-
TUID = 26 # TACACS user identification
99-
OUTMRK = 27 # output marking
100-
TTYLOC = 28 # terminal location number
101-
VT3270REGIME = 29 # 3270 regime
102-
X3PAD = 30 # X.3 PAD
103-
NAWS = 31 # window size
104-
TSPEED = 32 # terminal speed
105-
LFLOW = 33 # remote flow control
106-
LINEMODE = 34 # Linemode option
107-
XDISPLOC = 35 # X Display Location
108-
OLD_ENVIRON = 36 # Old - Environment variables
109-
AUTHENTICATION = 37 # Authenticate
110-
ENCRYPT = 38 # Encryption option
111-
NEW_ENVIRON = 39 # New - Environment variables
72+
BINARY = bytes([0]) # 8-bit data path
73+
ECHO = bytes([1]) # echo
74+
RCP = bytes([2]) # prepare to reconnect
75+
SGA = bytes([3]) # suppress go ahead
76+
NAMS = bytes([4]) # approximate message size
77+
STATUS = bytes([5]) # give status
78+
TM = bytes([6]) # timing mark
79+
RCTE = bytes([7]) # remote controlled transmission and echo
80+
NAOL = bytes([8]) # negotiate about output line width
81+
NAOP = bytes([9]) # negotiate about output page size
82+
NAOCRD = bytes([10]) # negotiate about CR disposition
83+
NAOHTS = bytes([11]) # negotiate about horizontal tabstops
84+
NAOHTD = bytes([12]) # negotiate about horizontal tab disposition
85+
NAOFFD = bytes([13]) # negotiate about formfeed disposition
86+
NAOVTS = bytes([14]) # negotiate about vertical tab stops
87+
NAOVTD = bytes([15]) # negotiate about vertical tab disposition
88+
NAOLFD = bytes([16]) # negotiate about output LF disposition
89+
XASCII = bytes([17]) # extended ascii character set
90+
LOGOUT = bytes([18]) # force logout
91+
BM = bytes([19]) # byte macro
92+
DET = bytes([20]) # data entry terminal
93+
SUPDUP = bytes([21]) # supdup protocol
94+
SUPDUPOUTPUT = bytes([22]) # supdup output
95+
SNDLOC = bytes([23]) # send location
96+
TTYPE = bytes([24]) # terminal type
97+
EOR = bytes([25]) # end or record
98+
TUID = bytes([26]) # TACACS user identification
99+
OUTMRK = bytes([27]) # output marking
100+
TTYLOC = bytes([28]) # terminal location number
101+
VT3270REGIME = bytes([29]) # 3270 regime
102+
X3PAD = bytes([30]) # X.3 PAD
103+
NAWS = bytes([31]) # window size
104+
TSPEED = bytes([32]) # terminal speed
105+
LFLOW = bytes([33]) # remote flow control
106+
LINEMODE = bytes([34]) # Linemode option
107+
XDISPLOC = bytes([35]) # X Display Location
108+
OLD_ENVIRON = bytes([36]) # Old - Environment variables
109+
AUTHENTICATION = bytes([37]) # Authenticate
110+
ENCRYPT = bytes([38]) # Encryption option
111+
NEW_ENVIRON = bytes([39]) # New - Environment variables
112112
# the following ones come from
113113
# http://www.iana.org/assignments/telnet-options
114114
# Unfortunately, that document does not assign identifiers
115115
# to all of them, so we are making them up
116-
TN3270E = 40 # TN3270E
117-
XAUTH = 41 # XAUTH
118-
CHARSET = 42 # CHARSET
119-
RSP = 43 # Telnet Remote Serial Port
120-
COM_PORT_OPTION = 44 # Com Port Control Option
121-
SUPPRESS_LOCAL_ECHO = 45 # Telnet Suppress Local Echo
122-
TLS = 46 # Telnet Start TLS
123-
KERMIT = 47 # KERMIT
124-
SEND_URL = 48 # SEND-URL
125-
FORWARD_X = 49 # FORWARD_X
126-
PRAGMA_LOGON = 138 # TELOPT PRAGMA LOGON
127-
SSPI_LOGON = 139 # TELOPT SSPI LOGON
128-
PRAGMA_HEARTBEAT = 140 # TELOPT PRAGMA HEARTBEAT
129-
EXOPL = 255 # Extended-Options-List
130-
NOOPT = 0
116+
TN3270E = bytes([40]) # TN3270E
117+
XAUTH = bytes([41]) # XAUTH
118+
CHARSET = bytes([42]) # CHARSET
119+
RSP = bytes([43]) # Telnet Remote Serial Port
120+
COM_PORT_OPTION = bytes([44]) # Com Port Control Option
121+
SUPPRESS_LOCAL_ECHO = bytes([45]) # Telnet Suppress Local Echo
122+
TLS = bytes([46]) # Telnet Start TLS
123+
KERMIT = bytes([47]) # KERMIT
124+
SEND_URL = bytes([48]) # SEND-URL
125+
FORWARD_X = bytes([49]) # FORWARD_X
126+
PRAGMA_LOGON = bytes([138]) # TELOPT PRAGMA LOGON
127+
SSPI_LOGON = bytes([139]) # TELOPT SSPI LOGON
128+
PRAGMA_HEARTBEAT = bytes([140]) # TELOPT PRAGMA HEARTBEAT
129+
EXOPL = bytes([255]) # Extended-Options-List
130+
NOOPT = bytes([0])
131131

132132
class Telnet:
133133

0 commit comments

Comments
 (0)