search for: have_pystring_fromstring

Displaying 11 results from an estimated 11 matches for "have_pystring_fromstring".

2019 Sep 11
0
[PATCH nbdkit] python: Drop support for Python 2.
...ious functions needed by the bindings. - old_LIBS="$LIBS" - - PYTHON_BLDLIBRARY=`$PYTHON -c "import distutils.sysconfig; \ - print (distutils.sysconfig.get_config_var('BLDLIBRARY'))"` - AC_CHECK_LIB([c],[PyString_FromString], - [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1, - [Found PyString_FromString in libpython.])], - [],[$PYTHON_BLDLIBRARY]) - AC_CHECK_LIB([c],[PyString_AsString], - [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, - [Found PyString_AsString in libpython.])], -...
2019 Sep 11
3
[PATCH nbdkit] python: Drop support for Python 2.
This patch proposes to drop support for Python 2 in nbdkit. Rather than abruptly drop it everywhere, my proposal is that we point people to nbdkit 1.14 (the current stable version) if they want to continue with Python 2 plugins, while gently reminding them of the upcoming Python 2.7 end of life announcement. Libnbd never supported Python 2. Libguestfs in theory supports Python 2 but I dropped
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
In preparation for adding other optional flag arguments to the python bindings, start by making the existing 'may_trim' flag to 'zero' be optional. That is, the plugin need not define the parameter if it does not make any semantic difference (ie. if the plugin ignores the hint and never trims); while if the parameter exists, we now pass it as a keyword argument rather than as a
2018 Aug 08
2
[PATCH nbdkit] python: Try harder to print the full traceback on error.
...ow.com/a/15907460/7126113 + */ +static int +print_python_traceback (const char *callback, + PyObject *type, PyObject *error, PyObject *traceback) +{ + PyObject *module_name, *traceback_module, *format_exception_fn, *rv, + *traceback_str; + char *traceback_cstr; + +#ifdef HAVE_PYSTRING_FROMSTRING + module_name = PyString_FromString ("traceback"); +#else + module_name = PyUnicode_FromString ("traceback"); +#endif + traceback_module = PyImport_Import (module_name); + Py_DECREF (module_name); + + /* couldn't 'import traceback' */ + if (traceback_module ==...
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python, these are independent enough to push now (and I'll have to rebase my 'optional may_trim' patch on top of this). Eric Blake (2): python: Use Py_XDEFREF() python: Simplify calling into plugin plugins/python/python.c | 106 ++++++++---------------------------------------- 1 file changed, 18 insertions(+), 88
2018 Aug 08
0
Re: [PATCH nbdkit] python: Try harder to print the full traceback on error.
...t; +print_python_traceback (const char *callback, > + PyObject *type, PyObject *error, PyObject > *traceback) > +{ > + PyObject *module_name, *traceback_module, *format_exception_fn, *rv, > + *traceback_str; > + char *traceback_cstr; > + > +#ifdef HAVE_PYSTRING_FROMSTRING > + module_name = PyString_FromString ("traceback"); > +#else > + module_name = PyUnicode_FromString ("traceback"); > +#endif > + traceback_module = PyImport_Import (module_name); > + Py_DECREF (module_name); > + > + /* couldn't 'import trace...
2018 Apr 05
0
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors properly.
...s(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index be38c84..c4c04d3 100644 --- a/configure.ac +++ b/configure.ac @@ -270,6 +270,14 @@ AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[ [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1, [Found PyString_FromString in libpython.])], [],[$PYTHON_BLDLIBRARY]) + AC_CHECK_LIB([c],[PyString_AsString], + [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, + [Found PyString_AsString in libpython.])], +...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...ILE *fp; PyObject *modname; PyObject *fn; - PyObject *args; PyObject *r; if (!script) { @@ -258,17 +257,8 @@ py_config (const char *key, const char *value) /* Other parameters are passed to the Python .config callback. */ PyErr_Clear (); - args = PyTuple_New (2); -#ifdef HAVE_PYSTRING_FROMSTRING - PyTuple_SetItem (args, 0, PyString_FromString (key)); - PyTuple_SetItem (args, 1, PyString_FromString (value)); -#else - PyTuple_SetItem (args, 0, PyUnicode_FromString (key)); - PyTuple_SetItem (args, 1, PyUnicode_FromString (value)); -#endif - r = PyObject_CallObject (fn, args); +...
2018 Apr 11
0
[nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional
...) + return 1; + } + return 0; +} + +/* Does a callback support the given keyword parameter? */ +static int +callback_has_parameter (PyObject *fn, const char *name) +{ + int r = 0; + PyObject *inspect, *pname, *spec, *args; + + assert (script != NULL); + assert (module != NULL); + +#ifdef HAVE_PYSTRING_FROMSTRING + pname = PyString_FromString ("inspect"); +#else + pname = PyUnicode_FromString ("inspect"); +#endif + if (!pname) + return -1; + inspect = PyImport_Import (pname); + Py_DECREF (pname); + + if (!inspect) + return -1; + +#if PY_MAJOR_VERSION >= 3 + pname = PyUnic...
2018 Apr 05
4
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors
Much more annoying that it needs to be, but I have tested it and it works on Python 2 & 3. Note this will not work on Python 3.0 - 3.2, but I guess we don't care about those versions. Rich.
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for reference, I added 'zero' support for python, perl, and ruby back in 1.1.13, then Rich had to add it for ocaml in 1.1.20). I tested this heavily under python 2, but for now only compile tested under python 3; I plan to do further testing there and make any tweaks if necessary. I wrote patch 5 early on, but then realized I