Description: In Python plug-in, try getfullargspec before deprecated getargspec
Author: Thibaut Paumard <thibaut.paumard@obspm.fr>
Origin: upstream
Forwarded: not-needed
Last-Update: 2022-11-27
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/plugins/python/lib/Base.C
+++ b/plugins/python/lib/Base.C
@@ -47,13 +47,25 @@
 bool Gyoto::Python::PyCallable_HasVarArg(PyObject * pMethod) {
   static PyObject * pGetArgSpec = NULL;
 
-  if (!pGetArgSpec) {
+  if (!pGetArgSpec) { // search for getfullargspec
+    PyObject * pName = PyUnicode_FromString("inspect");
+    PyObject * pModule = PyImport_Import(pName);
+    Py_XDECREF(pName); pName=NULL;
+    pGetArgSpec = PyObject_GetAttrString(pModule, "getfullargspec");
+  }
+
+  if (!pGetArgSpec) { // getargspec deprecated since Python 3.0, removed in 3.11
     PyObject * pName = PyUnicode_FromString("inspect");
     PyObject * pModule = PyImport_Import(pName);
     Py_XDECREF(pName); pName=NULL;
     pGetArgSpec = PyObject_GetAttrString(pModule, "getargspec");
   }
 
+  if (!pGetArgSpec) {
+    PyErr_Print();
+    GYOTO_ERROR("Failed finding method getargspec or getfullargspec in module inspect");
+  }
+  
   PyObject * pArgSpec =
     PyObject_CallFunctionObjArgs(pGetArgSpec, pMethod, NULL);
   bool answer = (PyTuple_GetItem(pArgSpec, 1) != Py_None);
