Skip to content

bpo-44133: Skip PyThread_get_thread_native_id() if not available #30636

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

Merged
merged 1 commit into from
Jan 17, 2022
Merged
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
8 changes: 7 additions & 1 deletion Lib/test/test_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# these are all functions _testcapi exports whose name begins with 'test_'.

from collections import OrderedDict
import _thread
import importlib.machinery
import importlib.util
import os
Expand Down Expand Up @@ -648,7 +649,11 @@ def test_export_symbols(self):
# "PyThread_get_thread_native_id" symbols are exported by the Python
# (directly by the binary, or via by the Python dynamic library).
ctypes = import_helper.import_module('ctypes')
names = ['PyThread_get_thread_native_id']
names = []

# Test if the PY_HAVE_THREAD_NATIVE_ID macro is defined
if hasattr(_thread, 'get_native_id'):
names.append('PyThread_get_thread_native_id')

# Python/frozenmain.c fails to build on Windows when the symbols are
# missing:
Expand All @@ -657,6 +662,7 @@ def test_export_symbols(self):
# - PyInitFrozenExtensions
if os.name != 'nt':
names.append('Py_FrozenMain')

for name in names:
with self.subTest(name=name):
self.assertTrue(hasattr(ctypes.pythonapi, name))
Expand Down