]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.0724: if_python: link error with python 3.13 and stable ABI v9.1.0724
authorYee Cheng Chin <ychin.git@gmail.com>
Mon, 9 Sep 2024 17:55:24 +0000 (19:55 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 9 Sep 2024 17:55:24 +0000 (19:55 +0200)
commitc2285a8cf397d1d694a350415fb37f7d51202ec4
tree001856fe4805735d0d668f28a094aab1bdbd1911
parent97a5be46879ab2b24bb9b485966be031865e1191
patch 9.1.0724: if_python: link error with python 3.13 and stable ABI

Problem:  if_python: link error with python 3.13 and stable ABI
          (zdohnal)
Solution: Use the correct stable APIs Py_IncRef and Py_DecRef instead
          (Yee Cheng Chin)

This fixes #15460 properly. There was an attempt to fix it in v9.1.0668,
but it did it by manually copy and pasting definitions from Python 3.13
headers, which is problematic as it makes Vim dependent on low-level
implementation details which are subject to change. That change also
pulls in dependencies to private APIs (`_Py_IncRef`) which is a very bad
idea as the next version of Python could very well remove that.

The core issue was simply that `Py_INCREF` and similar functions are not
part of the stable API. We are supposed to be using `Py_IncRef` instead
which performs null-check (similar to `Py_XINCREF`) and is available as
a linkable function. We simply need to call it instead of the macro.
We simply remap `Py_INCREF` (and friends) to the function version in
stable API similar to how we mapped other functions.

related #15460
closes: #15648

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