Dear maintainer, since this bug currently blocks the python3.10-default transition, I've prepared an NMU for unbound (versioned as 1.13.1-1.1). The diff is attached to this message.
Cheers -- Sebastian Ramacher
diff -Nru unbound-1.13.1/debian/changelog unbound-1.13.1/debian/changelog --- unbound-1.13.1/debian/changelog 2021-02-09 23:53:57.000000000 +0100 +++ unbound-1.13.1/debian/changelog 2022-04-06 21:37:02.000000000 +0200 @@ -1,3 +1,13 @@ +unbound (1.13.1-1.1) unstable; urgency=medium + + * Non-maintainer upload + + [ Rico Tzschichholz ] + * Cherry-pick upstream commits for Python 3.10 compatibility (Closes: + #1008641) + + -- Sebastian Ramacher <sramac...@debian.org> Wed, 06 Apr 2022 21:37:02 +0200 + unbound (1.13.1-1) unstable; urgency=medium * New upstream version 1.13.1 diff -Nru unbound-1.13.1/debian/patches/python3.10-2.patch unbound-1.13.1/debian/patches/python3.10-2.patch --- unbound-1.13.1/debian/patches/python3.10-2.patch 1970-01-01 01:00:00.000000000 +0100 +++ unbound-1.13.1/debian/patches/python3.10-2.patch 2022-04-06 21:35:02.000000000 +0200 @@ -0,0 +1,26 @@ +From 92d01d82658ffc3992e4468472d3c8c080f8b16c Mon Sep 17 00:00:00 2001 +From: Victor Stinner <vstin...@python.org> +Date: Tue, 16 Feb 2021 11:11:06 +0100 +Subject: [PATCH] Fix #426: Replace _Py_fopen() with fopen() in pythonmod.c + +The private _Py_fopen() function has been removed in Python 3.10. + +Fix build on Python 3.10. +--- + doc/Changelog | 1 + + pythonmod/pythonmod.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c +index 040ff7051..6e60d02fe 100644 +--- a/pythonmod/pythonmod.c ++++ b/pythonmod/pythonmod.c +@@ -338,7 +338,7 @@ int pythonmod_init(struct module_env* env, int id) + PyFileObject = PyFile_FromString((char*)pe->fname, "r"); + script_py = PyFile_AsFile(PyFileObject); + #else +- script_py = _Py_fopen(pe->fname, "r"); ++ script_py = fopen(pe->fname, "r"); + #endif + if (script_py == NULL) + { diff -Nru unbound-1.13.1/debian/patches/python3.10.patch unbound-1.13.1/debian/patches/python3.10.patch --- unbound-1.13.1/debian/patches/python3.10.patch 1970-01-01 01:00:00.000000000 +0100 +++ unbound-1.13.1/debian/patches/python3.10.patch 2022-04-06 21:35:02.000000000 +0200 @@ -0,0 +1,101 @@ +From e0d426ebb10653a78bf5c4053198f6ac19bfcd3e Mon Sep 17 00:00:00 2001 +From: "W.C.A. Wijngaards" <wou...@nlnetlabs.nl> +Date: Tue, 9 Feb 2021 10:38:55 +0100 +Subject: [PATCH] - Fix for Python 3.9, no longer use deprecated functions of + PyEval_CallObject (now PyObject_Call), PyEval_InitThreads (now none), + PyParser_SimpleParseFile (now Py_CompileString). + +--- + doc/Changelog | 5 +++++ + libunbound/python/libunbound.i | 6 +++++ + pythonmod/pythonmod.c | 41 ++++++++++++++++++++++++++++++++++ + 3 files changed, 52 insertions(+) + +diff --git a/libunbound/python/libunbound.i b/libunbound/python/libunbound.i +index a23c45b9c..ab244a6fb 100644 +--- a/libunbound/python/libunbound.i ++++ b/libunbound/python/libunbound.i +@@ -916,7 +916,13 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v + struct cb_data* id; + id = (struct cb_data*) iddata; + arglist = Py_BuildValue("(OiO)",id->data,status, SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ub_result, 0 | 0 )); // Build argument list ++#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) ++ /* for python before 3.9 */ + fresult = PyEval_CallObject(id->func,arglist); // Call Python ++#else ++ /* for python 3.9 and newer */ ++ fresult = PyObject_Call(id->func,arglist,NULL); ++#endif + Py_DECREF(id->func); + Py_DECREF(id->data); + free(id); +diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c +index 9006429ef..040ff7051 100644 +--- a/pythonmod/pythonmod.c ++++ b/pythonmod/pythonmod.c +@@ -299,7 +299,10 @@ int pythonmod_init(struct module_env* env, int id) + PyImport_AppendInittab(SWIG_name, (void*)SWIG_init); + #endif + Py_Initialize(); ++#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 6) ++ /* initthreads only for python 3.6 and older */ + PyEval_InitThreads(); ++#endif + SWIG_init(); + mainthr = PyEval_SaveThread(); + } +@@ -354,6 +357,8 @@ int pythonmod_init(struct module_env* env, int id) + /* TODO: deallocation of pe->... if an error occurs */ + + if (PyRun_SimpleFile(script_py, pe->fname) < 0) { ++#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) ++ /* for python before 3.9 */ + log_err("pythonmod: can't parse Python script %s", pe->fname); + /* print the error to logs too, run it again */ + fseek(script_py, 0, SEEK_SET); +@@ -369,9 +374,45 @@ int pythonmod_init(struct module_env* env, int id) + /* ignore the NULL return of _node, it is NULL due to the parse failure + * that we are expecting */ + (void)PyParser_SimpleParseFile(script_py, pe->fname, Py_file_input); ++#else ++ /* for python 3.9 and newer */ ++ char* fstr = NULL; ++ size_t flen = 0; ++ log_err("pythonmod: can't parse Python script %s", pe->fname); ++ /* print the error to logs too, run it again */ ++ fseek(script_py, 0, SEEK_END); ++ flen = (size_t)ftell(script_py); ++ fstr = malloc(flen+1); ++ if(!fstr) { ++ log_err("malloc failure to print parse error"); ++ PyGILState_Release(gil); ++ fclose(script_py); ++ return 0; ++ } ++ fseek(script_py, 0, SEEK_SET); ++ if(fread(fstr, flen, 1, script_py) < 1) { ++ log_err("file read failed to print parse error: %s: %s", ++ pe->fname, strerror(errno)); ++ PyGILState_Release(gil); ++ fclose(script_py); ++ free(fstr); ++ return 0; ++ } ++ fstr[flen] = 0; ++ /* we compile the string, but do not run it, to stop side-effects */ ++ /* ignore the NULL return of _node, it is NULL due to the parse failure ++ * that we are expecting */ ++ (void)Py_CompileString(fstr, pe->fname, Py_file_input); ++#endif + log_py_err(); + PyGILState_Release(gil); + fclose(script_py); ++#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) ++ /* no cleanup needed for python before 3.9 */ ++#else ++ /* cleanup for python 3.9 and newer */ ++ free(fstr); ++#endif + return 0; + } + #if PY_MAJOR_VERSION < 3 diff -Nru unbound-1.13.1/debian/patches/series unbound-1.13.1/debian/patches/series --- unbound-1.13.1/debian/patches/series 2021-02-09 23:53:57.000000000 +0100 +++ unbound-1.13.1/debian/patches/series 2022-04-06 21:36:13.000000000 +0200 @@ -1 +1,3 @@ 0001-Enable-remote-control-by-default.patch +python3.10.patch +python3.10-2.patch
signature.asc
Description: PGP signature