sioyek-python-extensions icon indicating copy to clipboard operation
sioyek-python-extensions copied to clipboard

Fix unpacking errors triggered by _embed_annotations in get_bookmarks() and get_highlights() functions

Open r7nd7 opened this issue 8 months ago • 0 comments

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_annotations more reliable across environments

Testing

  • Verified _embed_annotations works correctly after adding highlights and bookmarks
  • Tested with Sioyek installed via pip on Python 3.12
  • Used a PDF with real annotations to confirm that embed_annotations.py runs successfully

r7nd7 avatar Mar 30 '25 14:03 r7nd7