Skip to content

Refuse a PALSParserCpp library outside the supported versions - #18

Merged
DavidSagan merged 2 commits into
mainfrom
library-version-check
Nov 22, 2026
Merged

DavidSagan merged 2 commits into
mainfrom
library-version-check

Conversation

@DavidSagan

Copy link
Copy Markdown
Member

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 than major.minor.patch, or one without pals_parser_cpp_version() (anything older) raises a RuntimeError naming 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.
  • Installation guide: a "Matching versions" section.

Merge pals-project/PALSParserCpp#119 first. This PR's CI builds PALSParserCpp from main, which doesn't have pals_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

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>
@github-actions

Copy link
Copy Markdown
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>
@DavidSagan
DavidSagan merged commit fc7b72f into main Nov 22, 2026
7 checks passed
github-actions Bot added a commit that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant