Skip to content

Fix Python 3.14 compatibility, various updates#16

Open
ilyagr wants to merge 9 commits intopwang7:masterfrom
ilyagr:fixups
Open

Fix Python 3.14 compatibility, various updates#16
ilyagr wants to merge 9 commits intopwang7:masterfrom
ilyagr:fixups

Conversation

@ilyagr
Copy link

@ilyagr ilyagr commented Mar 15, 2026

These are a bunch of various updates; most of the commits can be used independently from each other. Most importantly, the first two commits prevent a crash and make rebook compatible with recent versions of Python.

I am mostly sharing them in case these are useful to anyone, these are mostly AI-generated. If you consider merging these and need help from me in polishing these (e.g. rewriting the descriptions in a more human fashion), picking out some of these (or splitting them into separate PRs), I'd be happy to help.

check_page_nums() uses re.split() but re was never imported, causing
NameError at runtime when page numbers are entered.
@ilyagr ilyagr force-pushed the fixups branch 4 times, most recently from 87bd2e1 to df00c8d Compare March 16, 2026 01:53
ilyagr added 8 commits March 15, 2026 19:02
A missing `+` between two string literals on adjacent lines caused Python
implicit string concatenation: `' ' 'in,'` became `' in,'`, putting the
space before the unit instead of between the page range and the margin
values. Result was e.g. `-cbox0.00 in,1.00 in,...` instead of the correct
`-cbox 0.00in,1.00in,...`.
Replace asyncio.get_event_loop() with asyncio.new_event_loop().
get_event_loop() was deprecated in 3.10 (warning) and raises
RuntimeError in Python 3.14+.
- Fix shebang from `#!/usr/bin/python` (often Python 2) to
  `#!/usr/bin/env python3`.
- Remove unused `import glob`.
Instead of requiring k2pdfopt to be in the same directory as rebook.py,
search for it in this order:
1. K2PDFOPT_PATH environment variable
2. Next to rebook.py (the script's own directory)
3. ./k2pdfopt (current working directory)
4. Anywhere in PATH (via shutil.which)

The error message now shows the script directory path and explains all
options.
Remove state='readonly' from all Spinbox widgets (width, height, DPI,
columns, resolution multiplier, margins, font size, OCR CPU %, line
break space). Previously, values could only be adjusted via arrow
buttons/keys. Now users can click the field and type a number directly.

Added <Return> and <FocusOut> bindings to each Spinbox so the
corresponding callback fires when the user finishes typing, not just
on arrow clicks.
- Show ./rebook_preset.json path on the Save button so users know where
  the preset file goes.
- Clarify that DPI only applies in non-native (rasterized) mode.
Switch from create_subprocess_shell to create_subprocess_exec with a
proper argument list. Previously, filenames with shell metacharacters
could be executed as commands. The old space-quoting workaround is no
longer needed since arguments are passed as a list.
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