Skip to content

Repository repr causes segfault #775

Closed
@RazerM

Description

@RazerM

I initially thought this was a pytest bug: pytest-dev/pytest/issues/3293

Minimal example:

from pygit2 import Repository

class MyRepository(Repository):
    def __init__(self, *args, **kwargs):
        self.path # causes segfault
        super().__init__(*args, **kwargs)
        
MyRepository('.')

self->repo isn't initialized when the getter is called:

pygit2/src/repository.c

Lines 519 to 523 in 2d4c1f5

PyObject *
Repository_path__get__(Repository *self, void *closure)
{
return to_path(git_repository_path(self->repo));
}

This will also show up if you try to step through Repository.__init__ in the PyCharm debugger when it calls repr on self.

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