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

filter: ensure GIL during pygit2_filter_cleanup #1259

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ void pygit2_filter_cleanup(git_filter *self, void *payload)
{
struct pygit2_filter_payload *pl = (struct pygit2_filter_payload *)payload;

PyGILState_STATE gil = PyGILState_Ensure();
pygit2_filter_payload_free(pl);
PyGILState_Release(gil);
}

void pygit2_filter_shutdown(git_filter *self)
Expand Down
5 changes: 5 additions & 0 deletions test/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ def test_filter_unmatched(testrepo, unmatched_filter):
assert b'bye world\n' == reader.read()
with pygit2.BlobIO(blob, as_path="bye.txt", flags=flags) as reader:
assert b'bye world\n' == reader.read()

def test_filter_cleanup(dirtyrepo, rot13_filter):
# Indirectly test that pygit2_filter_cleanup has the GIL
# before calling pygit2_filter_payload_free.
dirtyrepo.diff()
0x2b3bfa0 marked this conversation as resolved.
Show resolved Hide resolved
Loading