aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/thread.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Python/thread.c
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Python/thread.c')
-rw-r--r--contrib/tools/python3/src/Python/thread.c91
1 files changed, 12 insertions, 79 deletions
diff --git a/contrib/tools/python3/src/Python/thread.c b/contrib/tools/python3/src/Python/thread.c
index 940d8b8093..7fc53f9b61 100644
--- a/contrib/tools/python3/src/Python/thread.c
+++ b/contrib/tools/python3/src/Python/thread.c
@@ -7,16 +7,8 @@
#include "Python.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
-#include "pycore_structseq.h" // _PyStructSequence_FiniType()
-
-#ifndef _POSIX_THREADS
-/* This means pthreads are not implemented in libc headers, hence the macro
- not present in unistd.h. But they still can be implemented as an external
- library (e.g. gnu pth in pthread emulation) */
-# ifdef HAVE_PTHREAD_H
-# include <pthread.h> /* _POSIX_THREADS */
-# endif
-#endif
+#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
+#include "pycore_pythread.h"
#ifndef DONT_HAVE_STDIO_H
#include <stdio.h>
@@ -24,79 +16,25 @@
#include <stdlib.h>
-#ifndef _POSIX_THREADS
-
-/* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
- enough of the Posix threads package is implemented to support python
- threads.
-
- This is valid for HP-UX 11.23 running on an ia64 system. If needed, add
- a check of __ia64 to verify that we're running on an ia64 system instead
- of a pa-risc system.
-*/
-#ifdef __hpux
-#ifdef _SC_THREADS
-#define _POSIX_THREADS
-#endif
-#endif
-
-#endif /* _POSIX_THREADS */
-
-
-#ifdef Py_DEBUG
-static int thread_debug = 0;
-# define dprintf(args) (void)((thread_debug & 1) && printf args)
-#else
-# define dprintf(args)
-#endif
-
-static int initialized;
static void PyThread__init_thread(void); /* Forward */
+#define initialized _PyRuntime.threads.initialized
+
void
PyThread_init_thread(void)
{
-#ifdef Py_DEBUG
- const char *p = Py_GETENV("PYTHONTHREADDEBUG");
-
- if (p) {
- if (*p)
- thread_debug = atoi(p);
- else
- thread_debug = 1;
- }
-#endif /* Py_DEBUG */
- if (initialized)
+ if (initialized) {
return;
+ }
initialized = 1;
- dprintf(("PyThread_init_thread called\n"));
PyThread__init_thread();
}
-void
-_PyThread_debug_deprecation(void)
-{
-#ifdef Py_DEBUG
- if (thread_debug) {
- // Flush previous dprintf() logs
- fflush(stdout);
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "The threading debug (PYTHONTHREADDEBUG environment "
- "variable) is deprecated and will be removed "
- "in Python 3.12",
- 0))
- {
- _PyErr_WriteUnraisableMsg("at Python startup", NULL);
- }
- }
-#endif
-}
-
#if defined(HAVE_PTHREAD_STUBS)
# define PYTHREAD_NAME "pthread-stubs"
# include "thread_pthread_stubs.h"
-#elif defined(_POSIX_THREADS)
+#elif defined(_USE_PTHREADS) /* AKA _PTHREADS */
# if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
# define PYTHREAD_NAME "pthread-stubs"
# else
@@ -199,9 +137,9 @@ PyThread_GetInfo(void)
int len;
#endif
- if (ThreadInfoType.tp_name == 0) {
- if (PyStructSequence_InitType2(&ThreadInfoType, &threadinfo_desc) < 0)
- return NULL;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ if (_PyStructSequence_InitBuiltin(interp, &ThreadInfoType, &threadinfo_desc) < 0) {
+ return NULL;
}
threadinfo = PyStructSequence_New(&ThreadInfoType);
@@ -244,8 +182,7 @@ PyThread_GetInfo(void)
if (value == NULL)
#endif
{
- Py_INCREF(Py_None);
- value = Py_None;
+ value = Py_NewRef(Py_None);
}
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
return threadinfo;
@@ -255,9 +192,5 @@ PyThread_GetInfo(void)
void
_PyThread_FiniType(PyInterpreterState *interp)
{
- if (!_Py_IsMainInterpreter(interp)) {
- return;
- }
-
- _PyStructSequence_FiniType(&ThreadInfoType);
+ _PyStructSequence_FiniBuiltin(interp, &ThreadInfoType);
}