bpo-44133: Skip PyThread_get_thread_native_id() if not available (GH-… · python/cpython@16901c0

@@ -2,6 +2,7 @@

22

# these are all functions _testcapi exports whose name begins with 'test_'.

3344

from collections import OrderedDict

5+

import _thread

56

import importlib.machinery

67

import importlib.util

78

import os

@@ -648,7 +649,11 @@ def test_export_symbols(self):

648649

# "PyThread_get_thread_native_id" symbols are exported by the Python

649650

# (directly by the binary, or via by the Python dynamic library).

650651

ctypes = import_helper.import_module('ctypes')

651-

names = ['PyThread_get_thread_native_id']

652+

names = []

653+654+

# Test if the PY_HAVE_THREAD_NATIVE_ID macro is defined

655+

if hasattr(_thread, 'get_native_id'):

656+

names.append('PyThread_get_thread_native_id')

652657653658

# Python/frozenmain.c fails to build on Windows when the symbols are

654659

# missing:

@@ -657,6 +662,7 @@ def test_export_symbols(self):

657662

# - PyInitFrozenExtensions

658663

if os.name != 'nt':

659664

names.append('Py_FrozenMain')

665+660666

for name in names:

661667

with self.subTest(name=name):

662668

self.assertTrue(hasattr(ctypes.pythonapi, name))