Skip to content

Commit d11124c

Browse files
andryblacksalkinium
authored andcommitted
[tools] Fix telnetlib for Python 3.13
1 parent 8fa0594 commit d11124c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tools/modm_tools/jlink.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import time
4040
import signal
4141
import platform
42-
import telnetlib
4342
import subprocess
4443

4544
from . import gdb
@@ -99,10 +98,15 @@ def itm(device, baudrate=None):
9998

10099

101100
def rtt(backend, channel=0):
101+
try:
102+
import telnetlib3
103+
except ImportError:
104+
print("Please upgrade modm: pip3 install -U modm")
105+
import telnetlib as telnetlib3
102106
# Start JLinkGDBServer in the background
103107
with backend.scope():
104108
time.sleep(0.5)
105-
with telnetlib.Telnet("localhost", 19021) as tn:
109+
with telnetlib3.Telnet("localhost", 19021) as tn:
106110
try:
107111
tn.interact()
108112
except KeyboardInterrupt:

tools/modm_tools/openocd.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import signal
4242
import tempfile
4343
import platform
44-
import telnetlib
4544
import subprocess
4645

4746
from . import utils
@@ -126,11 +125,16 @@ def itm(backend, fcpu, baudrate=None):
126125
pass
127126

128127
def rtt(backend, channel=0):
128+
try:
129+
import telnetlib3
130+
except ImportError:
131+
print("Please upgrade modm: pip3 install -U modm")
132+
import telnetlib as telnetlib3
129133
backend.commands.append("modm_rtt")
130134
# Start OpenOCD in the background
131135
with backend.scope():
132136
time.sleep(0.5)
133-
with telnetlib.Telnet("localhost", 9090+channel) as tn:
137+
with telnetlib3.Telnet("localhost", 9090+channel) as tn:
134138
try:
135139
tn.interact()
136140
except KeyboardInterrupt:

0 commit comments

Comments
 (0)