Skip to content

Support pathlib paths for PDFKit inputs and output - #278

Open
Aschenbath wants to merge 1 commit into
JazzCore:masterfrom
Aschenbath:fix/pathlike-inputs-235
Open

Aschenbath wants to merge 1 commit into
JazzCore:masterfrom
Aschenbath:fix/pathlike-inputs-235

Conversation

@Aschenbath

Copy link
Copy Markdown

Passing a pathlib.Path to from_file() currently fails before launching wkhtmltopdf, and Path objects in other command positions can mask conversion errors with a TypeError. Normalize filesystem path objects at the source, executable, and command boundaries, while retaining ordinary strings and file streams.

Fixes #235. The README now includes a Path example. Regression tests cover single and mixed-list inputs, a custom bytes-returning path object, CSS, cover/output/executable paths, stdin streams, and error reporting.

Validation on Python 3.12 / Windows:

  • The 10 new unit tests pass; 8 fail with the original production code.
  • All 40 renderer-independent initialization/command/path tests pass with the default configuration explicitly pointed at the Python executable for command construction. Subprocess execution in the new conversion tests is mocked.
  • git diff --check passes.

The 17 wkhtmltopdf-dependent integration tests were not run; wkhtmltopdf is not installed in this environment.

Developed with assistance from OpenAI Codex.

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.

Add support for pathlib

1 participant