Files
JMR-devandClaude Opus 4.8 ae2231727f Fix Python 3 correctness bugs found in code review
Fix str/bytes and leftover-py2 defects across the plugin, several on live
decryption paths:

  - erdr2pml.py: getText() footnote/sidebar handling mixed a bytes
    accumulator with str literals and called ord() on a bytes element,
    crashing on eReader/.pdb books that contain footnotes or sidebars.
  - ion.py: readdecimal() did `[ord(x) for x in self.read(...)]` over
    bytes (ord(int)), crashing KFX decryption on Ion DECIMAL values;
    printlob() had the same ord()-over-bytes in its debug path.
  - zipfilerugged.py: `isinstance(file, unicode)` raised NameError when a
    file-like object (not a path string) was passed to the ZipFile.
  - utilities.py: SafeUnbuffered.write referenced the undefined `unicode`
    (same fix already applied to the obok copy).
  - ineptpdf.py: ord(bookkey[0]) over an int in an error-diagnostic print.
  - epubfontdecrypt.py: removed a dead py2 itertools.izip fallback.
  - convert2xml.py: escapestr did bytes.replace(str, ...).
  - kgenpids.py: decode() built a str result then += bytes.

Cleanups from the earlier shim removal: drop now-unused `import sys`
(alfcrypto, utilities, kgenpids); unicode_argv returns list(sys.argv) so
callers can't mutate the process-global sys.argv.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 20:35:11 -05:00

16 lines
459 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# get sys.argv arguments as a list of Unicode strings
def unicode_argv(default_name):
# On Python 3 sys.argv is already a list of Unicode strings on every
# platform, so no special handling is needed.
if len(sys.argv) > 0:
return list(sys.argv)
# if we don't have any arguments at all, just pass back the script name
# this should never happen
return [default_name]