Skip to content

Fix bare except clauses in agent.py, channel.py, client.py, and transport.py - #2644

Open
koteshyelamati wants to merge 4 commits into
paramiko:mainfrom
koteshyelamati:main
Open

koteshyelamati wants to merge 4 commits into
paramiko:mainfrom
koteshyelamati:main

Conversation

@koteshyelamati

Copy link
Copy Markdown

Fix 6 bare except: clauses that catch BaseException (including SystemExit, KeyboardInterrupt), replacing them with except Exception: or more specific types.

paramiko/agent.py (3 instances):

  • Line 148: except: → except Exception: — _communicate() thread body; re-raises on failure.
  • Line 203: except: → except Exception: — _accept() socket accept; re-raises on failure.
  • Line 231: except: → except OSError: — conn.connect(SSH_AUTH_SOCK); comment says "probably a dangling env var: the ssh agent is gone", so only OSError is expected.

paramiko/channel.py (1 instance):

  • Line 139: except: pass → except Exception: pass — in __del__ calling self.close(); standard cleanup.

paramiko/client.py (1 instance):

  • Line 362: except: pass → except Exception: pass — around sock.settimeout(timeout).

paramiko/transport.py (1 instance):

  • Line 2169: except: → except Exception: — wraps transport run-loop teardown; conditionally re-raises if interpreter is still running.

Bare except: clauses are bad practice (PEP 8 / flake8 E722) because they swallow KeyboardInterrupt and SystemExit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant