diff mbox series

[meta-python,2/2] python3-pikepdf: Upgrade 10.17.0 -> 10.18.0

Message ID 20261110103028.1041905-2-leon.anavi@konsulko.com
State Under Review
Headers show
Series [meta-python,1/2] python3-ruff: Upgrade 0.17.3 -> 0.17.4 | expand

Commit Message

Leon Anavi Nov. 10, 2026, 10:30 a.m. UTC
Upgrade to release 10.18.0:

- pikepdf.Pdf.add_pages_from now carries layers (optional
  content) with the pages it copies. The optional content groups
  that the copied pages depend on are listed in the destination's
  /OCProperties, with the default visibility, place in the layer
  list, lock, radio button groups and automatic states that the
  source's default configuration gave them. Previously the groups
  were copied but not listed, so viewers ignored them: the layer
  list was empty and content hidden in the source was shown.
- pikepdf.Pdf.add_pages_from now carries bookmarks. Outline
  items of the source that lead to a copied page are appended to
  the destination's outline, keeping their hierarchy, titles and
  style; items that lead to pages that were not copied are dropped.
- Both are on by default, which changes what existing callers of
  add_pages_from get: the destination may gain an /OCProperties and
  outline items it did not gain before. Pass layers='ignore' or
  outlines='ignore' for the previous behaviour, for example if you
  build the merged outline yourself. pikepdf.PageCopyResult
  reports layers_added, outline_items_added and
  outline_items_dropped.
- pikepdf.Pdf.check_pdf_syntax now performs the same checks
  as qpdf --check and reports the same problems. It checks the
  linearization data and hint tables of linearized files, which
  previously required a separate call to
  pikepdf.Pdf.check_linearization, and checks the interactive
  form, embedded files, page labels and outlines. A document with
  no pages is reported as ERROR: file does not contain any pages,
  and a page whose content stream cannot be read is reported as
  ERROR: page N: ... along with the other problems found, where it
  previously raised pikepdf.PdfError.
- Inserting a pikepdf.Dictionary or pikepdf.Array
  that refers to another Pdf into a Pdf now raises
  pikepdf.ForeignObjectError, naming the key or index where the
  foreign object was found, and leaves the target unchanged.
  This covers an indirect object of another Pdf held anywhere in
  the value, such as pdf3.Root.X = Dictionary(P=pdf1.Root.Y), and a
  direct dictionary or array that another Pdf already contains.
  Previously the value was accepted: the first kind made the Pdf
  impossible to save, failing part way through writing, and the
  second left two documents sharing one object. It applies to every
  way of inserting a value, including
  pikepdf.Pdf.make_indirect, pikepdf.Page.add_resource,
  adding a page built from a dictionary, name and number trees, and
  stream dictionaries. Use pikepdf.Pdf.copy_foreign to bring
  the foreign object over first.
- A password containing a NUL character now raises {exc}ValueError,
  both when opening a PDF and when encrypting one. Previously the
  password was silently cut short at the NUL, so a wrong password
  could open a file, and an encrypted file could be written with a
  shorter password than requested. PDF passwords may not contain
  NUL.
- Fixed threads interfering with each other inside one Pdf on
  GIL-enabled builds, which could cause an object to be read as
  None. The per-Pdf lock is now in force on every build, and
  pikepdf.Pdf.lock works on GIL-enabled builds too.
- Methods implemented in Python that change a Pdf in several steps,
  such as pikepdf.Page.add_overlay,
  pikepdf.Pdf.add_pages_from and the pikepdf.sanitize functions,
  now hold its lock until they finish. The thread safety section of
  the architecture notes now says which calls are atomic.
- Two threads that each hold the lock of one Pdf and then need the
  other's no longer deadlock; one of them gets a RuntimeError
  instead. What a callback such as a pikepdf.TokenFilter may
  do is now documented: see {ref}callback-restrictions.
- Fixed a crash, a native stack overflow that no Python except can
  catch, when reading, saving or checking a PDF in which a JBIG2
  image's /JBIG2Globals stream is itself JBIG2-encoded and leads
  back to the image, directly or through other streams. Such an
  image is now reported as unfilterable, as JBIG2-encoded globals
  without a cycle already were: reading it raises
  ~pikepdf.exceptions.PdfError, extracting it raises
  ~pikepdf.exceptions.UnsupportedImageTypeError, and saving
  writes it unchanged with a warning.
- A JBIG2 image's /JBIG2Globals are now read only when the image is
  being JBIG2-decoded, rather than every time qpdf checks whether
  the image can be decoded, which included every save.
- Reading the label of a page whose page label style is an unknown
  name, such as /S /Z, now warns and keeps the label prefix, as an
  invalid non-name style already did. Previously it raised
  KeyError.
- Reading the label of a page whose number cannot be written in its
  page label style, such as /S /R /St 0 or a Roman numeral above
  5000, now warns and writes the number in decimal digits.
  Previously it raised ValueError.
- Extracting an image whose /CalGray or /CalRGB colour space array
  lacks its parameter dictionary now decodes it as the
  corresponding device space, without an ICC profile, as a missing
  /WhitePoint already did. Previously it raised IndexError.
- An ICCBased image whose profile stream omits the required /N, or
  gives one that is not an integer, now takes its mode and default
  /Decode from the profile's colour space. Previously its mode
  raised KeyError.
- Fixed pikepdf.form.SignatureField.stamp_overlay stamping
  the overlay twice when the signature widget names its page with
  /P.
- Fixed a Pdf returned by pikepdf.Job.create_pdf not being
  set up like other Pdf objects: setting its conversion_mode raised
  pikepdf.PdfError, and on free-threaded Python none of its
  methods were protected by a lock.
- Matrix.__array__(copy=False) now raises ValueError, as numpy
  expects of an object that cannot share its memory. The check for
  this was written in a way that never fired.
- A progress argument to pikepdf.Pdf.save that is not
  callable is now rejected with TypeError before anything is
  written. Previously the error was raised part of the way through
  writing the file.
- Fixed a small memory leak each time
  pikepdf.AcroForm.get_fields_with_qualified_name or
  pikepdf.AcroForm.fix_copied_annotations returned a field.
- Iterating over a pikepdf.NameTree or
  pikepdf.NumberTree now iterates over the keys it had when
  the iteration began. Previously the tree was read as the
  iteration went on, so changing it meanwhile gave undefined
  results.
- Putting an object that belongs to another Pdf in a
  pikepdf.NameTree or pikepdf.NumberTree now raises
  pikepdf.ForeignObjectError at once, as it does for a
  dictionary or an array. Previously the error was not raised until
  the Pdf was saved.
- x in tree is now False for an x that cannot be a key of a
  pikepdf.NameTree, such as an int, and for None in a
  pikepdf.NumberTree. Previously these raised TypeError.
- Corrected the documentation and type hints of
  pikepdf.NameTree, which said that names are bytes. Names
  are, and have always been, str: qpdf reads each name as a PDF
  text string and compares names by that text.
- Fixed building from source on Android (Termux), where importing
  pikepdf failed with cannot locate symbol "_Py_TrueStruct" since
  v10.6.0. The extension module is now linked against libpython
  when the build interpreter is an Android Python, as that platform
  requires. Android is not a tested platform.

Free-threaded Python fixes:

Many crashes and data races that occurred when several threads used the
same Pdf at once have been fixed. The test suite now runs under
ThreadSanitizer in continuous integration, which is how most of them
were found ().

- Every binding that reads or changes a Pdf now takes that Pdf's
  lock, and the lock of any other Pdf among its arguments, enforced
  at compile time. Many bindings previously did not, notably most
  methods of pikepdf.NameTree, pikepdf.NumberTree,
  attachments, annotations and pikepdf.AcroForm.
- Fixed crashes and data races in pikepdf.Page methods,
  content stream parsing, adding pages from one Pdf to another, and
  dropping the last reference to a Pdf while another thread used
  one of its objects.
- A pikepdf.Dictionary or pikepdf.Array that belongs
  to no Pdf is now protected by a lock shared by all such objects.
  Threads that each build objects of their own contend for it, so
  add a Dictionary or Array to its Pdf as soon as it is created
  rather than building large structures before adding them.
- Fixed "dictionary changed size during iteration" when several
  threads opened a Pdf's metadata for the first time at once.
- Threads that take turns using the same Pdf are no longer slowed
  to a crawl when every CPU is busy.

This work was sponsored by GOVCERT.LU.

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
 .../python3-pikepdf/0001-pyproject.toml-Do-not-strip.patch    | 4 ++--
 ...{python3-pikepdf_10.17.0.bb => python3-pikepdf_10.18.0.bb} | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename meta-python/recipes-devtools/python/{python3-pikepdf_10.17.0.bb => python3-pikepdf_10.18.0.bb} (96%)
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-pikepdf/0001-pyproject.toml-Do-not-strip.patch b/meta-python/recipes-devtools/python/python3-pikepdf/0001-pyproject.toml-Do-not-strip.patch
index 3650675069..8e935fc4ed 100644
--- a/meta-python/recipes-devtools/python/python3-pikepdf/0001-pyproject.toml-Do-not-strip.patch
+++ b/meta-python/recipes-devtools/python/python3-pikepdf/0001-pyproject.toml-Do-not-strip.patch
@@ -1,4 +1,4 @@ 
-From f54475de5f883ab6d021af78b1f33f34e6cd43eb Mon Sep 17 00:00:00 2001
+From 38c9eb8ee27b1c4fba6035cf346c8efde7cdcd20 Mon Sep 17 00:00:00 2001
 From: Leon Anavi <leon.anavi@konsulko.com>
 Date: Wed, 8 Jul 2026 11:45:11 +0000
 Subject: [PATCH] pyproject.toml: Do not strip
@@ -19,7 +19,7 @@  Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/pyproject.toml b/pyproject.toml
-index a2843de..950a3c2 100644
+index 769a26c..29cb347 100644
 --- a/pyproject.toml
 +++ b/pyproject.toml
 @@ -7,7 +7,8 @@ build-backend = "scikit_build_core.build"
diff --git a/meta-python/recipes-devtools/python/python3-pikepdf_10.17.0.bb b/meta-python/recipes-devtools/python/python3-pikepdf_10.18.0.bb
similarity index 96%
rename from meta-python/recipes-devtools/python/python3-pikepdf_10.17.0.bb
rename to meta-python/recipes-devtools/python/python3-pikepdf_10.18.0.bb
index 3801c4826c..a915f51efa 100644
--- a/meta-python/recipes-devtools/python/python3-pikepdf_10.17.0.bb
+++ b/meta-python/recipes-devtools/python/python3-pikepdf_10.18.0.bb
@@ -4,7 +4,7 @@  HOMEPAGE = "https://github.com/pikepdf/pikepdf"
 LICENSE = "MPL-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9741c346eef56131163e13b9db1241b3"
 
-SRC_URI[sha256sum] = "de4ccaae83628e86c1fd473b384c09c6ff1dd35a583a8dacbf61d2aa4bea843b"
+SRC_URI[sha256sum] = "cb555ebff93482e8a6eb55881488b469bbb2b5675161c1b93a0510a8642d98d0"
 
 SRC_URI += "file://0001-pyproject.toml-Do-not-strip.patch"