Python 3.13 support: vendor telnetlib, paramiko 3.x — cloudshell-cli 6.0 - #138
Merged
Conversation
- Vendor CPython 3.12's telnetlib as cloudshell/cli/session/_telnetlib.py (PSF-2.0; telnetlib was removed from the stdlib in 3.13 by PEP 594). telnet_session.py prefers the stdlib module when it exists (<=3.12) and falls back to the vendored copy on 3.13+ - zero behavior change on <=3.12. - paramiko ~=2.12 -> >=3.4,<4. Capped below 4 because _get_pkey_object still supports paramiko.DSSKey, which paramiko 4.0 removed. - Version 6.0.0, python_requires >=3.9, classifiers 3.9-3.13. - CI: package-tox-py-37-39.yml -> package-tox-py-39.yml; tox envlist py39. - Lint: pin setuptools<81 for the flake8 hook (pkg_resources); exclude the vendored module; per-file-ignores for py3.12+ f-string tokenizer false positives (E231/E702) and the intentional types.py name (A005). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
cloudshell-cli5.0.2 cannot run on Python 3.13:telnetlibwas removed from the stdlib in Python 3.13 (PEP 594) —TelnetSessionfails at import.paramiko~=2.12is EOL-ish and creates friction with moderncryptography(the ecosystem now ships cryptography>=43 via cloudshell-snmp 6.0).What changed
Lib/telnetlib.pycopied tocloudshell/cli/session/_telnetlib.py(PSF-2.0, provenance header, CLItest()/__main__scaffolding and the 3.13 deprecation call removed).telnet_session.pydoestry: import telnetlib / except ImportError: ... _telnetlib as telnetlib— the stdlib module is still preferred on <=3.12, so behavior there is unchanged. No other module in the repo imports telnetlib.>=3.4,<4(resolves to 3.5.1). Capped below 4.x deliberately:SSHSession._get_pkey_objectstill supportsparamiko.DSSKey, which paramiko 4.0 removed; the_transport_factoryserver_extensionsssh-rsa workaround is alreadyhasattr-guarded.scp~=0.14left as-is (resolves to 0.16.1, compatible).python_requires>=3.9, classifiers 3.9–3.13.package-tox-py-37-39.yml→package-tox-py-39.yml; tox envlistpy39only.setuptools<81pinned into the flake8 hook (its plugins needpkg_resources, gone from newer setuptools/py3.12+ venvs); vendored module excluded from hooks/flake8; per-file-ignores for E231/E702 false positives from the py3.12+ f-string tokenizer intl1_session.pyand A005 for the intentionalcloudshell/cli/types.pymodule name.Evidence
Transportserver (password + RSA-key auth, SCP and SFTP upload) — a live handshake against paramiko 3.x. No mock changes were needed.import telnetlibconfirmed to fail on 3.13; a local asyncio telnet server on port 2323 +TelnetSession.connect()completed the full login/password action-map flow and prompt match through the vendored module (telnetlib module in use: cloudshell.cli.session._telnetlib,CONNECTED, active = True).SSHSessioninstantiation OK (plus the live-handshake unit tests above).🤖 Generated with Claude Code