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
)
| 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: |
no outgoing calls
no test coverage detected