sioyek-python-extensions
sioyek-python-extensions copied to clipboard
Fix unpacking errors triggered by _embed_annotations in get_bookmarks() and get_highlights() functions
Problem
When using the _embed_annotations , users may run into unpacking errors in the get_bookmarks() and get_highlights() functions inside sioyek.py.
These functions expect a fixed number of columns returned by SQLite queries. However, on some systems (e.g., Arch Linux with Python 3.12+), the database may return extra columns due to schema changes or environment-specific differences.
This can trigger errors like:
ValueError: too many values to unpack (expected 4)ValueError: too many values to unpack (expected 8)
These issues break the _embed_annotations feature, which depends on both functions to extract highlights and bookmarks.
What this PR does
- Replaces fixed unpacking with a more robust pattern that handles extra columns gracefully
- Uses length checks and wildcard unpacking (
*_) to capture only the needed fields - Preserves the original behavior using list comprehensions
- Makes
_embed_annotationsmore reliable across environments
Testing
- Verified
_embed_annotationsworks correctly after adding highlights and bookmarks - Tested with Sioyek installed via
pipon Python 3.12 - Used a PDF with real annotations to confirm that
embed_annotations.pyruns successfully