Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKQeN-0006Oe-SK for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2023 21:16:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKQeM-0004RN-O9 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2023 21:16:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKQeM-0004RE-FE for pgsql-hackers@lists.postgresql.org; Tue, 24 Jan 2023 21:16:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKQeK-0002ro-Cs for pgsql-hackers@postgresql.org; Tue, 24 Jan 2023 21:16:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30OLG67a2320615; Tue, 24 Jan 2023 16:16:06 -0500 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgresql.org, Peter Eisentraut , Andrew Dunstan Subject: Re: plpython vs _POSIX_C_SOURCE In-reply-to: <20230124190721.mi7l5c3n2tsrqjno@awork3.anarazel.de> References: <20230124165814.2njc7gnvubn2amh6@awork3.anarazel.de> <2265665.1674582915@sss.pgh.pa.us> <20230124190721.mi7l5c3n2tsrqjno@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 24 Jan 2023 11:07:21 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2320613.1674594966.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 24 Jan 2023 16:16:06 -0500 Message-ID: <2320614.1674594966@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > Python's _POSIX_C_SOURCE value is set to a specific value in their confi= gure > script: > if test $define_xopen_source =3D yes > then > ... > AC_DEFINE(_POSIX_C_SOURCE, 200809L, Define to activate features from I= EEE Stds 1003.1-2008) > fi Hm. I looked into Python 3.2 (the oldest release we still support) and it has similar code but AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEE= E Stds 1003.1-2001) So yeah it's fixed (or else not defined) for any particular Python release, but could vary across releases. > Solaris and AIX are the ones missing. > I guess I'll test them manually. It seems promising not to need this stu= ff > anymore? Given that hoverfly is AIX, I'm betting there's an issue there. >> Anyway, I'm still of the opinion that what a11cf433413 tried to do >> was the best available fix, and we need to do whatever we have to do >> to plpython's headers to reinstate that coding rule. > You think it's not a viable path to just remove the _POSIX_C_SOURCE, > _XOPEN_SOURCE undefines? I think at the least that will result in warnings on some platforms, and at the worst in actual build problems. Maybe there are no more of the latter a dozen years after the fact, but ... >> That would be nice. This old code was certainly mostly concerned with >> python 2, maybe python 3 no longer does that? > There's currently no non-comment references to *printf in their headers.= The > only past reference was removed in: > commit e822e37946f27c09953bb5733acf3b07c2db690f > Author: Victor Stinner > Date: 2020-06-15 21:59:47 +0200 > bpo-36020: Remove snprintf macro in pyerrors.h (GH-20889) Oh, interesting. > Which suggests an easier fix would be to just to do > /* > * Python versions <=3D 3.8 otherwise define a replacement, causing > * macro redefinition warnings. > */ > #define HAVE_SNPRINTF > And have that be enough for all python versions? Nice idea. We did not have that option while we were using HAVE_SNPRINTF ourselves, but now that we are not I concur that this should work. (I confirmed that their code looks the same in Python 3.2.) Note that you'd better make it #define HAVE_SNPRINTF 1 or you risk macro-redefinition warnings. regards, tom lane