You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError and AttributeError when using Config objects in sensible ways #1466
Constructing a Config with a PathLike results in a TypeError, but this is unnecessary, because the underlying utilities supporting the constructor already support PathLike.
>>> pygit2.Config(pathlib.Path("/Users/nicholas/.gitconfig"))
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
pygit2.Config(pathlib.Path("/Users/nicholas/.gitconfig"))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nicholas/Development/OSS/libgit2/pygit2/.venv/lib/python3.14/site-packages/pygit2/config.py", line 93, in __init__
path_bytes = str_to_bytes(path, 'path')
File "/Users/nicholas/Development/OSS/libgit2/pygit2/.venv/lib/python3.14/site-packages/pygit2/config.py", line 48, in str_to_bytes
raise TypeError(f'{name} must be a string')
TypeError: path must be a string
Additionally, calling Config.snapshot() on any config object other than one obtained from BaseRepository.config() results in an AttributeError. This includes the system config, the global config, the XDB config, and any other file-based configs:
>>> c = pygit2.Config.get_global_config().snapshot()
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
c = pygit2.Config.get_global_config().snapshot()
File "/Users/nicholas/Development/OSS/libgit2/pygit2/.venv/lib/python3.14/site-packages/pygit2/config.py", line 270, in snapshot
return Config.from_c(self._repo, ccfg[0])
^^^^^^^^^^
AttributeError: 'Config' object has no attribute '_repo'
I have a pull request incoming to fix both of these.
Activity
beamerblvd commentedon Jun 28, 2026
Fixed with #1468.