Repository navigation
Refuse a PALSParserCpp library outside the supported versions - #18
Merged
Merged
Conversation
palsparserpy mirrors the C library's structs by their layout through ctypes, so a library whose structs differ would be read wrongly, not refused. PALSParserCpp now reports its version with pals_parser_cpp_version(). On first use, check that version against SUPPORTED_LIBRARY_VERSIONS (0.0.3 for now) before any other prototype is bound, and raise a RuntimeError naming the library's path, its version and the versions needed. A library without the function predates every supported version and is refused the same way. Add palsparserpy.library_version(), which returns the version of the library in use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
📖 Documentation preview for this PR: https://pals-project.github.io/PALSParserPy/previews/PR18/ Rebuilt on every push; removed automatically when the PR closes. |
Bring in the Windows test jobs (#17), so this branch's CI checks the version check on Windows too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
palsparserpy mirrors PALSParserCpp's structs by layout through ctypes, so a library whose structs differ is read wrongly instead of refused. pals-project/PALSParserCpp#119 makes the library report its version with
pals_parser_cpp_version(); this checks it._clib.py:SUPPORTED_LIBRARY_VERSIONS = ((0, 0, 3), (0, 0, 3)), the oldest and newest PALSParserCpp versions the bindings mirror. On the first call, before any other prototype is bound, the library's version is checked against it. A library outside the range, one reporting something other thanmajor.minor.patch, or one withoutpals_parser_cpp_version()(anything older) raises aRuntimeErrornaming its path, its version and the versions needed.palsparserpy.library_version(): the version of the library in use.tests/test_clib.py: the library in use is supported; the check passes at both ends of the range and refuses a library outside it, an unreadable version, and one with no version function.Merge pals-project/PALSParserCpp#119 first. This PR's CI builds PALSParserCpp from
main, which doesn't havepals_parser_cpp_version()yet, so every test that loads the library fails here until #119 is merged and CI is re-run. Locally against #119's build: 146 passed, 6 skipped.🤖 Generated with Claude Code