Skip to content

Incompatibility with Python 3.14 #229

@adferrand

Description

@adferrand

Python 3.14 now raises a SyntaxWarning when a break, continue or return statement is used in a finally block.

As a consequence, the following code fails in strict test environments, and will fail in the future on production:

def get_role_name(self):
if self.role:
return self.role
try:
resp = urlopen(self._role_endpoint)
self.role = resp.read().decode("utf8")
except Exception as e:
raise TencentCloudSDKException("ClientError.MetadataError", str(e))
finally:
return self.role

The fix seems pretty straightforward: the final return self.role should be made in the try block because if it fails, an exception will be raised and no value would be returned anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions