Skip to content

SyntaxWarning with Python 3.14 #308

@adamkbmc

Description

@adamkbmc

Running some tests of my code with Python 3.14.0 (on Linux) I spotted this:

/usr/lib/python3.14/site-packages/sshtunnel.py:1040: SyntaxWarning: 'return' in a 'finally' block

Looking at the code the finally seems a bit pointless as several exceptions are being caught. The trouble with this approach is that other exceptions are simply lost, i.e. if the code raises something other than IOError, AttributeError or TypeError those exceptions would not be reported or raised As an example consider this:

`def foo():
try:
raise Exception("test")
finally:
return "hello"

print(foo())`

This prints "hello", there is nothing to indicate the Exception happened

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions