11 Commits

Author SHA1 Message Date
Nicolas Roche
cd650de5e3 Add minimal support for Python 3.11
Part of eng/toolchain/gnatcoll-bindings#1
2023-10-31 11:41:09 +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
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
af397296fd Move declaration of python thread related bindings under GNATCOLL.Python
* Move PyEval_SaveThread to GNATCOLL.Python.Eval
* Move PyEval_RestoreThread to GNATCOLL.Python.Eval
* Move PyThreadState to GNATCOLL.Python
* Remove binding to PyEval_InitThreads (not needed since 3.7)
* Remove Has_Thread_Support (we assume python 3 always have thread
support)

Part of S821-014

Change-Id: I037b19be518a36600663df20d34f233c91bc4139
2020-05-27 07:00:24 +00:00
Nicolas Roche
d17cadce7f Move PyErr_Occured to GNATCOLL.Python.Errors
Part of S821-014

Change-Id: Ibff41518354899137b19782803247dce39654614
2020-05-27 07:00:24 +00:00
Nicolas Roche
74d32011ca Renames GetTypeObject into Py_TYPE.
This ensures function name maps to C API.
Also renames Dummy type into PyObject_Opaque as the type will be
used in other units.

Part of S821-014

Change-Id: I14a2d05897480c4dbfb3f04a2fe45567d2385a7b
2020-05-25 12:33:38 +00:00
Nicolas Roche
955181d8af Move Py_Initialize and Py_Finalize to GNATCOLL.Python.Lifecycle
Part of S821-014

Change-Id: I5c62565f7af598a692d96a560d7482d349ebd4ee
2020-05-25 12:29:19 +00: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
d658e6f9f4 Fix minimum Python version in python3/ subdirectory
Change-Id: Idbf2bbd5c1095acf2f93c5619c29ee3ae9b40e41
TN: S821-014
2020-05-13 09:15:48 -07: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