feat: Binding for custom HTTP resolver (with_resolver on Context) - #303
Open
tmathern wants to merge 78 commits into
Open
feat: Binding for custom HTTP resolver (with_resolver on Context)#303tmathern wants to merge 78 commits into
with_resolver on Context)#303tmathern wants to merge 78 commits into
Conversation
* fix: Docs * fix: Error handling memory * fix: Update the docs * fix: Refactor * fix: Fix script
* fix: Refactor * fix: Refactor * fix: Typo * fix: refactor * fix: Refactor * fix: Refactor 2 * fix: Clean up debug
with_resolver on Context)
Clarified the module's dependency statement regarding c2pa.
tmathern
marked this pull request as ready for review
August 3, 2026 15:16
ok-nick
reviewed
Aug 18, 2026
| @@ -0,0 +1 @@ | |||
| # Placeholder | |||
Collaborator
Author
There was a problem hiding this comment.
Oh, that is for the moduling in Python, so various tools (who may not agree) don't complain. Unittest generally is happy with whatever, pytest is more easily confused, any linter loves to flag that as missing file otherwise.
Comment on lines
+295
to
+319
| _native_malloc = None | ||
|
|
||
| @staticmethod | ||
| def _get_native_malloc(): | ||
| """ | ||
| Return malloc from the C runtime whose free() is used. | ||
|
|
||
| Some allocations must come from the matching runtime | ||
| or the free is heap corruption, so we retrieve that here. | ||
| Looked up lazily as needed, if needed, | ||
| """ | ||
| if ManagedResource._native_malloc is None: | ||
| if sys.platform == "win32": | ||
| try: | ||
| crt = ctypes.CDLL("ucrtbase") | ||
| except OSError: | ||
| crt = ctypes.CDLL("msvcrt") | ||
| else: | ||
| crt = ctypes.CDLL(None) | ||
| malloc = crt.malloc | ||
| malloc.argtypes = [ctypes.c_size_t] | ||
| # The default c_int restype truncates 64-bit pointers. | ||
| malloc.restype = ctypes.c_void_p | ||
| ManagedResource._native_malloc = malloc | ||
| return ManagedResource._native_malloc |
Contributor
There was a problem hiding this comment.
Hm, this doesn't seem too ideal. Maybe the C FFI should be accepting a free callback so the caller can provide their own allocation. We discussed this a little bit when Colin was adding the functionality to the C FFI. I suppose this is fine for now but something to think about.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
Checklist
TO DOitems (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.