public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-PyMuPDF] rawhide: Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility
@ 2026-07-31  9:05 Jitka Plesnikova
  0 siblings, 0 replies; only message in thread
From: Jitka Plesnikova @ 2026-07-31  9:05 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python-PyMuPDF
Branch : rawhide
Commit : 5e2573a0bcf5fb676f266f1f8ba1c2d55a5372d3
Author : Jitka Plesnikova <jplesnik@redhat.com>
Date   : 2026-07-28T15:29:18+02:00
Stats  : +116/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-PyMuPDF/c/5e2573a0bcf5fb676f266f1f8ba1c2d55a5372d3?branch=rawhide

Log:
Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility

---
diff --git a/python-PyMuPDF-swig45.patch b/python-PyMuPDF-swig45.patch
new file mode 100644
index 0000000..e312719
--- /dev/null
+++ b/python-PyMuPDF-swig45.patch
@@ -0,0 +1,113 @@
+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 7277257..ac6dab0 100644
--- a/python-PyMuPDF.spec
+++ b/python-PyMuPDF.spec
@@ -26,6 +26,9 @@ Patch:		0001-src-__init__.py-fix-incorrect-generation-of-PDF-cont.patch
 # Upstreamable:
 # 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
 
 # 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-07-31  9:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31  9:05 [rpms/python-PyMuPDF] rawhide: Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility Jitka Plesnikova

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