search for: pydict_getitemstring

Displaying 6 results from an estimated 6 matches for "pydict_getitemstring".

2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
...ret) +get_value (PyObject *v, hive_set_value *ret, uint64_t *word) { PyObject *obj; -#ifndef HAVE_PYSTRING_ASSTRING PyObject *bytes; -#endif + + if (!PyDict_Check (v)) { + PyErr_SetString (PyExc_TypeError, \"expected dictionary type for value\"); + return -1; + } obj = PyDict_GetItemString (v, \"key\"); if (!obj) { - PyErr_SetString (PyExc_RuntimeError, \"no 'key' element in dictionary\"); + PyErr_SetString (PyExc_KeyError, \"no 'key' element in dictionary\"); + return -1; + } + if (PyUnicode_Check (obj)) { + bytes = PyUn...
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...ode to figure out how > > to check for a python global variable, compared to the glue code we > > already have for calling a python function. > > The extra glue code is (without error handling): > > PyObject *d = PyModule_GetDict(PyObject *module); > PyObject *v = PyDict_GetItemString(d, "API_VERSION"); > long api_version = PyLong_AsLong(v); Or simpler (with error handling): PyObject *v = PyObject_GetAttrString(m, "API_VERSION"); if (v == NULL) return 1; long value = PyLong_AsLong(v); Py_DECREF(m); return value; On erro...
2014 Aug 16
7
[hivex] [PATCH 0/6] Python fixes for node_set_value
Hi, This patch series is based on a prior patch[1], splitting off changes as requested and incorporating feedback from Richard Jones. It introduces type validation to avoid segmentation faults (instead, it reports an exception) and fixes handling of the bytes type in Python 3. Major changes since that series: - Drop newly introduced support for integer types for DWORD/QWORDS - Reject Unicode
2019 Nov 22
4
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On 11/22/19 3:20 PM, Nir Soffer wrote: >>> +# There are several variants of the API. nbdkit will call this >>> +# function first to determine which one you want to use. This is the >>> +# latest version at the time this example was written. >>> +def api_version(): >>> + return 2 >> >> Matches the C counterpart of #define
2019 Nov 22
0
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...But it is that much more glue code to figure out how > to check for a python global variable, compared to the glue code we > already have for calling a python function. The extra glue code is (without error handling): PyObject *d = PyModule_GetDict(PyObject *module); PyObject *v = PyDict_GetItemString(d, "API_VERSION"); long api_version = PyLong_AsLong(v);
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 = {