Commit Graph

17 Commits

Author SHA1 Message Date
Boulanger
8ddfd12a76 Bindings transition from python 3.11 to 3.13
Fix ada method descriptor creation in Cpython: since python3.12
the ada method descriptor type must be properly defined and
handle computation of __name__ and __qualname__.

Fix internal testsuite related to API changes of e3 and
add a test.

Fix CI using old component names

Depends-On: eng/shared/anod!7814

For eng/ide/gnatstudio#486
2026-02-11 16:19:39 +01:00
Olivier Hainque
0993f57d57 Fix python3/python_support.c redef of PyMODINIT_FUNC for Windows
The base PyMODINIT_FUNC (without attributes) is PyObject* in python3,
not void. Adjust the redefinition we do on Windows to remove a declspec
accordingly.
2024-05-29 12:06:45 +02:00
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
Vadim Godunko
8313f88587 V927-001 Return correct value and remove unused variable.
Change-Id: Ia7b4a80b904710c235a159f8a1e6318e70d776ae
2022-09-30 10:38:06 +04:00
Adrien Boulanger
1624f7e808 U914-005: Transition from python 3.7 to 3.9
- Disable the new vectorcall API (the tp_call profile only
supports the old call format).
- Add missing GIL locks
- Manually config python to use utf-8 (this was automatic with
previous versions)

Change-Id: I214b53e1e1b4fbc2a9af1cf1ec8985cff7905a55
2021-12-01 12:08:28 +01:00
Adrien Boulanger
7a272ebf03 U305-023: Defensive code for the GIL
Trying to ensure/release the GIL when there is no interpreter will
raise an exception.

Change-Id: I4f85bfbfdd799b906848d2038b52825c4c709e54
2021-03-19 12:34:13 +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
1b4bf35ad9 TC21-029: Fix PyAdaMethodDescrObject function call
The cfunc is stored inside the descriptor when doing:

f = Foo()
f.bar() => cfunc is retrieved via tp_descr_get
Foo.bar(f) => cfunc is retrieved via tp_call

Without defining tp_call it will try to call a
wrapping function without the proper flags.

Change-Id: I164492895cee66dd4d9946b505c6866c2fea768a
2021-02-12 11:14:20 +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
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
092c3262db Fix issue with Initialize_Py_And_Module.
Replace wrong cast from char* to wchar_t* by Py_DecodeLocale call

Part of S821-014

Change-Id: I574c93587640284c78b0bd04bc0b3c082441186b
2020-05-25 12:29:19 +00:00
Nicolas Roche
0c7be0a295 Remove reference to Python 2.x in python3/python_support.c
Part of S821-014
Change-Id: Ifc5e6a65f5802455a3c23e61c9b75cdba20c23f6
2020-05-25 07:39:02 +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
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