]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126)
authorChristian Heimes <christian@python.org>
Fri, 19 Aug 2022 19:41:25 +0000 (21:41 +0200)
committerGitHub <noreply@github.com>
Fri, 19 Aug 2022 19:41:25 +0000 (12:41 -0700)
Automerge-Triggered-By: GH:tiran
Lib/test/test_sys.py
Misc/NEWS.d/next/Library/2022-08-19-18-21-01.gh-issue-96125.ODcF1Y.rst [new file with mode: 0644]
Python/thread.c

index 78da09d6abc0f975899c1100750f72bc3a8fe7d6..202fb30a8a7e9d6a37a3a21c64712e1adb52c21e 100644 (file)
@@ -628,6 +628,14 @@ class SysModuleTest(unittest.TestCase):
         self.assertEqual(len(info), 3)
         self.assertIn(info.name, ('nt', 'pthread', 'pthread-stubs', 'solaris', None))
         self.assertIn(info.lock, ('semaphore', 'mutex+cond', None))
+        if sys.platform.startswith(("linux", "freebsd")):
+            self.assertEqual(info.name, "pthread")
+        elif sys.platform == "win32":
+            self.assertEqual(info.name, "nt")
+        elif sys.platform == "emscripten":
+            self.assertIn(info.name, {"pthread", "pthread-stubs"})
+        elif sys.platform == "wasi":
+            self.assertEqual(info.name, "pthread-stubs")
 
     @unittest.skipUnless(support.is_emscripten, "only available on Emscripten")
     def test_emscripten_info(self):
diff --git a/Misc/NEWS.d/next/Library/2022-08-19-18-21-01.gh-issue-96125.ODcF1Y.rst b/Misc/NEWS.d/next/Library/2022-08-19-18-21-01.gh-issue-96125.ODcF1Y.rst
new file mode 100644 (file)
index 0000000..ba7d26a
--- /dev/null
@@ -0,0 +1,2 @@
+Fix incorrect condition that causes ``sys.thread_info.name`` to be wrong on
+pthread platforms.
index e206a69c0507daad7c300c33e77c815719aba258..8c8a4e81895eb689c75b6b665d6ecfafca000a84 100644 (file)
@@ -59,7 +59,7 @@ PyThread_init_thread(void)
 #   define PYTHREAD_NAME "pthread-stubs"
 #   include "thread_pthread_stubs.h"
 #elif defined(_POSIX_THREADS)
-#   if defined(__EMSCRIPTEN__) || !defined(__EMSCRIPTEN_PTHREADS__)
+#   if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
 #     define PYTHREAD_NAME "pthread-stubs"
 #   else
 #     define PYTHREAD_NAME "pthread"