Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Submodule.open() if parent repo is instance of Repository subclass #1295

Merged
merged 1 commit into from
May 25, 2024

Conversation

jorio
Copy link
Contributor

@jorio jorio commented May 25, 2024

Submodule.open() fails if the submodule was created from a subclass of Repository.

For example:

class CustomRepoClass(pygit2.Repository):
    pass
r = CustomRepoClass("some-repo")
s = r.submodules["submodule-name"].open()

# Traceback (most recent call last):
#   (...snip...)
#   File "pygit2/submodules.py", line 60, in open
#     return self._repo._from_c(crepo[0], True)
#   File "pygit2/repository.py", line 1551, in _from_c
#     super(cls, repo)._from_c(bytes(ffi.buffer(cptr)[:]), owned)
#   File "pygit2/repository.py", line 1549, in _from_c
#     cptr[0] = ptr
# TypeError: initializer for ctype 'struct git_repository *' must be a cdata pointer, not bytes

This PR fixes this issue.

@jdavid jdavid merged commit 2538735 into libgit2:master May 25, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants