pygit2
pygit2 copied to clipboard
Improve repr of pygit2.hash
At present hash and pygit2.hash have the same repr. We can tell them apart by looking at the __module__ attribute. But not their type.
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
>>> hash, pygit2.hash
(<built-in function hash>, <built-in function hash>)
>>> id(hash) - id(pygit2.hash)
2918112
>>> pygit2.hash.__module__
'pygit2._pygit2'
>>> hash.__module__
'builtins'
>>> type(hash), type(pygit2.hash)
(<class 'builtin_function_or_method'>, <class 'builtin_function_or_method'>)
>>>
This will confuse anyone who relies on repr to check that they are using the correct hash function.