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/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 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. diff --git a/PC/pyconfig.h.in b/PC/pyconfig.h.in index 9e70303868e5de..874479bffd67d3 100644 --- a/PC/pyconfig.h.in +++ b/PC/pyconfig.h.in @@ -102,6 +102,24 @@ 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 +/* Set value for `sys.abiflags` */ +#define ABIFLAGS ("" _ABIFLAGS_FREETHREADED _ABIFLAGS_DEBUG) + /* Compiler specific defines */ /* ------------------------------------------------------------------------*/ @@ -319,21 +337,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 +394,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