8 Commits

Author SHA1 Message Date
Adrien Boulanger
0decdc2341 VA24-029: Fix invalid conversion to C strings
Missing ASCII.NUL to be a valid C string

Change-Id: I70f2368523648d257d3c0b5dc59e10ee76f1db8a
2022-11-02 16:47:26 +01:00
Adrien Boulanger
fc63e2906b U201-012: Ensure frame state when calling python function.
Most of the commands can only be called if we have the GIL:
retrieve it.
Add a controlled type to automatically retrieve/free the GIL.
Lock every call using Py_INCREF/Py_DECREF.

Change-Id: I8989fcb3eacf6aedbb90056469536144a2795a3f
2021-02-25 11:17:13 +01:00
Adrien Boulanger
45aaa42efc TC15-079: Remove forbidden flags METH_OLDARGS
METH_OLDARGS (0x0, i.e. no flag) was obsolete in python2
and is forbidden with python3.

(no-precommit-check)
Change-Id: I576042492d74ca69bd59ed6ea6264cb7562c650f
2021-02-12 11:18:02 +01:00
Nicolas Roche
6140ee8e69 Remove simulation of PyCObjects in Python 3.x
Capsules should be used instead. Tentative of PyCObject simulation
cannot work as destructors associated with PyCObject and PyCapsule
do not have the same semantic (one receive the encapsulated C
pointer and the other the capsule).

This fix also memory issues in GNATCOLL.Scripts.Python

Part of T601-026

Change-Id: Id1793d255998a55b10d507deff1ce707d79a8932
2020-06-16 09:55:43 +00:00
Nicolas Roche
928b7b25b3 Fix issue with declaration of static method with GNATCOLL.Scripts.
Python 3.x modified the way CFunction with METH_STATIC flag are
called. Self attribute passed to PyCFunction_New is not passed
anymore to the C code. Removing the METH_STATIC flag ensure that
self is preserved. This ensure GNATCOLL.Scripts can bind C data
to the declared C function.

Part of S821-014
Part of T519-009

Change-Id: Ib51501df8302e2f0451924e954f3fb8b37ea89f1
2020-05-28 12:17:19 +02:00
Nicolas Roche
e259adfecb Fix issue with binding of the interpreter lifecycle functions
* Py_SetProgramName expect a *wchar_t
* Py_SetPythonhome expect a *wchar_t
* Py_Main except decoded arguments as  *wchar_t
* Expose function Py_DecodeLocale

Part of T518-013

Change-Id: I3ad1df239203ecf70e5de7dfe78aed202cd21666
2020-05-22 16:05:10 +00:00
Joel Brobecker
3c0738d979 replace "Import" aspects with simple pragma "Import".
This is to keep things consistent throughout the Python binding.
Eventually, we should switch imports to aspects, which are more
modern Ada, but this should be done for all imports at the same
time, to maintain consistency.

Change-Id: Id413db8e434a9e0e966773c2bf4e9429bd8a45f0
2020-02-14 19:32:52 +04:00
Nicolas Roche
4981602c6d Split support for Python 3.x and Python 2.x
Part of S821-014

Change-Id: I17a26eb45043f7fe48b5b33db57425abe8cd9b78
2020-02-07 10:26:11 +01:00