search for: py_ssize_t

Displaying 20 results from an estimated 27 matches for "py_ssize_t".

2010 Aug 22
1
Difficulty compiling 4.0.0alpha11 on RHEL 5, "Py_ssize_t" undeclared in net.c
Line 59 of samba4.0.0-alpha11/source4/utils/net.c file, at line 59 uses "Py_ssize_t", which was not defined in Python until Python 2.5. This causes havoc trying to compile it on RHEL 5, which uses Python 2.4 and which I cannot recommend upgrading the Python for in a production server environment. (I've tried that: it causes dependency hell in RHEL.) So, I suggest adding...
2010 Oct 13
1
[PATCH]: pyxl: fix build of python xl binding for python < 2.5
The python C API introduced Py_ssize_t in version 2.5. Prior to this int''s were used instead. Fix the build by way of a heinous preprocessor macro. diff -r 38ad3633ecaf tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Wed Oct 13 12:01:30 2010 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Wed Oct 13 17:...
2024 Jan 31
4
Bug#1062048: xen: FTBFS with Python 3.12 as default
...~~~ In file included from /usr/include/python3.12/Python.h:53: /usr/include/python3.12/cpython/longintrepr.h: In function ?_PyLong_CompactValue?: /usr/include/python3.12/cpython/longintrepr.h:121:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 121 | Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK); | ^~~~~~~~~~ cc1: all warnings being treated as errors error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...; +} > + > +static int > +py_extents (void *handle, uint32_t count, uint64_t offset, > + uint32_t flags, struct nbdkit_extents *extents) > +{ > + ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; > + struct handle *h = handle; > + PyObject *fn; > + PyObject *r; > + Py_ssize_t i, size; > + > + if (callback_defined ("extents", &fn)) { > + PyErr_Clear (); > + > + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) &gt...
2017 May 21
0
[PATCH 2/2] python: unicode decode handler error scheme setter
...string (previous_handler); +} + +PyObject * guestfs_int_py_create (PyObject *self, PyObject *args) { guestfs_h *g; @@ -386,7 +399,8 @@ guestfs_int_py_fromstring (const char *str) #ifdef HAVE_PYSTRING_ASSTRING return PyString_FromString (str); #else - return PyUnicode_FromString (str); + Py_ssize_t size = strlen(str); + return PyUnicode_DecodeUTF8 (str, size, decode_error_handler); #endif } @@ -396,7 +410,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) #ifdef HAVE_PYSTRING_ASSTRING return PyString_FromStringAndSize (str, size); #else - return PyUnicode_FromStringAn...
2020 Aug 10
5
[PATCH nbdkit] python: Implement can_extents + extents.
...dle, "can_extents", "extents"); +} + +static int +py_extents (void *handle, uint32_t count, uint64_t offset, + uint32_t flags, struct nbdkit_extents *extents) +{ + ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; + struct handle *h = handle; + PyObject *fn; + PyObject *r; + Py_ssize_t i, size; + + if (callback_defined ("extents", &fn)) { + PyErr_Clear (); + + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); + Py_DECREF (fn); + if (check_python_failure ("extents") == -1) + return -1; + + /* We expect...
2020 Aug 10
2
[PATCH nbdkit] python: Allow extents to return any iterable (which includes lists).
...ff --git a/plugins/python/python.c b/plugins/python/python.c index 46b912e2..27c5ede2 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -1035,7 +1035,8 @@ py_extents (void *handle, uint32_t count, uint64_t offset, struct handle *h = handle; PyObject *fn; PyObject *r; - Py_ssize_t i, size; + PyObject *iter, *t; + size_t size; if (callback_defined ("extents", &fn)) { PyErr_Clear (); @@ -1045,29 +1046,25 @@ py_extents (void *handle, uint32_t count, uint64_t offset, if (check_python_failure ("extents") == -1) return -1; - /*...
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...; +} > + > +static int > +py_extents (void *handle, uint32_t count, uint64_t offset, > + uint32_t flags, struct nbdkit_extents *extents) > +{ > + ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; > + struct handle *h = handle; > + PyObject *fn; > + PyObject *r; > + Py_ssize_t i, size; > + > + if (callback_defined ("extents", &fn)) { > + PyErr_Clear (); > + > + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) &gt...
2017 May 21
3
[PATCH 0/2] python: improved UTF8 decoding error handling
The Python 3 bindings currently are unable to deal with non UTF8 characters. This series continues what proposed in RHBZ#1406906. A new function 'set_decode_error_handler' allows the User to specify how to deal with decoding errors. The default behaviour will be raising a UnicodeDecodeError. If the handler is changed to 'surrogateescape', non UTF8 characters will be escaped in a
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...@@ -271,7 +271,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | BytesIn (n, _) -> pr " Py_buffer %s;\n" n | BytesOut (n, count) -> - pr " char *%s;\n" n; + pr " char *%s = NULL;\n" n; pr " Py_ssize_t %s;\n" count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> @@ -279,11 +279,10 @@ let print_python_binding name { args; optargs; ret; may_set_error } = n; pr " struct py_aio_buffer *%s_buf;\n" n | Closure { cbname } -> - pr "...
2020 Sep 29
2
[PATCH libnbd] generator: Add SizeT type, maps to C size_t.
...- a/generator/Python.ml +++ b/generator/Python.ml @@ -295,6 +295,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | Path n -> pr " PyObject *py_%s = NULL;\n" n; pr " char *%s = NULL;\n" n + | SizeT n -> + pr " Py_ssize_t %s;\n" n | SockAddrAndLen (n, _) -> pr " /* XXX Complicated - Python uses a tuple of different\n"; pr " * lengths for the different socket types.\n"; @@ -341,6 +343,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = |...
2020 Jan 09
9
[PATCH 0/7] Various Python cleanups.
Patch #7 depends on: https://www.redhat.com/archives/libguestfs/2020-January/msg00035.html No, Python < 3 support is not dropped yet, however it will be easier after this series. Pino Toscano (7): build: enforce a minimum Python version python: drop code for Python < 2.5 python: assume support for Capsules python: remove compile time check for PyString_AsString python: replace
2020 Jan 30
2
[PATCH libnbd] python: Add AIO buffer is_zero method.
...static inline PyObject * @@ -213,3 +215,48 @@ nbd_internal_py_aio_buffer_size (PyObject *self, PyObject *args) return PyLong_FromSsize_t (buf->len); } + +PyObject * +nbd_internal_py_aio_buffer_is_zero (PyObject *self, PyObject *args) +{ + PyObject *obj; + struct py_aio_buffer *buf; + Py_ssize_t offset, size; + + if (!PyArg_ParseTuple (args, + (char *) "Onn:nbd_internal_py_aio_buffer_size", + &obj, &offset, &size)) + return NULL; + + if (size == 0) + Py_RETURN_TRUE; + + buf = nbd_internal_py_get_aio_buffer (obj)...
2015 Oct 20
3
[PATCH 1/2] generator: add a RelativePathnameList parameter type
...) diff --git a/generator/python.ml b/generator/python.ml index 1e043fc..b8329a5 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -292,7 +292,7 @@ put_table (char * const * const argv) | BufferIn n -> pr " const char *%s;\n" n; pr " Py_ssize_t %s_size;\n" n - | StringList n | DeviceList n -> + | StringList n | DeviceList n | RelativePathnameList n -> pr " PyObject *py_%s;\n" n; pr " char **%s = NULL;\n" n | Bool n -> pr " int %s;\n" n @@ -326,...
2014 Aug 04
6
[hivex] Segfault for an integer value to node_set_value
Hi, When an integer argument is passed as value, node_set_value segfaults. Reproducer is at the end of this message The backtrace points at hivex-py.c, function get_value. While obj is non-NULL, `bytes = PyUnicode_AsUTF8String (obj);` returns NULL. Kind regards, Peter https://lekensteyn.nl #!/usr/bin/env python3 import hivex, sys h = hivex.Hivex(sys.argv[1]) print(h) val = {
2015 Oct 21
2
[PATCH 1/2] generator: add a FilenameList parameter type
...) diff --git a/generator/python.ml b/generator/python.ml index 1e043fc..9b3037c 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -292,7 +292,7 @@ put_table (char * const * const argv) | BufferIn n -> pr " const char *%s;\n" n; pr " Py_ssize_t %s_size;\n" n - | StringList n | DeviceList n -> + | StringList n | DeviceList n | FilenameList n -> pr " PyObject *py_%s;\n" n; pr " char **%s = NULL;\n" n | Bool n -> pr " int %s;\n" n @@ -326,7 +326,7...
2010 Sep 09
2
[PATCH]: add libxl python binding
...ytearray_set(PyObject *v, uint8_t *ptr, size_t len) +{ + char *tmp; + size_t sz; + + if ( NULL == v ) { + memset(ptr, 0, len); + return 0; + } + if ( PyByteArray_Check(v) ) { + sz = PyByteArray_Size(v); + tmp = PyByteArray_AsString(v); + }else{ + Py_ssize_t ssz; + if ( PyString_AsStringAndSize(v, &tmp, &ssz) ) + return -1; + if ( ssz < 0 ) + tmp = NULL; + sz = ssz; + } + if ( NULL == tmp ) { + memset(ptr, 0, len); + return 0; + } + if ( sz != len ) { + PyErr_SetStri...
2017 Jun 15
0
[PATCH v6 11/41] utils: Rename ‘guestfs-internal-frontend.h’ to ‘utils.h’.
.../python.ml +++ b/generator/python.ml @@ -42,7 +42,7 @@ let rec generate_python_actions_h () = #define GUESTFS_PYTHON_ACTIONS_H_ #include \"guestfs.h\" -#include \"guestfs-internal-frontend.h\" +#include \"utils.h\" #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; diff --git a/generator/ruby.ml b/generator/ruby.ml index 825cab32a..75a93398d 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -55,7 +55,7 @@ let rec generate_ruby_h () = #endif #include \"guestfs.h\" -#include \"guestfs-internal-frontend.h\" /* Only for POINTER_NO...
2017 Jun 19
0
[PATCH v7 12/13] utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
...ml +++ b/generator/python.ml @@ -42,7 +42,7 @@ let rec generate_python_actions_h () = #define GUESTFS_PYTHON_ACTIONS_H_ #include \"guestfs.h\" -#include \"guestfs-internal-frontend.h\" +#include \"guestfs-utils.h\" #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; diff --git a/generator/ruby.ml b/generator/ruby.ml index 825cab32a..f209109ee 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -55,7 +55,7 @@ let rec generate_ruby_h () = #endif #include \"guestfs.h\" -#include \"guestfs-internal-frontend.h\" /* Only for POINTER_NO...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must