From d11124c7527182bba66ea45945774ccf699a31de Mon Sep 17 00:00:00 2001 From: andryblack Date: Sun, 15 Dec 2024 15:37:05 +0100 Subject: [PATCH] [tools] Fix telnetlib for Python 3.13 --- tools/modm_tools/jlink.py | 8 ++++++-- tools/modm_tools/openocd.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/modm_tools/jlink.py b/tools/modm_tools/jlink.py index 2ab8fc4bf7..f956db5909 100644 --- a/tools/modm_tools/jlink.py +++ b/tools/modm_tools/jlink.py @@ -39,7 +39,6 @@ import time import signal import platform -import telnetlib import subprocess from . import gdb @@ -99,10 +98,15 @@ def itm(device, baudrate=None): def rtt(backend, channel=0): + try: + import telnetlib3 + except ImportError: + print("Please upgrade modm: pip3 install -U modm") + import telnetlib as telnetlib3 # Start JLinkGDBServer in the background with backend.scope(): time.sleep(0.5) - with telnetlib.Telnet("localhost", 19021) as tn: + with telnetlib3.Telnet("localhost", 19021) as tn: try: tn.interact() except KeyboardInterrupt: diff --git a/tools/modm_tools/openocd.py b/tools/modm_tools/openocd.py index 3e6d333cfe..134e18623b 100644 --- a/tools/modm_tools/openocd.py +++ b/tools/modm_tools/openocd.py @@ -41,7 +41,6 @@ import signal import tempfile import platform -import telnetlib import subprocess from . import utils @@ -126,11 +125,16 @@ def itm(backend, fcpu, baudrate=None): pass def rtt(backend, channel=0): + try: + import telnetlib3 + except ImportError: + print("Please upgrade modm: pip3 install -U modm") + import telnetlib as telnetlib3 backend.commands.append("modm_rtt") # Start OpenOCD in the background with backend.scope(): time.sleep(0.5) - with telnetlib.Telnet("localhost", 9090+channel) as tn: + with telnetlib3.Telnet("localhost", 9090+channel) as tn: try: tn.interact() except KeyboardInterrupt: