public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-PyMuPDF] f44: record upstream PR
@ 2026-08-16 19:05 Michael J Gruber
  0 siblings, 0 replies; only message in thread
From: Michael J Gruber @ 2026-08-16 19:05 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python-PyMuPDF
            Branch : f44
            Commit : 6825fa6d40d79012a92a939c9a6e55c1dd40268a
            Author : Michael J Gruber <mjg@fedoraproject.org>
            Date   : 2026-07-31T15:59:43+02:00
            Stats  : +144/-115 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-PyMuPDF/c/6825fa6d40d79012a92a939c9a6e55c1dd40268a?branch=f44

            Log:
            record upstream PR

[skip changelog]

---
diff --git a/0001-Replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch b/0001-Replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
new file mode 100644
index 0000000..51afbbe
--- /dev/null
+++ b/0001-Replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
@@ -0,0 +1,141 @@
+From 7f419a5bed7b257416f6837580dc4325e240e625 Mon Sep 17 00:00:00 2001
+Message-ID: <7f419a5bed7b257416f6837580dc4325e240e625.1785424868.git.mjg@fedoraproject.org>
+From: Michael J Gruber <mjg@fedoraproject.org>
+Date: Thu, 30 Jul 2026 17:20:11 +0200
+Subject: [PATCH] Replace removed Python 2 C API macros for SWIG 4.5.0
+ compatibility
+
+SWIG was carrying thus macros before version 4.5.0, but they were never
+necessary in Python 3. Stop using for compatibility with upcoming SWIG
+4.5.0.
+
+Suggested-by: Jitka Plesnikova <jplesnik@redhat.com>
+---
+ src/__init__.py              |  2 +-
+ src/extra.i                  |  2 +-
+ src_classic/fitz_old.i       |  2 +-
+ src_classic/helper-fields.i  | 14 +++++++-------
+ src_classic/helper-xobject.i |  2 +-
+ 5 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/src/__init__.py b/src/__init__.py
+index af7f9d7f..1a798a79 100644
+--- a/src/__init__.py
++++ b/src/__init__.py
+@@ -21945,7 +21945,7 @@ def JM_set_widget_properties(annot, Widget):
+ 
+     # entry ignored - may be used later
+     #
+-    #int text_format = (int) PyInt_AsLong(GETATTR("text_format"));
++    #int text_format = (int) PyLong_AsLong(GETATTR("text_format"));
+     #
+ 
+     # field label -----------------------------------------------------------
+diff --git a/src/extra.i b/src/extra.i
+index bf04ebb8..aafff30c 100644
+--- a/src/extra.i
++++ b/src/extra.i
+@@ -225,7 +225,7 @@ static void messagev(const char* format, va_list va)
+     static PyObject* message_fn = PyObject_GetAttrString(pymupdf_module, "message");
+     char* text;
+     vasprintf(&text, format, va);
+-    PyObject* text_py = PyString_FromString(text);
++    PyObject* text_py = PyUnicode_FromString(text);
+     PyObject* args = PyTuple_Pack(1, text_py);
+     PyObject* ret = PyObject_CallObject(message_fn, args);
+     Py_XDECREF(ret);
+diff --git a/src_classic/fitz_old.i b/src_classic/fitz_old.i
+index 8abc8955..3181e569 100644
+--- a/src_classic/fitz_old.i
++++ b/src_classic/fitz_old.i
+@@ -6805,7 +6805,7 @@ def get_oc_items(self) -> list:
+             fz_try(gctx) {
+                 pdf_page *page = pdf_page_from_fz_page(gctx, (fz_page *) $self);
+                 if (!page) goto finished;  // have no PDF
+-                int xref = (int) PyInt_AsLong(PyDict_GetItem(linkdict, dictkey_xref));
++                int xref = (int) PyLong_AsLong(PyDict_GetItem(linkdict, dictkey_xref));
+                 if (xref < 1) goto finished;  // invalid xref
+                 pdf_obj *annots = pdf_dict_get(gctx, page->obj, PDF_NAME(Annots));
+                 if (!annots) goto finished;  // have no annotations
+diff --git a/src_classic/helper-fields.i b/src_classic/helper-fields.i
+index 721dc34f..e173acc3 100644
+--- a/src_classic/helper-fields.i
++++ b/src_classic/helper-fields.i
+@@ -323,7 +323,7 @@ PyObject *JM_listbox_value(fz_context *ctx, pdf_annot *annot)
+     pdf_obj *annot_obj = pdf_annot_obj(ctx, annot);
+     pdf_obj *optarr = pdf_dict_get(ctx, annot_obj, PDF_NAME(V));
+     if (pdf_is_string(ctx, optarr))         // a single string
+-        return PyString_FromString(pdf_to_text_string(ctx, optarr));
++        return PyUnicode_FromString(pdf_to_text_string(ctx, optarr));
+ 
+     // value is an array (may have len 0)
+     n = pdf_array_len(ctx, optarr);
+@@ -609,7 +609,7 @@ void JM_set_widget_properties(fz_context *ctx, pdf_annot *annot, PyObject *Widge
+     Py_ssize_t i, n = 0;
+     int d;
+     PyObject *value = GETATTR("field_type");
+-    int field_type = (int) PyInt_AsLong(value);
++    int field_type = (int) PyLong_AsLong(value);
+     Py_DECREF(value);
+ 
+     // rectangle --------------------------------------------------------------
+@@ -642,7 +642,7 @@ void JM_set_widget_properties(fz_context *ctx, pdf_annot *annot, PyObject *Widge
+         dashes = pdf_new_array(ctx, pdf, n);
+         for (i = 0; i < n; i++) {
+             pdf_array_push_int(ctx, dashes,
+-                               (int64_t) PyInt_AsLong(PySequence_ITEM(value, i)));
++                               (int64_t) PyLong_AsLong(PySequence_ITEM(value, i)));
+         }
+         pdf_dict_putl_drop(ctx, annot_obj, dashes,
+                                 PDF_NAME(BS),
+@@ -670,7 +670,7 @@ void JM_set_widget_properties(fz_context *ctx, pdf_annot *annot, PyObject *Widge
+ 
+     // entry ignored - may be used later
+     /*
+-    int text_format = (int) PyInt_AsLong(GETATTR("text_format"));
++    int text_format = (int) PyLong_AsLong(GETATTR("text_format"));
+     */
+ 
+     // field label -----------------------------------------------------------
+@@ -701,14 +701,14 @@ void JM_set_widget_properties(fz_context *ctx, pdf_annot *annot, PyObject *Widge
+     if (field_type == PDF_WIDGET_TYPE_TEXT)
+     {
+         value = GETATTR("text_maxlen");
+-        int text_maxlen = (int) PyInt_AsLong(value);
++        int text_maxlen = (int) PyLong_AsLong(value);
+         if (text_maxlen) {
+             pdf_dict_put_int(ctx, annot_obj, PDF_NAME(MaxLen), text_maxlen);
+         }
+         Py_XDECREF(value);
+     }
+     value = GETATTR("field_display");
+-    d = (int) PyInt_AsLong(value);
++    d = (int) PyLong_AsLong(value);
+     Py_XDECREF(value);
+     pdf_field_set_display(ctx, annot_obj, d);
+ 
+@@ -748,7 +748,7 @@ void JM_set_widget_properties(fz_context *ctx, pdf_annot *annot, PyObject *Widge
+ 
+     // field flags ------------------------------------------------------------
+     value = GETATTR("field_flags");
+-    int field_flags = (int) PyInt_AsLong(value);
++    int field_flags = (int) PyLong_AsLong(value);
+     Py_XDECREF(value);
+     if (!PyErr_Occurred()) {
+         if (field_type == PDF_WIDGET_TYPE_COMBOBOX) {
+diff --git a/src_classic/helper-xobject.i b/src_classic/helper-xobject.i
+index 7f9c9c97..be09f3d7 100644
+--- a/src_classic/helper-xobject.i
++++ b/src_classic/helper-xobject.i
+@@ -137,7 +137,7 @@ static void show(const char* prefix, PyObject* obj)
+     }
+     PyObject* obj_repr = PyObject_Repr( obj);
+     PyObject* obj_repr_u = PyUnicode_AsEncodedString( obj_repr, "utf-8", "~E~");
+-    const char* obj_repr_s = PyString_AsString( obj_repr_u);
++    const char* obj_repr_s = PyBytes_AsString( obj_repr_u);
+     printf( "%s%s\n", prefix, obj_repr_s);
+     fflush(stdout);
+ }
+-- 
+2.55.0.607.ge54b5b6513
+

diff --git a/python-PyMuPDF-swig45.patch b/python-PyMuPDF-swig45.patch
deleted file mode 100644
index e312719..0000000
--- a/python-PyMuPDF-swig45.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-diff -up PyMuPDF-1.27.2.2/src_classic/fitz_old.i.swig45 PyMuPDF-1.27.2.2/src_classic/fitz_old.i
---- PyMuPDF-1.27.2.2/src_classic/fitz_old.i.swig45	2026-07-28 10:30:13.882743539 +0200
-+++ PyMuPDF-1.27.2.2/src_classic/fitz_old.i	2026-07-28 10:30:29.552064294 +0200
-@@ -6800,7 +6800,7 @@ def get_oc_items(self) -> list:
-             fz_try(gctx) {
-                 pdf_page *page = pdf_page_from_fz_page(gctx, (fz_page *) $self);
-                 if (!page) goto finished;  // have no PDF
--                int xref = (int) PyInt_AsLong(PyDict_GetItem(linkdict, dictkey_xref));
-+                int xref = (int) PyLong_AsLong(PyDict_GetItem(linkdict, dictkey_xref));
-                 if (xref < 1) goto finished;  // invalid xref
-                 pdf_obj *annots = pdf_dict_get(gctx, page->obj, PDF_NAME(Annots));
-                 if (!annots) goto finished;  // have no annotations
-diff -up PyMuPDF-1.27.2.2/src_classic/helper-fields.i.swig45 PyMuPDF-1.27.2.2/src_classic/helper-fields.i
---- PyMuPDF-1.27.2.2/src_classic/helper-fields.i.swig45	2026-07-28 10:30:13.878743457 +0200
-+++ PyMuPDF-1.27.2.2/src_classic/helper-fields.i	2026-07-28 10:30:29.542064089 +0200
-@@ -323,7 +323,7 @@ PyObject *JM_listbox_value(fz_context *c
-     pdf_obj *annot_obj = pdf_annot_obj(ctx, annot);
-     pdf_obj *optarr = pdf_dict_get(ctx, annot_obj, PDF_NAME(V));
-     if (pdf_is_string(ctx, optarr))         // a single string
--        return PyString_FromString(pdf_to_text_string(ctx, optarr));
-+        return PyUnicode_FromString(pdf_to_text_string(ctx, optarr));
- 
-     // value is an array (may have len 0)
-     n = pdf_array_len(ctx, optarr);
-@@ -609,7 +609,7 @@ void JM_set_widget_properties(fz_context
-     Py_ssize_t i, n = 0;
-     int d;
-     PyObject *value = GETATTR("field_type");
--    int field_type = (int) PyInt_AsLong(value);
-+    int field_type = (int) PyLong_AsLong(value);
-     Py_DECREF(value);
- 
-     // rectangle --------------------------------------------------------------
-@@ -642,7 +642,7 @@ void JM_set_widget_properties(fz_context
-         dashes = pdf_new_array(ctx, pdf, n);
-         for (i = 0; i < n; i++) {
-             pdf_array_push_int(ctx, dashes,
--                               (int64_t) PyInt_AsLong(PySequence_ITEM(value, i)));
-+                               (int64_t) PyLong_AsLong(PySequence_ITEM(value, i)));
-         }
-         pdf_dict_putl_drop(ctx, annot_obj, dashes,
-                                 PDF_NAME(BS),
-@@ -670,7 +670,7 @@ void JM_set_widget_properties(fz_context
- 
-     // entry ignored - may be used later
-     /*
--    int text_format = (int) PyInt_AsLong(GETATTR("text_format"));
-+    int text_format = (int) PyLong_AsLong(GETATTR("text_format"));
-     */
- 
-     // field label -----------------------------------------------------------
-@@ -701,14 +701,14 @@ void JM_set_widget_properties(fz_context
-     if (field_type == PDF_WIDGET_TYPE_TEXT)
-     {
-         value = GETATTR("text_maxlen");
--        int text_maxlen = (int) PyInt_AsLong(value);
-+        int text_maxlen = (int) PyLong_AsLong(value);
-         if (text_maxlen) {
-             pdf_dict_put_int(ctx, annot_obj, PDF_NAME(MaxLen), text_maxlen);
-         }
-         Py_XDECREF(value);
-     }
-     value = GETATTR("field_display");
--    d = (int) PyInt_AsLong(value);
-+    d = (int) PyLong_AsLong(value);
-     Py_XDECREF(value);
-     pdf_field_set_display(ctx, annot_obj, d);
- 
-@@ -748,7 +748,7 @@ void JM_set_widget_properties(fz_context
- 
-     // field flags ------------------------------------------------------------
-     value = GETATTR("field_flags");
--    int field_flags = (int) PyInt_AsLong(value);
-+    int field_flags = (int) PyLong_AsLong(value);
-     Py_XDECREF(value);
-     if (!PyErr_Occurred()) {
-         if (field_type == PDF_WIDGET_TYPE_COMBOBOX) {
-diff -up PyMuPDF-1.27.2.2/src_classic/helper-xobject.i.swig45 PyMuPDF-1.27.2.2/src_classic/helper-xobject.i
---- PyMuPDF-1.27.2.2/src_classic/helper-xobject.i.swig45	2026-07-28 10:30:13.880743498 +0200
-+++ PyMuPDF-1.27.2.2/src_classic/helper-xobject.i	2026-07-28 10:30:29.543210368 +0200
-@@ -137,7 +137,7 @@ static void show(const char* prefix, PyO
-     }
-     PyObject* obj_repr = PyObject_Repr( obj);
-     PyObject* obj_repr_u = PyUnicode_AsEncodedString( obj_repr, "utf-8", "~E~");
--    const char* obj_repr_s = PyString_AsString( obj_repr_u);
-+    const char* obj_repr_s = PyBytes_AsString( obj_repr_u);
-     printf( "%s%s\n", prefix, obj_repr_s);
-     fflush(stdout);
- }
-diff -up PyMuPDF-1.27.2.2/src/extra.i.swig45 PyMuPDF-1.27.2.2/src/extra.i
---- PyMuPDF-1.27.2.2/src/extra.i.swig45	2026-07-28 10:30:13.874743375 +0200
-+++ PyMuPDF-1.27.2.2/src/extra.i	2026-07-28 10:30:29.518063597 +0200
-@@ -225,7 +225,7 @@ static void messagev(const char* format,
-     static PyObject* message_fn = PyObject_GetAttrString(pymupdf_module, "message");
-     char* text;
-     vasprintf(&text, format, va);
--    PyObject* text_py = PyString_FromString(text);
-+    PyObject* text_py = PyUnicode_FromString(text);
-     PyObject* args = PyTuple_Pack(1, text_py);
-     PyObject* ret = PyObject_CallObject(message_fn, args);
-     Py_XDECREF(ret);
-diff -up PyMuPDF-1.27.2.2/src/__init__.py.swig45 PyMuPDF-1.27.2.2/src/__init__.py
---- PyMuPDF-1.27.2.2/src/__init__.py.swig45	2026-07-28 10:30:13.876743416 +0200
-+++ PyMuPDF-1.27.2.2/src/__init__.py	2026-07-28 10:30:29.537063986 +0200
-@@ -21724,7 +21724,7 @@ def JM_set_widget_properties(annot, Widg
- 
-     # entry ignored - may be used later
-     #
--    #int text_format = (int) PyInt_AsLong(GETATTR("text_format"));
-+    #int text_format = (int) PyLong_AsLong(GETATTR("text_format"));
-     #
- 
-     # field label -----------------------------------------------------------

diff --git a/python-PyMuPDF.spec b/python-PyMuPDF.spec
index ac6dab0..f950960 100644
--- a/python-PyMuPDF.spec
+++ b/python-PyMuPDF.spec
@@ -23,12 +23,13 @@ Patch:		0001-adjust-tests-to-tesseract-5.5.1.patch
 Patch:		0001-tests-conftest-do-not-call-pip.patch
 # Upstream patches from main branch:
 Patch:		0001-src-__init__.py-fix-incorrect-generation-of-PDF-cont.patch
-# Upstreamable:
+# Suggested upstream::
 # https://github.com/pymupdf/PyMuPDF/pull/5015
 Patch:		0001-remove-usage-of-typing.ByteString.patch
 # Replace removed Python 2 C API macros with Python 3 equivalents
 # for compatibility with SWIG 4.5.0
-Patch:		python-PyMuPDF-swig45.patch
+# https://github.com/pymupdf/PyMuPDF/pull/5072
+Patch:		0001-Replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
 
 # test dependencies not picked up by generator
 BuildRequires:	python3dist(pillow)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-16 19:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-16 19:05 [rpms/python-PyMuPDF] f44: record upstream PR Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox