search for: pymoduledef

Displaying 12 results from an estimated 12 matches for "pymoduledef".

Did you mean: moduledef
2019 Sep 11
0
[PATCH nbdkit] python: Drop support for Python 2.
...ack"); -#else module_name = PyUnicode_FromString ("traceback"); -#endif traceback_module = PyImport_Import (module_name); Py_DECREF (module_name); @@ -222,7 +210,6 @@ check_python_failure (const char *callback) return 0; } -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "nbdkit", @@ -234,25 +221,18 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif static PyMODINIT_FUNC create_nbdkit_module (void) { PyObject *m; -#if PY_MAJOR_VERSION >= 3 m = PyModule_Create (&moduledef);...
2020 Mar 23
2
Re: [PATCH nbdkit 3/3] python: Remove extraneous static keyword
...gins/python/python.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/plugins/python/python.c b/plugins/python/python.c > index a1a0438b..adc1aaa5 100644 > --- a/plugins/python/python.c > +++ b/plugins/python/python.c > @@ -224,7 +224,7 @@ static struct PyModuleDef moduledef = { > NULL > }; > > -static PyMODINIT_FUNC > +PyMODINIT_FUNC > create_nbdkit_module (void) > { > PyObject *m; > -- I don't believe this is correct. We call PyImport_AppendInittab ("nbdkit", create_nbdkit_module); later on so the f...
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
2020 Mar 23
0
[PATCH nbdkit 3/3] python: Remove extraneous static keyword
...revents building on MSYS2. --- plugins/python/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/python/python.c b/plugins/python/python.c index a1a0438b..adc1aaa5 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -224,7 +224,7 @@ static struct PyModuleDef moduledef = { NULL }; -static PyMODINIT_FUNC +PyMODINIT_FUNC create_nbdkit_module (void) { PyObject *m; -- 2.25.0
2019 Jun 28
3
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
This kind of fixes the problems in v1. The exception still primarily lives in the libnbdmod and you could still refer to it using libnbdmod.Error (but don't do that). However when the exception is printed it now appears as nbd.Error, and you can catch it also using the same name. Other problems: - There is no "nice" interface to accessing the exception fields. You have to use
2020 Mar 23
0
Re: [PATCH nbdkit 3/3] python: Remove extraneous static keyword
...gt; 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/plugins/python/python.c b/plugins/python/python.c > > index a1a0438b..adc1aaa5 100644 > > --- a/plugins/python/python.c > > +++ b/plugins/python/python.c > > @@ -224,7 +224,7 @@ static struct PyModuleDef moduledef = { > > NULL > > }; > > > > -static PyMODINIT_FUNC > > +PyMODINIT_FUNC > > create_nbdkit_module (void) > > { > > PyObject *m; > > -- > > I don't believe this is correct. We call > > PyImport_AppendInittab (&...
2019 Jun 28
0
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
...() +{ + PyObject *args = PyTuple_New (2); + + PyTuple_SetItem (args, 0, PyUnicode_FromString (nbd_get_error ())); + PyTuple_SetItem (args, 1, PyLong_FromLong (nbd_get_errno ())); + PyErr_SetObject (nbd_internal_py_Error, args); +} + "; List.iter ( @@ -3390,6 +3403,9 @@ static struct PyModuleDef moduledef = { NULL, /* m_free */ }; +/* nbd.Error exception. */ +PyObject *nbd_internal_py_Error; + extern PyMODINIT_FUNC PyInit_libnbdmod (void); PyMODINIT_FUNC @@ -3401,6 +3417,19 @@ PyInit_libnbdmod (void) if (mod == NULL) return NULL; + nbd_internal_py_Erro...
2019 Jun 28
1
[PATCH libnbd] python: Raise a custom exception containing error string and errno.
I spent a good few hours this morning trying to make this work and came up with the following patch. It's not quite right though. The exception I've created exists in the libnbdmod module (ie. the underlying C module that we use for the Python bindings). Ideally we'd define and throw an exception from the normal nbd module, but I couldn't work out how to do that. Probably
2019 Jun 28
0
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...() +{ + PyObject *args = PyTuple_New (2); + + PyTuple_SetItem (args, 0, PyUnicode_FromString (nbd_get_error ())); + PyTuple_SetItem (args, 1, PyLong_FromLong (nbd_get_errno ())); + PyErr_SetObject (nbd_internal_py_Error, args); +} + "; List.iter ( @@ -3390,6 +3403,9 @@ static struct PyModuleDef moduledef = { NULL, /* m_free */ }; +/* nbd.Error exception. */ +PyObject *nbd_internal_py_Error; + extern PyMODINIT_FUNC PyInit_libnbdmod (void); PyMODINIT_FUNC @@ -3401,6 +3417,11 @@ PyInit_libnbdmod (void) if (mod == NULL) return NULL; + nbd_internal_py_Erro...
2020 Mar 23
6
[PATCH nbdkit 0/3] msys2 support for review
I pushed a few of the msys2 patches upstream. I changed the way that $(SHARED_LDFLAGS) works so it's more to my liking, and the others were pushed unchanged. Three patches remain which I'm posting on the mailing list for proper review. Rich.
2019 Jun 28
3
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Following Eric's suggestions from v2, this adds .string, .errno and .__str__ properties. The .string property returns the error string. The .errno property returns the errno (from the errno module), or None. The __str__ property makes the exception nicely printable. Rich.
2012 Mar 28
0
[LLVMdev] GSoC 2012 Proposal: Python bindings for LLVM
...ttention to the C API changes between Python 2.x and Python 3. Here I list some of them. 1. Extension module initialization and finalization (PEP 3121) [2] In Python 3, the module initialization routines should look like this: *PyObject *PyInit_<modulename>()* When creating a module, a struct PyModuleDef should be passed as a parameter. 2. Making PyObject_HEAD conform to standard C (PEP 3123) [3] Some macros are added, for instance, *PY_TYPE, PY_REFCNT,PY_SIZE*. So a code block *func->ob_type->tp_name* in Python 2.x should be replaced with * PY_TYPE(func)->ty_nam*e in Python 3. 3. Byte vec...