Skip to content

Refuse an invalid timeout and align L.document and L.layout - #85

Merged
codesensedev merged 2 commits into
mainfrom
726-sdk-parity-fixes
Nov 30, 2026
Merged

codesensedev merged 2 commits into
mainfrom
726-sdk-parity-fixes

Conversation

@codesensedev

@codesensedev codesensedev commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Three places where the Python SDK read or behaved differently from the other four. A negative timeout, or a NaN, was taken as no limit, and a fraction such as 1.5 passed the options and failed at the render with a ctypes ArgumentError, where PHP and Java take a whole number of seconds and refuse the rest. L.document's second parameter was sections, where the others call it nodes, which shows when it is passed by name. And L.layout typed its attributes LayoutAttr | None but gave them no default, so L.layout() failed where L.section() and L.column() build an empty node.

What changes

  • EngineOptions raises ValueError("timeout must be a whole number of seconds, 0 for no limit, not -1") for a timeout that isn't a whole number from 0, in PHP's words, as max_memory_mb below it already does for its own range. Every engine call takes its options from EngineOptions, so a render, a stamp, a merge and the invoice calls all get the check. The docstring's :raises: says so.
  • L.document(attrs, nodes): the second parameter is nodes. A call that passed sections= by name needs the new name.
  • L.layout(attrs=None, nodes=None): L.layout() builds an empty layout, as L.section() and L.column() do.

How it was checked

  • New tests: test_a_timeout_that_is_not_a_whole_number_from_0_is_refused (for -1, -60, 1.5, NaN, "5" and True), test_a_document_takes_its_sections_as_nodes (by position and by name give the same tree) and test_a_layout_needs_no_attributes.
  • make test-sdk-python: 273 passed.
  • make check-sdk-api: no generated file differs, and all 65 classes match the schema in all five SDKs.

Companion PRs: lpdfio/lpdf-js#89 and lpdfio/lpdf-php#89.

Work: 726

L.layout's attributes default to None, as every other builder's do.

Work: 726
@codesensedev codesensedev changed the title Refuse a negative timeout and match L.document and L.layout to the other SDKs Refuse a negative timeout and align L.document and L.layout Nov 30, 2026
@codesensedev codesensedev changed the title Refuse a negative timeout and align L.document and L.layout Refuse an invalid timeout and align L.document and L.layout Nov 30, 2026
@codesensedev
codesensedev merged commit b9decda into main Nov 30, 2026
1 check passed
@codesensedev
codesensedev deleted the 726-sdk-parity-fixes branch November 30, 2026 18:30
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