Skip to content

Config.__del__() can raise exception #916

Closed
@MarcelWaldvogel

Description

@MarcelWaldvogel

Trying to work around #915, I started writing code that would try to call Config.get_*_config() to check whether they are out there.

However, if Config.__init__() raises an exception (e.g., because the .gitconfig file is not readable or is a directory), then on program termination (or garbage collection), a seemingly spurious exception is raised:

Exception ignored in: <function Config.__del__ at 0x7fe011d96730>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pygit2/config.py", line 99, in __del__
    C.git_config_free(self._config)
AttributeError: 'Config' object has no attribute '_config'

This happens also if the exception is caught, i.e., when the exception from __init__() is not seen by the user.

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