1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Files
libgpiod/bindings/python/gpiod/ext/internal.h
Vincent Fazio 9106b6c190 bindings: python: use PyImport_ImportModuleAttrString() when available
Commit 035ad74fdd introduced Py_gpiod_GetModuleAttrString() as a way to
get a module's attribute and was inspired by CPython's internal function
_PyImport_GetModuleAttrString().

CPython 3.14 added PyImport_ImportModuleAttrString() to the public
API [0] which allows us to use the standard function when available.

[0]: https://github.com/python/cpython/pull/128912

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260423222125.29097-6-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-04-24 10:49:51 +02:00

27 lines
968 B
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl> */
#ifndef __LIBGPIOD_PYTHON_MODULE_H__
#define __LIBGPIOD_PYTHON_MODULE_H__
#include <gpiod.h>
#include <Python.h>
PyObject *Py_gpiod_SetErrFromErrno(void);
unsigned int Py_gpiod_PyLongAsUnsignedInt(PyObject *pylong);
void Py_gpiod_dealloc(PyObject *self);
PyObject *Py_gpiod_MakeRequestObject(struct gpiod_line_request *request,
size_t event_buffer_size);
struct gpiod_line_config *Py_gpiod_LineConfigGetData(PyObject *obj);
struct gpiod_line_settings *Py_gpiod_LineSettingsGetData(PyObject *obj);
#if PY_VERSION_HEX >= 0x030E0000
/* Alias to standard function available in 3.14 */
#define Py_gpiod_GetModuleAttrString PyImport_ImportModuleAttrString
#else
PyObject *Py_gpiod_GetModuleAttrString(const char *modname,
const char *attrname);
#endif /* PY_VERSION_HEX >= 0x030E0000 */
#endif /* __LIBGPIOD_PYTHON_MODULE_H__ */