Skip to content

Commit 69bfb01

Browse files
Merge pull request #960 from sacsant/telnetlib
Fix telnetlib ModuleNotFoundError for Python 3.13+
2 parents 09df672 + 96d5dfe commit 69bfb01

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

common/OpTestHost.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import random
3939
import subprocess
4040
import re
41-
import telnetlib
4241
import socket
4342
import select
4443
import pty

common/OpTestTConnection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
# constantly themselves, so in this file we should expect to be given
3838
# strings and to return strings - even though that makes things harder.
3939

40-
import telnetlib
40+
# telnetlib was removed in Python 3.13, use telnetlib3 as replacement
41+
import sys
42+
if sys.version_info >= (3, 13):
43+
import telnetlib3 as telnetlib
44+
else:
45+
import telnetlib
4146

4247

4348
class NoLoginPrompt(Exception):

common/OpTestUtil.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
import subprocess
3434
import random
3535
import re
36-
import telnetlib
36+
# telnetlib was removed in Python 3.13, but we keep backward compatibility
37+
try:
38+
import telnetlib
39+
except ModuleNotFoundError:
40+
telnetlib = None
3741
import socket
3842
import select
3943
import time

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ paramiko>=2.7.0
55
pexpect
66
ptyprocess
77

8+
# Telnet support - telnetlib3 for Python 3.13+
9+
telnetlib3; python_version >= '3.13'
10+
811
# Testing and utilities
912
unittest-xml-reporting
1013
unittest2

0 commit comments

Comments
 (0)