Skip to content

gh-127405: Set sys.abiflags on Windows #127406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ 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

.. versionchanged:: 3.8
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)
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set :data:`sys.abiflags` on Windows. Patch by Xuehai Pan.
31 changes: 22 additions & 9 deletions PC/pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/* ------------------------------------------------------------------------*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
Loading