libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

Remove decrement of reference when using Py_None #1161 #1162

Closed siscia closed 1 year ago

siscia commented 1 year ago

Addressing #1161

If the representation of a signature requires the use of Py_None we should not decrement the reference count of the special Py_None object.

I tried adding a unit test to verify this new behavior, unfortunately, all the unit test I could come up with were not triggering the bug.

This was tested against the reproduce example in the issue setting the env var PYTHONPATH.

jdavid commented 1 year ago

Good catch! The correct solution is to Py_INCREF(Py_None) when it is assigned. That's what we do in other places, and what is done in Python's core. Please update the PR.

siscia commented 1 year ago

Wonderful I will try to follow up tonight!

siscia commented 1 year ago

Addressed!

Let me know if you need me to squash the commits or to fix the history somehow!

jdavid commented 1 year ago

Yes please, squash the commits.

siscia commented 1 year ago

Done!