Subject: Re: [PATCH] pl: fix can not build free-thread for plpython extension like 3.14t

From: Tom Lane <[email-masked]>
Date: Thu, 15 Jan 2026 23:01:19 -0500

=?UTF-8?B?5rSq5LyK?= <[email-masked]> writes:
> This patch fix can not build plpython for free-thread python like
> python3.14t

We've gone to fairly considerable trouble to switch to using Python's
limited API, for reasons described here:

https://www.postgresql.org/message-id/[email-masked]

I don't see why we should abandon that for the convenience of
somebody's evidently-nonstandard Python build.

The proposed patch also breaks the header isolation that
the separate plpython_system.h header is meant to maintain.
Arguably we should have #define'd Py_LIMITED_API inside
plpython_system.h, not where it is.  But I don't feel a need
to mess with that without a far better argument for why
we should change this at all.

			regards, tom lane

---

From: 洪伊 <[email-masked]>
Date: Fri, 16 Jan 2026 12:33:18 +0800

Hi

I understand the reason for using Py_LIMITED_API, and python 3.14t is a
standard build from cpython team.

link:
https://docs.python.org/3/whatsnew/3.14.html#whatsnew314-free-threaded-now-supported

It seems the only way to build plpython for free-thread python is to use
Py_LIMITED_API, otherwise it fails to build.

Thanks
Hong Yi

---

From: Tom Lane <[email-masked]>
Date: Thu, 15 Jan 2026 23:43:33 -0500

> standard build from cpython team.

AIUI, the "limited API" was devised by the Python community as an
API/ABI subset that they are prepared to guarantee holds stable
for every Python 3.x release, full stop.  I think you're going
to have a hard time convincing us that there is anything standard
about a Python variant that can't handle client code built against
that API.

			regards, tom lane