Skip to content

Commit 5bb0619

Browse files
committed
Set sys.abiflags on Windows
1 parent f1967e7 commit 5bb0619

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

Doc/library/sys.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ always available. Unless explicitly noted otherwise, all variables are read-only
1313

1414
.. data:: abiflags
1515

16-
On POSIX systems where Python was built with the standard ``configure``
17-
script, this contains the ABI flags as specified by :pep:`3149`.
16+
On POSIX and Windows systems where Python was built with the standard
17+
``configure`` script, this contains the ABI flags as specified by :pep:`3149`.
1818

1919
.. versionadded:: 3.2
2020

2121
.. versionchanged:: 3.8
2222
Default flags became an empty string (``m`` flag for pymalloc has been
2323
removed).
2424

25-
.. availability:: Unix.
25+
.. versionchanged:: 3.14
26+
The attribute was also added on Windows.
27+
28+
.. availability:: Unix, Windows.
2629

2730

2831
.. function:: addaudithook(hook)

Lib/test/test_sys.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,7 @@ def test_attributes(self):
696696
self.assertTrue(vi > (1,0,0))
697697
self.assertIsInstance(sys.float_repr_style, str)
698698
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
699-
if not sys.platform.startswith('win'):
700-
self.assertIsInstance(sys.abiflags, str)
699+
self.assertIsInstance(sys.abiflags, str)
701700

702701
def test_thread_info(self):
703702
info = sys.thread_info

PC/pyconfig.h.in

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ WIN32 is still required for the locale module.
102102
/* #define Py_GIL_DISABLED 1 */
103103
#endif
104104

105+
/* Defined in debug builds */
106+
#ifdef _DEBUG
107+
# define Py_DEBUG
108+
#endif
109+
110+
#ifdef Py_GIL_DISABLED
111+
# define _ABIFLAGS_FREETHREADED "t"
112+
#else
113+
# define _ABIFLAGS_FREETHREADED ""
114+
#endif
115+
#ifdef Py_DEBUG
116+
# define _ABIFLAGS_DEBUG "d"
117+
#else
118+
# define _ABIFLAGS_DEBUG ""
119+
#endif
120+
#define ABIFLAGS ("" _Py_STRINGIZE(_ABIFLAGS_FREETHREADED) _Py_STRINGIZE(_ABIFLAGS_DEBUG))
121+
105122
/* Compiler specific defines */
106123

107124
/* ------------------------------------------------------------------------*/
@@ -319,21 +336,21 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
319336
This is relevant when using build-system generator (e.g CMake) where
320337
the linking is explicitly handled */
321338
# if defined(Py_GIL_DISABLED)
322-
# if defined(_DEBUG)
339+
# if defined(Py_DEBUG)
323340
# pragma comment(lib,"python314t_d.lib")
324341
# elif defined(Py_LIMITED_API)
325342
# pragma comment(lib,"python3t.lib")
326343
# else
327344
# pragma comment(lib,"python314t.lib")
328-
# endif /* _DEBUG */
345+
# endif /* Py_DEBUG */
329346
# else /* Py_GIL_DISABLED */
330-
# if defined(_DEBUG)
347+
# if defined(Py_DEBUG)
331348
# pragma comment(lib,"python314_d.lib")
332349
# elif defined(Py_LIMITED_API)
333350
# pragma comment(lib,"python3.lib")
334351
# else
335352
# pragma comment(lib,"python314.lib")
336-
# endif /* _DEBUG */
353+
# endif /* Py_DEBUG */
337354
# endif /* Py_GIL_DISABLED */
338355
# endif /* _MSC_VER && !Py_NO_LINK_LIB */
339356
# endif /* Py_BUILD_CORE */
@@ -376,11 +393,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
376393
# define ALIGNOF_MAX_ALIGN_T 8
377394
#endif
378395

379-
#ifdef _DEBUG
380-
# define Py_DEBUG
381-
#endif
382-
383-
384396
#ifdef MS_WIN32
385397

386398
#define SIZEOF_SHORT 2

0 commit comments

Comments
 (0)