Git pygit2 python

pygit2 0.20.3 introduces support for credentials


  • Introduce support for credentials
  • Several memory issues fixed
  • Compatibility fixes for Python 3.3, PyPy3 and Visual Studio
  • And much more…

Thanks to Carlos Martín Nieto, Leonardo Rhodes, Devaev Maxim, Erik Meusel, Thomas Kluyver and earl.



Git pygit2 python

pygit2 version 0.20.1 brings support for merge and reset


  • New remote ref-specs API: #290
  • New Repository.reset(...): #292, #294
  • Export GIT_DIFF_MINIMAL: #293
  • New Repository.merge(...): #295
  • Fix Repository.blame argument handling: #297
  • Fix build error on Windows: #298
  • Fix typo in the README file, Blog → Blob: #301
  • Now Diff.patch returns None if no patch: #232, #303
  • New Walker.simplify_first_parent(): #304

Thanks to Jose Plana, Victor Garcia, Petr Hosek, Adam Spiers, Eric Schrijver,  Óscar San José and Xu Tao.




Python: Running Valgrind on a C extension

This is how I use Valgrind to check for memory bugs in pygit2.

UPDATED 2019-10-09

Glibc with debug symbols

The first issue I run into is that Valgrind refused to work if Glibc was not compiled with debug symbols.

This is how I did in my Gentoo notebook, I edited the /etc/portage/make.conf file to enable the splitdebug feature:

FEATURES="${FEATURES} splitdebug compressdebug -nostrip"

Then re-emerged the glibc:

$ sudo emerge glibc

Then commented out the splitdebug feature to avoid emerging other packages with debug symbols (there is likely a better way to do this).

Valgrind 3.7

The big problem is that running Valgrind with a Python C extension raises tons of false positives. There are a number of things you need to do to avoid all these false positives.

The first one is to use latest version of Valgrind 3.7, because of some bug I forgot about present in version 3.6

Python, compiling for a memory debugger

Now, you need to install a version of Python to be used with Valgrind:

$ ./configure --prefix=/.../Python-3.7.4-valgrind --without-pymalloc --with-pydebug --with-valgrind
$ make
$ make install

Install pytest and pygit2

$ curl -o
$ /.../Python-3.7.4-valgrind/bin/python3
$ /.../Python-3.7.4-valgrind/bin/pip install pytest
$ /.../Python-3.7.4-valgrind/bin/python3 install

The suppression file

Now you need to use the suppression file that you will find in the Python sources, at Misc/valgrind-python.supp. This is how I run the unit tests in pygit2 to find issues:

$ valgrind --trace-children=yes --suppressions=valgrind-python.supp \

That’s it.