From 5bb06199684b92c6252109b251051fa4a45ccac7 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Fri, 29 Nov 2024 19:48:37 +0800 Subject: [PATCH 1/4] Set `sys.abiflags` on Windows --- Doc/library/sys.rst | 9 ++++++--- Lib/test/test_sys.py | 3 +-- PC/pyconfig.h.in | 30 +++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 2bdfb337f02056..40c582f04e90bd 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -13,8 +13,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only .. data:: abiflags - On POSIX systems where Python was built with the standard ``configure`` - script, this contains the ABI flags as specified by :pep:`3149`. + On POSIX and Windows systems where Python was built with the standard + ``configure`` script, this contains the ABI flags as specified by :pep:`3149`. .. versionadded:: 3.2 @@ -22,7 +22,10 @@ always available. Unless explicitly noted otherwise, all variables are read-only Default flags became an empty string (``m`` flag for pymalloc has been removed). - .. availability:: Unix. + .. versionchanged:: 3.14 + The attribute was also added on Windows. + + .. availability:: Unix, Windows. .. function:: addaudithook(hook) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 87c0106ad30840..8be5832819c5f1 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -696,8 +696,7 @@ def test_attributes(self): self.assertTrue(vi > (1,0,0)) self.assertIsInstance(sys.float_repr_style, str) self.assertIn(sys.float_repr_style, ('short', 'legacy')) - if not sys.platform.startswith('win'): - self.assertIsInstance(sys.abiflags, str) + self.assertIsInstance(sys.abiflags, str) def test_thread_info(self): info = sys.thread_info diff --git a/PC/pyconfig.h.in b/PC/pyconfig.h.in index 9e70303868e5de..53d1566126066b 100644 --- a/PC/pyconfig.h.in +++ b/PC/pyconfig.h.in @@ -102,6 +102,23 @@ WIN32 is still required for the locale module. /* #define Py_GIL_DISABLED 1 */ #endif +/* Defined in debug builds */ +#ifdef _DEBUG +# define Py_DEBUG +#endif + +#ifdef Py_GIL_DISABLED +# define _ABIFLAGS_FREETHREADED "t" +#else +# define _ABIFLAGS_FREETHREADED "" +#endif +#ifdef Py_DEBUG +# define _ABIFLAGS_DEBUG "d" +#else +# define _ABIFLAGS_DEBUG "" +#endif +#define ABIFLAGS ("" _Py_STRINGIZE(_ABIFLAGS_FREETHREADED) _Py_STRINGIZE(_ABIFLAGS_DEBUG)) + /* Compiler specific defines */ /* ------------------------------------------------------------------------*/ @@ -319,21 +336,21 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ This is relevant when using build-system generator (e.g CMake) where the linking is explicitly handled */ # if defined(Py_GIL_DISABLED) -# if defined(_DEBUG) +# if defined(Py_DEBUG) # pragma comment(lib,"python314t_d.lib") # elif defined(Py_LIMITED_API) # pragma comment(lib,"python3t.lib") # else # pragma comment(lib,"python314t.lib") -# endif /* _DEBUG */ +# endif /* Py_DEBUG */ # else /* Py_GIL_DISABLED */ -# if defined(_DEBUG) +# if defined(Py_DEBUG) # pragma comment(lib,"python314_d.lib") # elif defined(Py_LIMITED_API) # pragma comment(lib,"python3.lib") # else # pragma comment(lib,"python314.lib") -# endif /* _DEBUG */ +# endif /* Py_DEBUG */ # endif /* Py_GIL_DISABLED */ # endif /* _MSC_VER && !Py_NO_LINK_LIB */ # endif /* Py_BUILD_CORE */ @@ -376,11 +393,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ # define ALIGNOF_MAX_ALIGN_T 8 #endif -#ifdef _DEBUG -# define Py_DEBUG -#endif - - #ifdef MS_WIN32 #define SIZEOF_SHORT 2 From 0e6bdcad471b67fdcc1bf7fef49e7c834d944998 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:36:47 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2024-11-30-13-36-44.gh-issue-127405.gLRZoT.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2024-11-30-13-36-44.gh-issue-127405.gLRZoT.rst diff --git a/Misc/NEWS.d/next/Windows/2024-11-30-13-36-44.gh-issue-127405.gLRZoT.rst b/Misc/NEWS.d/next/Windows/2024-11-30-13-36-44.gh-issue-127405.gLRZoT.rst new file mode 100644 index 00000000000000..ed067cb7259d9f --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-11-30-13-36-44.gh-issue-127405.gLRZoT.rst @@ -0,0 +1 @@ +Set :data:`sys.abiflags` on Windows. Patch by Xuehai Pan. From 0116f46ea0e1d1de74f137774bb4a52caae64b05 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Sat, 23 Nov 2024 14:07:33 +0800 Subject: [PATCH 3/4] Add Xuehai Pan to `ACKS` --- Misc/ACKS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/ACKS b/Misc/ACKS index b0b4ea0db44b64..e7a7bac5ca151e 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1402,6 +1402,7 @@ Todd R. Palmer Juan David Ibáñez Palomar Nicola Palumbo Jan Palus +Xuehai Pan Yongzhi Pan Martin Panter Mathias Panzenböck From 0b17343e5ed1d6a4abb465101089d63971369731 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Thu, 5 Dec 2024 17:56:49 +0800 Subject: [PATCH 4/4] Remove unnecessary stringfy --- PC/pyconfig.h.in | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PC/pyconfig.h.in b/PC/pyconfig.h.in index 53d1566126066b..874479bffd67d3 100644 --- a/PC/pyconfig.h.in +++ b/PC/pyconfig.h.in @@ -104,20 +104,21 @@ WIN32 is still required for the locale module. /* Defined in debug builds */ #ifdef _DEBUG -# define Py_DEBUG +# define Py_DEBUG #endif #ifdef Py_GIL_DISABLED -# define _ABIFLAGS_FREETHREADED "t" +# define _ABIFLAGS_FREETHREADED "t" #else -# define _ABIFLAGS_FREETHREADED "" +# define _ABIFLAGS_FREETHREADED "" #endif #ifdef Py_DEBUG -# define _ABIFLAGS_DEBUG "d" +# define _ABIFLAGS_DEBUG "d" #else -# define _ABIFLAGS_DEBUG "" +# define _ABIFLAGS_DEBUG "" #endif -#define ABIFLAGS ("" _Py_STRINGIZE(_ABIFLAGS_FREETHREADED) _Py_STRINGIZE(_ABIFLAGS_DEBUG)) +/* Set value for `sys.abiflags` */ +#define ABIFLAGS ("" _ABIFLAGS_FREETHREADED _ABIFLAGS_DEBUG) /* Compiler specific defines */