Skip to content

Commit 886424b

Browse files
committed
Set sys.abiflags on Windows
1 parent 3afb639 commit 886424b

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.
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
@@ -683,8 +683,7 @@ def test_attributes(self):
683683
self.assertTrue(vi > (1,0,0))
684684
self.assertIsInstance(sys.float_repr_style, str)
685685
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
686-
if not sys.platform.startswith('win'):
687-
self.assertIsInstance(sys.abiflags, str)
686+
self.assertIsInstance(sys.abiflags, str)
688687

689688
def test_thread_info(self):
690689
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
/* ------------------------------------------------------------------------*/
@@ -315,21 +332,21 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
315332
/* So MSVC users need not specify the .lib
316333
file in their Makefile */
317334
# if defined(Py_GIL_DISABLED)
318-
# if defined(_DEBUG)
335+
# if defined(Py_DEBUG)
319336
# pragma comment(lib,"python314t_d.lib")
320337
# elif defined(Py_LIMITED_API)
321338
# pragma comment(lib,"python3t.lib")
322339
# else
323340
# pragma comment(lib,"python314t.lib")
324-
# endif /* _DEBUG */
341+
# endif /* Py_DEBUG */
325342
# else /* Py_GIL_DISABLED */
326-
# if defined(_DEBUG)
343+
# if defined(Py_DEBUG)
327344
# pragma comment(lib,"python314_d.lib")
328345
# elif defined(Py_LIMITED_API)
329346
# pragma comment(lib,"python3.lib")
330347
# else
331348
# pragma comment(lib,"python314.lib")
332-
# endif /* _DEBUG */
349+
# endif /* Py_DEBUG */
333350
# endif /* Py_GIL_DISABLED */
334351
# endif /* _MSC_VER */
335352
# endif /* Py_BUILD_CORE */
@@ -372,11 +389,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
372389
# define ALIGNOF_MAX_ALIGN_T 8
373390
#endif
374391

375-
#ifdef _DEBUG
376-
# define Py_DEBUG
377-
#endif
378-
379-
380392
#ifdef MS_WIN32
381393

382394
#define SIZEOF_SHORT 2

0 commit comments

Comments
 (0)