]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.0726: not using correct python3 API with dynamic linking v9.1.0726
authorYee Cheng Chin <ychin.git@gmail.com>
Tue, 10 Sep 2024 18:56:13 +0000 (20:56 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 10 Sep 2024 18:56:13 +0000 (20:56 +0200)
commit508403687d3538a99fc900ff9e9951ec788ac421
tree08e1ed26daf432c6f337e077f4011bfd9d4d44e4
parentc0982f9f794a4c5737d3d7a3129b3121ab20e458
patch 9.1.0726: not using correct python3 API with dynamic linking

Problem:  not using correct python3 API with dynamic linking
Solution: Use stable IncRef / DecRef in Python 3 dynamic bindings
          (Yee Cheng Chin)

Previously, we were using the Py_DECREF macros even when using dynamic
linking of Python 3. This caused issues because Python's headers contain
references to internal APIs like `_Py_Dealloc` and in v8.1.2201 and
v8.2.1225 we simply hacked around the issue by manually copying the
Python header implementation to Vim and linking in the private APIs.
This is fragile and prone to break. In fact, the Py_DECREF
implementation is different in newer versions of Python meaning that
this could potentially cause memory issues.

Instead, simply use the API versions (`Py_DECREF` and `Py_INCREF`) which
are functions exposed by the Python library. They could be slightly
slower since they require a function call instead of a macro, but are
much more reliable and we should only be calling these when the Python
Vim plugins are crossing the language boundary anyway which are always
going to be slow.

Note that this only affects dynamically linked Python builds that are
not using stable ABI.

Also see #15648

closes: #15653

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/if_python3.c
src/version.c