Skip to content

Session is not set in object if connection fails, which raises 'AttributeError' on __del__ #746

Open

Description

@tomasfarias

The session attribute is set on the Connection here:

self.session = Session(
.

If connecting fails (e.g. due to invalid host or credentials) then no session attribute will be set, but __del__ will still be called when the not-fully-initialized Connection instance is destroyed. This causes warnings to be printed to stderr.

A simple fix would be to check if session is set in open or doing the same thing in __del__ only, to keep the semantics of open intact.

Activity

  1. added
    engineer-botMaintainer-applied gate: triggers engineer-bot (bug-fix on issue / take-over on PR).
    on Jul 23, 2026
  2. added theissue type on Jul 23, 2026
  3. peco-engineer-bot commented on Jul 23, 2026

    @peco-engineer-bot
    Contributor

    🤖 engineer-bot opened a fix PR: #877

    Review before merge.

  4. tomasfarias commented on Jul 28, 2026

    @tomasfarias
    Author

    Any possibility of merging my PR or the robot's PR? I just want this fixed if possible, I don't really care much about attribution.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineer-botMaintainer-applied gate: triggers engineer-bot (bug-fix on issue / take-over on PR).

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions