Index | Thread | Search

From:
Jonathan Gray <jsg@jsg.id.au>
Subject:
devel/coccinelle patch for python 3.13
To:
ports@openbsd.org
Cc:
sthen@openbsd.org
Date:
Fri, 5 Dec 2025 15:07:45 +1100

Download raw body.

Thread
fixes:
Py.find_library: unable to find the Python library [/usr/local/lib/libpython3.13.so.0.0 returned Cannot resolve _PyObject_NextNotImplemented.

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/coccinelle/Makefile,v
diff -u -p -r1.60 Makefile
--- Makefile	21 Jul 2025 16:26:26 -0000	1.60
+++ Makefile	5 Dec 2025 03:54:06 -0000
@@ -11,7 +11,7 @@ COMMENT =	program matching and transform
 GH_ACCOUNT =	coccinelle
 GH_PROJECT =	coccinelle
 GH_TAGNAME =	1.1.1
-REVISION =	8
+REVISION =	9
 
 CATEGORIES =	devel
 
--- /dev/null	Fri Dec  5 14:58:31 2025
+++ patches/patch-bundles_pyml_pyml-current_pyml_stubs_c	Fri Dec  5 14:53:36 2025
@@ -0,0 +1,76 @@
+Support for Python 3.13
+
+https://github.com/thierry-martinez/pyml/commit/68bf34b79bd43d145fbf33f8bbd7c4eb520cae34.patch
+
+Index: bundles/pyml/pyml-current/pyml_stubs.c
+--- bundles/pyml/pyml-current/pyml_stubs.c.orig
++++ bundles/pyml/pyml-current/pyml_stubs.c
+@@ -157,8 +157,6 @@ typedef struct PyMethodDef {
+ 
+ typedef void (*PyCapsule_Destructor)(PyObject *);
+ 
+-static void *Python27__PyObject_NextNotImplemented;
+-
+ /* Global variables for the library */
+ 
+ /* version_major != 0 iff the library is initialized */
+@@ -678,8 +676,6 @@ py_load_library(value filename_ocaml, value debug_buil
+         Python27_PyCapsule_New = resolve("PyCapsule_New");
+         Python27_PyCapsule_GetPointer = resolve("PyCapsule_GetPointer");
+         Python27_PyCapsule_IsValid = resolve("PyCapsule_IsValid");
+-        Python27__PyObject_NextNotImplemented =
+-            resolve("_PyObject_NextNotImplemented");
+     }
+     Python_PyObject_CallFunctionObjArgs =
+         resolve("PyObject_CallFunctionObjArgs");
+@@ -731,10 +727,10 @@ py_load_library(value filename_ocaml, value debug_buil
+         PyObject *debug_build_py;
+         char *py_debug_str = "Py_DEBUG";
+         if (version_major >= 3) {
+-            py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, 8);
++            py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, strlen(py_debug_str));
+         }
+         else {
+-            py_debug = Python2_PyString_FromStringAndSize(py_debug_str, 8);
++            py_debug = Python2_PyString_FromStringAndSize(py_debug_str, strlen(py_debug_str));
+         }
+         if (!py_debug) {
+             failwith("py_debug");
+@@ -749,7 +745,8 @@ py_load_library(value filename_ocaml, value debug_buil
+         debug_build_py =
+             Python_PyEval_CallObjectWithKeywords(get_config_var, args, NULL);
+         if (!debug_build_py) {
+-            failwith("PyEval_CallObjectWithKeywords");
++            Python_PyErr_Print();
++            caml_failwith("Cannot check for debug build");
+         }
+         if (version_major >= 3) {
+             debug_build = Python_PyLong_AsLong(debug_build_py);
+@@ -877,6 +874,17 @@ enum pytype_labels {
+     Set
+ };
+ 
++static bool is_iterable(PyObject *obj) {
++    PyObject *iter = Python_PyObject_GetIter(obj);
++    if (iter) {
++        Py_DECREF(iter);
++        return true;
++    } else {
++        Python_PyErr_Clear();
++        return false;
++    }
++}
++
+ CAMLprim value
+ pytype(value object_ocaml)
+ {
+@@ -942,8 +950,7 @@ pytype(value object_ocaml)
+     else if (ob_type == Python_PySet_Type) {
+         result = Set;
+     }
+-    else if (typeobj->tp_iternext != NULL &&
+-        typeobj->tp_iternext != &Python27__PyObject_NextNotImplemented) {
++    else if (is_iterable(object)) {
+         result = Iter;
+     }
+     else {