MCPcopy Create free account
hub / github.com/libgit2/pygit2 / _from_c

Method _from_c

pygit2/config.py:329–352  ·  view source on GitHub ↗

Builds the entry from a ``git_config_entry`` pointer. ``iterator`` must be a ``ConfigIterator`` instance if the entry was created during ``git_config_iterator`` actions.

(
        cls, ptr: 'GitConfigEntryC', iterator: ConfigIterator | None = None
    )

Source from the content-addressed store, hash-verified

327
328 @classmethod
329 def _from_c(
330 cls, ptr: 'GitConfigEntryC', iterator: ConfigIterator | None = None
331 ) -> 'ConfigEntry':
332 """Builds the entry from a ``git_config_entry`` pointer.
333
334 ``iterator`` must be a ``ConfigIterator`` instance if the entry was
335 created during ``git_config_iterator`` actions.
336 """
337 entry = cls.__new__(cls)
338 entry._entry = ptr
339 entry.iterator = iterator
340
341 # It should be enough to keep a reference to iterator, so we only call
342 # git_config_iterator_free when we've deleted all ConfigEntry objects.
343 # But it's not, to reproduce the error comment the lines below and run
344 # the script in https://github.com/libgit2/pygit2/issues/970
345 # So instead we load the Python object immediately. Ideally we should
346 # investigate libgit2 source code.
347 if iterator is not None:
348 entry.raw_name = entry.raw_name
349 entry.raw_value = entry.raw_value
350 entry.level = entry.level
351
352 return entry
353
354 def __del__(self) -> None:
355 if self.iterator is None:

Callers 2

_next_entryMethod · 0.45
_getMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected