summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-09-07 16:56:24 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-09-07 16:56:24 (GMT)
commita6a4dc816d68df04a7d592e0b6af8c7ecc4d4344 (patch)
tree1c31738009bee903417cea928e705a112aea2392 /Modules
parent1f06a680de465be0c24a78ea3b610053955daa99 (diff)
downloadcpython-a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344.zip
cpython-a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344.tar.gz
cpython-a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344.tar.bz2
bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config * Always define WITH_THREAD for compatibility.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Setup.config.in10
-rw-r--r--Modules/Setup.dist14
-rw-r--r--Modules/_blake2/blake2b_impl.c12
-rw-r--r--Modules/_blake2/blake2s_impl.c12
-rw-r--r--Modules/_bz2module.c23
-rw-r--r--Modules/_ctypes/_ctypes.c2
-rw-r--r--Modules/_ctypes/callbacks.c22
-rw-r--r--Modules/_ctypes/callproc.c10
-rw-r--r--Modules/_hashopenssl.c10
-rw-r--r--Modules/_io/bufferedio.c13
-rw-r--r--Modules/_lzmamodule.c23
-rw-r--r--Modules/_sha3/sha3module.c14
-rw-r--r--Modules/_sqlite/connection.c37
-rw-r--r--Modules/_sqlite/module.c2
-rw-r--r--Modules/_ssl.c30
-rw-r--r--Modules/_testcapimodule.c11
-rw-r--r--Modules/_threadmodule.c7
-rw-r--r--Modules/_tkinter.c62
-rw-r--r--Modules/_tracemalloc.c41
-rw-r--r--Modules/clinic/signalmodule.c.h6
-rw-r--r--Modules/faulthandler.c12
-rw-r--r--Modules/hashlib.h29
-rw-r--r--Modules/posixmodule.c4
-rw-r--r--Modules/readline.c24
-rw-r--r--Modules/signalmodule.c24
-rw-r--r--Modules/socketmodule.c14
-rw-r--r--Modules/zlibmodule.c25
27 files changed, 38 insertions, 455 deletions
diff --git a/Modules/Setup.config.in b/Modules/Setup.config.in
deleted file mode 100644
index 6450528..0000000
--- a/Modules/Setup.config.in
+++ /dev/null
@@ -1,10 +0,0 @@
-# This file is transmogrified into Setup.config by config.status.
-
-# The purpose of this file is to conditionally enable certain modules
-# based on configure-time options.
-
-# Threading
-@USE_THREAD_MODULE@_thread _threadmodule.c
-
-# The rest of the modules previously listed in this file are built
-# by the setup.py script in Python 2.1 and later.
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index dd533ef..9c3e1be 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -123,6 +123,7 @@ atexit atexitmodule.c # Register functions to be run at interpreter-shutdow
_signal signalmodule.c
_stat _stat.c # stat.h interface
time timemodule.c # -lm # time operations and variables
+_thread _threadmodule.c # low-level threading interface
# access to ISO C locale support
_locale _localemodule.c # -lintl
@@ -216,8 +217,6 @@ _symtable symtablemodule.c
# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
-#
-# First, look at Setup.config; configure may have set this for you.
#_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems
@@ -308,8 +307,6 @@ _symtable symtablemodule.c
# Curses support, requiring the System V version of curses, often
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).
-#
-# First, look at Setup.config; configure may have set this for you.
#_curses _cursesmodule.c -lcurses -ltermcap
# Wrapper for the panel library that's part of ncurses and SYSV curses.
@@ -323,18 +320,9 @@ _symtable symtablemodule.c
# implementation independent wrapper for these; dbm/dumb.py provides
# similar functionality (but slower of course) implemented in Python.
-# The standard Unix dbm module has been moved to Setup.config so that
-# it will be compiled as a shared library by default. Compiling it as
-# a built-in module causes conflicts with the pybsddb3 module since it
-# creates a static dependency on an out-of-date version of db.so.
-#
-# First, look at Setup.config; configure may have set this for you.
-
#_dbm _dbmmodule.c # dbm(3) may require -lndbm or similar
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
-#
-# First, look at Setup.config; configure may have set this for you.
#_gdbm _gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c
index ec9e3c1..b1ae3e9 100644
--- a/Modules/_blake2/blake2b_impl.c
+++ b/Modules/_blake2/blake2b_impl.c
@@ -15,9 +15,7 @@
#include "Python.h"
#include "pystrhex.h"
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#include "../hashlib.h"
#include "blake2ns.h"
@@ -41,9 +39,7 @@ typedef struct {
PyObject_HEAD
blake2b_param param;
blake2b_state state;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BLAKE2bObject;
#include "clinic/blake2b_impl.c.h"
@@ -60,11 +56,9 @@ new_BLAKE2bObject(PyTypeObject *type)
{
BLAKE2bObject *self;
self = (BLAKE2bObject *)type->tp_alloc(type, 0);
-#ifdef WITH_THREAD
if (self != NULL) {
self->lock = NULL;
}
-#endif
return self;
}
@@ -292,7 +286,6 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
-#ifdef WITH_THREAD
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
self->lock = PyThread_allocate_lock();
@@ -305,9 +298,6 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)
} else {
blake2b_update(&self->state, buf.buf, buf.len);
}
-#else
- blake2b_update(&self->state, buf.buf, buf.len);
-#endif /* !WITH_THREAD */
PyBuffer_Release(&buf);
Py_RETURN_NONE;
@@ -407,12 +397,10 @@ py_blake2b_dealloc(PyObject *self)
/* Try not to leave state in memory. */
secure_zero_memory(&obj->param, sizeof(obj->param));
secure_zero_memory(&obj->state, sizeof(obj->state));
-#ifdef WITH_THREAD
if (obj->lock) {
PyThread_free_lock(obj->lock);
obj->lock = NULL;
}
-#endif
PyObject_Del(self);
}
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
index 42257a2..3615a38 100644
--- a/Modules/_blake2/blake2s_impl.c
+++ b/Modules/_blake2/blake2s_impl.c
@@ -15,9 +15,7 @@
#include "Python.h"
#include "pystrhex.h"
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#include "../hashlib.h"
#include "blake2ns.h"
@@ -41,9 +39,7 @@ typedef struct {
PyObject_HEAD
blake2s_param param;
blake2s_state state;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BLAKE2sObject;
#include "clinic/blake2s_impl.c.h"
@@ -60,11 +56,9 @@ new_BLAKE2sObject(PyTypeObject *type)
{
BLAKE2sObject *self;
self = (BLAKE2sObject *)type->tp_alloc(type, 0);
-#ifdef WITH_THREAD
if (self != NULL) {
self->lock = NULL;
}
-#endif
return self;
}
@@ -292,7 +286,6 @@ _blake2s_blake2s_update(BLAKE2sObject *self, PyObject *obj)
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
-#ifdef WITH_THREAD
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
self->lock = PyThread_allocate_lock();
@@ -305,9 +298,6 @@ _blake2s_blake2s_update(BLAKE2sObject *self, PyObject *obj)
} else {
blake2s_update(&self->state, buf.buf, buf.len);
}
-#else
- blake2s_update(&self->state, buf.buf, buf.len);
-#endif /* !WITH_THREAD */
PyBuffer_Release(&buf);
Py_RETURN_NONE;
@@ -407,12 +397,10 @@ py_blake2s_dealloc(PyObject *self)
/* Try not to leave state in memory. */
secure_zero_memory(&obj->param, sizeof(obj->param));
secure_zero_memory(&obj->state, sizeof(obj->state));
-#ifdef WITH_THREAD
if (obj->lock) {
PyThread_free_lock(obj->lock);
obj->lock = NULL;
}
-#endif
PyObject_Del(self);
}
diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c
index 409522f..dba0e19 100644
--- a/Modules/_bz2module.c
+++ b/Modules/_bz2module.c
@@ -5,9 +5,7 @@
#include "Python.h"
#include "structmember.h"
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#include <bzlib.h>
#include <stdio.h>
@@ -23,7 +21,6 @@
#endif /* ! BZ_CONFIG_ERROR */
-#ifdef WITH_THREAD
#define ACQUIRE_LOCK(obj) do { \
if (!PyThread_acquire_lock((obj)->lock, 0)) { \
Py_BEGIN_ALLOW_THREADS \
@@ -31,19 +28,13 @@
Py_END_ALLOW_THREADS \
} } while (0)
#define RELEASE_LOCK(obj) PyThread_release_lock((obj)->lock)
-#else
-#define ACQUIRE_LOCK(obj)
-#define RELEASE_LOCK(obj)
-#endif
typedef struct {
PyObject_HEAD
bz_stream bzs;
int flushed;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BZ2Compressor;
typedef struct {
@@ -59,9 +50,7 @@ typedef struct {
separately. Conversion and looping is encapsulated in
decompress_buf() */
size_t bzs_avail_in_real;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BZ2Decompressor;
static PyTypeObject BZ2Compressor_Type;
@@ -325,13 +314,11 @@ _bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
return -1;
}
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->bzs.opaque = NULL;
self->bzs.bzalloc = BZ2_Malloc;
@@ -343,10 +330,8 @@ _bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
return 0;
error:
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -354,10 +339,8 @@ static void
BZ2Compressor_dealloc(BZ2Compressor *self)
{
BZ2_bzCompressEnd(&self->bzs);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -651,13 +634,11 @@ _bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
{
int bzerror;
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->needs_input = 1;
self->bzs_avail_in_real = 0;
@@ -675,10 +656,8 @@ _bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
error:
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -689,10 +668,8 @@ BZ2Decompressor_dealloc(BZ2Decompressor *self)
PyMem_Free(self->input_buffer);
BZ2_bzDecompressEnd(&self->bzs);
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 0255f76..1942c63 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -5410,9 +5410,7 @@ PyInit__ctypes(void)
ob_type is the metatype (the 'type'), defaults to PyType_Type,
tp_base is the base type, defaults to 'object' aka PyBaseObject_Type.
*/
-#ifdef WITH_THREAD
PyEval_InitThreads();
-#endif
m = PyModule_Create(&_ctypesmodule);
if (!m)
return NULL;
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index a11ae04..d579291 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -137,9 +137,7 @@ static void _CallPythonObject(void *mem,
Py_ssize_t nArgs;
PyObject *error_object = NULL;
int *space;
-#ifdef WITH_THREAD
PyGILState_STATE state = PyGILState_Ensure();
-#endif
nArgs = PySequence_Length(converters);
/* Hm. What to return in case of error?
@@ -281,9 +279,7 @@ if (x == NULL) _PyTraceback_Add(what, "_ctypes/callbacks.c", __LINE__ - 1), PyEr
Py_XDECREF(result);
Done:
Py_XDECREF(arglist);
-#ifdef WITH_THREAD
PyGILState_Release(state);
-#endif
}
static void closure_fcn(ffi_cif *cif,
@@ -347,7 +343,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
assert(CThunk_CheckExact((PyObject *)p));
p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
- &p->pcl_exec);
+ &p->pcl_exec);
if (p->pcl_write == NULL) {
PyErr_NoMemory();
goto error;
@@ -397,8 +393,8 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
#else
result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
- p,
- p->pcl_exec);
+ p,
+ p->pcl_exec);
#endif
if (result != FFI_OK) {
PyErr_Format(PyExc_RuntimeError,
@@ -422,9 +418,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
static void LoadPython(void)
{
if (!Py_IsInitialized()) {
-#ifdef WITH_THREAD
PyEval_InitThreads();
-#endif
Py_Initialize();
}
}
@@ -495,18 +489,12 @@ STDAPI DllGetClassObject(REFCLSID rclsid,
LPVOID *ppv)
{
long result;
-#ifdef WITH_THREAD
PyGILState_STATE state;
-#endif
LoadPython();
-#ifdef WITH_THREAD
state = PyGILState_Ensure();
-#endif
result = Call_GetClassObject(rclsid, riid, ppv);
-#ifdef WITH_THREAD
PyGILState_Release(state);
-#endif
return result;
}
@@ -558,13 +546,9 @@ long Call_CanUnloadNow(void)
STDAPI DllCanUnloadNow(void)
{
long result;
-#ifdef WITH_THREAD
PyGILState_STATE state = PyGILState_Ensure();
-#endif
result = Call_CanUnloadNow();
-#ifdef WITH_THREAD
PyGILState_Release(state);
-#endif
return result;
}
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index be757ef..3a6ad86 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -745,9 +745,7 @@ static int _call_function_pointer(int flags,
void *resmem,
int argcount)
{
-#ifdef WITH_THREAD
PyThreadState *_save = NULL; /* For Py_BLOCK_THREADS and Py_UNBLOCK_THREADS */
-#endif
PyObject *error_object = NULL;
int *space;
ffi_cif cif;
@@ -786,10 +784,8 @@ static int _call_function_pointer(int flags,
if (error_object == NULL)
return -1;
}
-#ifdef WITH_THREAD
if ((flags & FUNCFLAG_PYTHONAPI) == 0)
Py_UNBLOCK_THREADS
-#endif
if (flags & FUNCFLAG_USE_ERRNO) {
int temp = space[0];
space[0] = errno;
@@ -826,10 +822,8 @@ static int _call_function_pointer(int flags,
space[0] = errno;
errno = temp;
}
-#ifdef WITH_THREAD
if ((flags & FUNCFLAG_PYTHONAPI) == 0)
Py_BLOCK_THREADS
-#endif
Py_XDECREF(error_object);
#ifdef MS_WIN32
#ifndef DONT_USE_SEH
@@ -982,9 +976,7 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
/* We absolutely have to release the GIL during COM method calls,
otherwise we may get a deadlock!
*/
-#ifdef WITH_THREAD
Py_BEGIN_ALLOW_THREADS
-#endif
hr = pIunk->lpVtbl->QueryInterface(pIunk, &IID_ISupportErrorInfo, (void **)&psei);
if (FAILED(hr))
@@ -1008,9 +1000,7 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
pei->lpVtbl->Release(pei);
failed:
-#ifdef WITH_THREAD
Py_END_ALLOW_THREADS
-#endif
progid = NULL;
ProgIDFromCLSID(&guid, &progid);
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 8ef8c54..01f1671 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -53,9 +53,7 @@ typedef struct {
PyObject_HEAD
PyObject *name; /* name of this hash algorithm */
EVP_MD_CTX *ctx; /* OpenSSL message digest context */
-#ifdef WITH_THREAD
PyThread_type_lock lock; /* OpenSSL context lock */
-#endif
} EVPobject;
@@ -122,9 +120,7 @@ newEVPobject(PyObject *name)
/* save the name for .name to return */
Py_INCREF(name);
retval->name = name;
-#ifdef WITH_THREAD
retval->lock = NULL;
-#endif
return retval;
}
@@ -153,10 +149,8 @@ EVP_hash(EVPobject *self, const void *vp, Py_ssize_t len)
static void
EVP_dealloc(EVPobject *self)
{
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
EVP_MD_CTX_free(self->ctx);
Py_XDECREF(self->name);
PyObject_Del(self);
@@ -267,7 +261,6 @@ EVP_update(EVPobject *self, PyObject *args)
GET_BUFFER_VIEW_OR_ERROUT(obj, &view);
-#ifdef WITH_THREAD
if (self->lock == NULL && view.len >= HASHLIB_GIL_MINSIZE) {
self->lock = PyThread_allocate_lock();
/* fail? lock = NULL and we fail over to non-threaded code. */
@@ -282,9 +275,6 @@ EVP_update(EVPobject *self, PyObject *args)
} else {
EVP_hash(self, view.buf, view.len);
}
-#else
- EVP_hash(self, view.buf, view.len);
-#endif
PyBuffer_Release(&view);
Py_RETURN_NONE;
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 189b1cd..ba0932c 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -230,10 +230,8 @@ typedef struct {
isn't ready for writing. */
Py_off_t write_end;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
volatile unsigned long owner;
-#endif
Py_ssize_t buffer_size;
Py_ssize_t buffer_mask;
@@ -267,8 +265,6 @@ typedef struct {
/* These macros protect the buffered object against concurrent operations. */
-#ifdef WITH_THREAD
-
static int
_enter_buffered_busy(buffered *self)
{
@@ -315,11 +311,6 @@ _enter_buffered_busy(buffered *self)
PyThread_release_lock(self->lock); \
} while(0);
-#else
-#define ENTER_BUFFERED(self) 1
-#define LEAVE_BUFFERED(self)
-#endif
-
#define CHECK_INITIALIZED(self) \
if (self->ok <= 0) { \
if (self->detached) { \
@@ -401,12 +392,10 @@ buffered_dealloc(buffered *self)
PyMem_Free(self->buffer);
self->buffer = NULL;
}
-#ifdef WITH_THREAD
if (self->lock) {
PyThread_free_lock(self->lock);
self->lock = NULL;
}
-#endif
Py_CLEAR(self->dict);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -753,7 +742,6 @@ _buffered_init(buffered *self)
PyErr_NoMemory();
return -1;
}
-#ifdef WITH_THREAD
if (self->lock)
PyThread_free_lock(self->lock);
self->lock = PyThread_allocate_lock();
@@ -762,7 +750,6 @@ _buffered_init(buffered *self)
return -1;
}
self->owner = 0;
-#endif
/* Find out whether buffer_size is a power of 2 */
/* XXX is this optimization useful? */
for (n = self->buffer_size - 1; n & 1; n >>= 1)
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index 26bfa0b..fd3bbb8 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -9,16 +9,13 @@
#include "Python.h"
#include "structmember.h"
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#include <stdarg.h>
#include <string.h>
#include <lzma.h>
-#ifdef WITH_THREAD
#define ACQUIRE_LOCK(obj) do { \
if (!PyThread_acquire_lock((obj)->lock, 0)) { \
Py_BEGIN_ALLOW_THREADS \
@@ -26,10 +23,6 @@
Py_END_ALLOW_THREADS \
} } while (0)
#define RELEASE_LOCK(obj) PyThread_release_lock((obj)->lock)
-#else
-#define ACQUIRE_LOCK(obj)
-#define RELEASE_LOCK(obj)
-#endif
/* Container formats: */
@@ -48,9 +41,7 @@ typedef struct {
lzma_allocator alloc;
lzma_stream lzs;
int flushed;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} Compressor;
typedef struct {
@@ -63,9 +54,7 @@ typedef struct {
char needs_input;
uint8_t *input_buffer;
size_t input_buffer_size;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} Decompressor;
/* LZMAError class object. */
@@ -757,13 +746,11 @@ Compressor_init(Compressor *self, PyObject *args, PyObject *kwargs)
self->alloc.free = PyLzma_Free;
self->lzs.allocator = &self->alloc;
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->flushed = 0;
switch (format) {
@@ -790,10 +777,8 @@ Compressor_init(Compressor *self, PyObject *args, PyObject *kwargs)
break;
}
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -801,10 +786,8 @@ static void
Compressor_dealloc(Compressor *self)
{
lzma_end(&self->lzs);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -1180,13 +1163,11 @@ _lzma_LZMADecompressor___init___impl(Decompressor *self, int format,
self->lzs.allocator = &self->alloc;
self->lzs.next_in = NULL;
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->check = LZMA_CHECK_UNKNOWN;
self->needs_input = 1;
@@ -1230,10 +1211,8 @@ _lzma_LZMADecompressor___init___impl(Decompressor *self, int format,
error:
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -1245,10 +1224,8 @@ Decompressor_dealloc(Decompressor *self)
lzma_end(&self->lzs);
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index 33b77b1..970ce16 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -139,9 +139,7 @@ class _sha3.shake_256 "SHA3object *" "&SHAKE256type"
typedef struct {
PyObject_HEAD
SHA3_state hash_state;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} SHA3object;
static PyTypeObject SHA3_224type;
@@ -167,9 +165,7 @@ newSHA3object(PyTypeObject *type)
if (newobj == NULL) {
return NULL;
}
-#ifdef WITH_THREAD
newobj->lock = NULL;
-#endif
return newobj;
}
@@ -224,7 +220,6 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data)
if (data) {
GET_BUFFER_VIEW_OR_ERROR(data, &buf, goto error);
-#ifdef WITH_THREAD
if (buf.len >= HASHLIB_GIL_MINSIZE) {
/* invariant: New objects can't be accessed by other code yet,
* thus it's safe to release the GIL without locking the object.
@@ -236,9 +231,6 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data)
else {
res = SHA3_process(&self->hash_state, buf.buf, buf.len * 8);
}
-#else
- res = SHA3_process(&self->hash_state, buf.buf, buf.len * 8);
-#endif
if (res != SUCCESS) {
PyErr_SetString(PyExc_RuntimeError,
"internal error in SHA3 Update()");
@@ -265,11 +257,9 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data)
static void
SHA3_dealloc(SHA3object *self)
{
-#ifdef WITH_THREAD
if (self->lock) {
PyThread_free_lock(self->lock);
}
-#endif
PyObject_Del(self);
}
@@ -373,7 +363,6 @@ _sha3_sha3_224_update(SHA3object *self, PyObject *obj)
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
/* add new data, the function takes the length in bits not bytes */
-#ifdef WITH_THREAD
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE) {
self->lock = PyThread_allocate_lock();
}
@@ -391,9 +380,6 @@ _sha3_sha3_224_update(SHA3object *self, PyObject *obj)
else {
res = SHA3_process(&self->hash_state, buf.buf, buf.len * 8);
}
-#else
- res = SHA3_process(&self->hash_state, buf.buf, buf.len * 8);
-#endif
if (res != SUCCESS) {
PyBuffer_Release(&buf);
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index e2ba758..f596bcf 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -170,9 +170,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
self->detect_types = detect_types;
self->timeout = timeout;
(void)sqlite3_busy_timeout(self->db, (int)(timeout*1000));
-#ifdef WITH_THREAD
self->thread_ident = PyThread_get_thread_ident();
-#endif
if (!check_same_thread && sqlite3_libversion_number() < 3003001) {
PyErr_SetString(pysqlite_NotSupportedError, "shared connections not available");
return -1;
@@ -592,11 +590,9 @@ void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value**
PyObject* py_retval = NULL;
int ok;
-#ifdef WITH_THREAD
PyGILState_STATE threadstate;
threadstate = PyGILState_Ensure();
-#endif
py_func = (PyObject*)sqlite3_user_data(context);
@@ -620,9 +616,7 @@ void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value**
_sqlite3_result_error(context, "user-defined function raised exception", -1);
}
-#ifdef WITH_THREAD
PyGILState_Release(threadstate);
-#endif
}
static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_value** params)
@@ -633,11 +627,9 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
PyObject** aggregate_instance;
PyObject* stepmethod = NULL;
-#ifdef WITH_THREAD
PyGILState_STATE threadstate;
threadstate = PyGILState_Ensure();
-#endif
aggregate_class = (PyObject*)sqlite3_user_data(context);
@@ -684,9 +676,7 @@ error:
Py_XDECREF(stepmethod);
Py_XDECREF(function_result);
-#ifdef WITH_THREAD
PyGILState_Release(threadstate);
-#endif
}
void _pysqlite_final_callback(sqlite3_context* context)
@@ -698,11 +688,9 @@ void _pysqlite_final_callback(sqlite3_context* context)
PyObject *exception, *value, *tb;
int restore;
-#ifdef WITH_THREAD
PyGILState_STATE threadstate;
threadstate = PyGILState_Ensure();
-#endif
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
if (!*aggregate_instance) {
@@ -746,12 +734,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
}
error:
-#ifdef WITH_THREAD
PyGILState_Release(threadstate);
-#endif
- /* explicit return to avoid a compilation error if WITH_THREAD
- is not defined */
- return;
}
static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self)
@@ -884,11 +867,9 @@ static int _authorizer_callback(void* user_arg, int action, const char* arg1, co
{
PyObject *ret;
int rc;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate;
gilstate = PyGILState_Ensure();
-#endif
ret = PyObject_CallFunction((PyObject*)user_arg, "issss", action, arg1, arg2, dbname, access_attempt_source);
@@ -917,9 +898,7 @@ static int _authorizer_callback(void* user_arg, int action, const char* arg1, co
Py_DECREF(ret);
}
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return rc;
}
@@ -927,11 +906,9 @@ static int _progress_handler(void* user_arg)
{
int rc;
PyObject *ret;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate;
gilstate = PyGILState_Ensure();
-#endif
ret = _PyObject_CallNoArg((PyObject*)user_arg);
if (!ret) {
@@ -948,9 +925,7 @@ static int _progress_handler(void* user_arg)
Py_DECREF(ret);
}
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return rc;
}
@@ -959,11 +934,9 @@ static void _trace_callback(void* user_arg, const char* statement_string)
PyObject *py_statement = NULL;
PyObject *ret = NULL;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate;
gilstate = PyGILState_Ensure();
-#endif
py_statement = PyUnicode_DecodeUTF8(statement_string,
strlen(statement_string), "replace");
if (py_statement) {
@@ -981,9 +954,7 @@ static void _trace_callback(void* user_arg, const char* statement_string)
}
}
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
}
static PyObject* pysqlite_connection_set_authorizer(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
@@ -1120,7 +1091,6 @@ static PyObject* pysqlite_load_extension(pysqlite_Connection* self, PyObject* ar
int pysqlite_check_thread(pysqlite_Connection* self)
{
-#ifdef WITH_THREAD
if (self->check_same_thread) {
if (PyThread_get_thread_ident() != self->thread_ident) {
PyErr_Format(pysqlite_ProgrammingError,
@@ -1131,7 +1101,6 @@ int pysqlite_check_thread(pysqlite_Connection* self)
}
}
-#endif
return 1;
}
@@ -1365,15 +1334,11 @@ pysqlite_collation_callback(
PyObject* callback = (PyObject*)context;
PyObject* string1 = 0;
PyObject* string2 = 0;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate;
-#endif
PyObject* retval = NULL;
long longval;
int result = 0;
-#ifdef WITH_THREAD
gilstate = PyGILState_Ensure();
-#endif
if (PyErr_Occurred()) {
goto finally;
@@ -1409,9 +1374,7 @@ finally:
Py_XDECREF(string1);
Py_XDECREF(string2);
Py_XDECREF(retval);
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return result;
}
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 59406e1..5f8aaf9 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -478,9 +478,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
* threads have already been initialized.
* (see pybsddb-users mailing list post on 2002-08-07)
*/
-#ifdef WITH_THREAD
PyEval_InitThreads();
-#endif
error:
if (PyErr_Occurred())
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 2fa6bd2..b8509ac 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -18,7 +18,6 @@
#include "Python.h"
-#ifdef WITH_THREAD
#include "pythread.h"
/* Redefined below for Windows debug builds after important #includes */
@@ -35,17 +34,6 @@
#define PySSL_UNBLOCK_THREADS PySSL_BEGIN_ALLOW_THREADS_S(_save);
#define PySSL_END_ALLOW_THREADS PySSL_END_ALLOW_THREADS_S(_save); }
-#else /* no WITH_THREAD */
-
-#define PySSL_BEGIN_ALLOW_THREADS_S(save)
-#define PySSL_END_ALLOW_THREADS_S(save)
-#define PySSL_BEGIN_ALLOW_THREADS
-#define PySSL_BLOCK_THREADS
-#define PySSL_UNBLOCK_THREADS
-#define PySSL_END_ALLOW_THREADS
-
-#endif
-
/* Include symbols from _socket module */
#include "socketmodule.h"
@@ -171,9 +159,7 @@ static void _PySSLFixErrno(void) {
#define OPENSSL_NO_SSL2
#endif
#else /* OpenSSL < 1.1.0 */
-#if defined(WITH_THREAD)
#define HAVE_OPENSSL_CRYPTO_LOCK
-#endif
#define TLS_method SSLv23_method
#define TLS_client_method SSLv23_client_method
@@ -285,15 +271,11 @@ enum py_ssl_version {
PY_SSL_VERSION_TLS_SERVER,
};
-#ifdef WITH_THREAD
-
/* serves as a flag to see whether we've initialized the SSL thread support. */
/* 0 means no, greater than 0 means yes */
static unsigned int _ssl_locks_count = 0;
-#endif /* def WITH_THREAD */
-
/* SSL socket object */
#define X509_NAME_MAXLEN 256
@@ -3768,16 +3750,12 @@ _servername_callback(SSL *s, int *al, void *args)
/* The high-level ssl.SSLSocket object */
PyObject *ssl_socket;
const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
-#ifdef WITH_THREAD
PyGILState_STATE gstate = PyGILState_Ensure();
-#endif
if (ssl_ctx->set_hostname == NULL) {
/* remove race condition in this the call back while if removing the
* callback is in progress */
-#ifdef WITH_THREAD
PyGILState_Release(gstate);
-#endif
return SSL_TLSEXT_ERR_OK;
}
@@ -3846,18 +3824,14 @@ _servername_callback(SSL *s, int *al, void *args)
Py_DECREF(result);
}
-#ifdef WITH_THREAD
PyGILState_Release(gstate);
-#endif
return ret;
error:
Py_DECREF(ssl_socket);
*al = SSL_AD_INTERNAL_ERROR;
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
-#ifdef WITH_THREAD
PyGILState_Release(gstate);
-#endif
return ret;
}
#endif
@@ -5117,7 +5091,7 @@ static int _setup_ssl_threads(void) {
return 1;
}
-#endif /* HAVE_OPENSSL_CRYPTO_LOCK for WITH_THREAD && OpenSSL < 1.1.0 */
+#endif /* HAVE_OPENSSL_CRYPTO_LOCK for OpenSSL < 1.1.0 */
PyDoc_STRVAR(module_doc,
"Implementation module for SSL socket operations. See the socket module\n\
@@ -5193,7 +5167,6 @@ PyInit__ssl(void)
SSL_library_init();
#endif
-#ifdef WITH_THREAD
#ifdef HAVE_OPENSSL_CRYPTO_LOCK
/* note that this will start threading if not already started */
if (!_setup_ssl_threads()) {
@@ -5203,7 +5176,6 @@ PyInit__ssl(void)
/* OpenSSL 1.1.0 builtin thread support is enabled */
_ssl_locks_count++;
#endif
-#endif /* WITH_THREAD */
/* Add symbols to module dict */
sslerror_type_slots[0].pfunc = PyExc_OSError;
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 2952317..1a29621 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -22,9 +22,7 @@
#include <sys/wait.h> /* For W_STOPCODE */
#endif
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif /* WITH_THREAD */
static PyObject *TestError; /* set to exception object in init */
/* Raise TestError with test_name + ": " + msg, and return NULL. */
@@ -2229,8 +2227,6 @@ test_datetime_capi(PyObject *self, PyObject *args) {
}
-#ifdef WITH_THREAD
-
/* test_thread_state spawns a thread of its own, and that thread releases
* `thread_done` when it's finished. The driver code has to know when the
* thread finishes, because the thread uses a PyObject (the callable) that
@@ -2348,7 +2344,6 @@ PyObject *pending_threadfunc(PyObject *self, PyObject *arg)
}
Py_RETURN_TRUE;
}
-#endif
/* Some tests of PyUnicode_FromFormat(). This needs more tests. */
static PyObject *
@@ -3617,7 +3612,6 @@ PyDoc_STRVAR(docstring_with_signature_with_defaults,
"and the parameters take defaults of varying types."
);
-#ifdef WITH_THREAD
typedef struct {
PyThread_type_lock start_event;
PyThread_type_lock exit_event;
@@ -3704,7 +3698,6 @@ exit:
PyThread_free_lock(test_c_thread.exit_event);
return res;
}
-#endif /* WITH_THREAD */
static PyObject*
test_raise_signal(PyObject* self, PyObject *args)
@@ -4420,10 +4413,8 @@ static PyMethodDef TestMethods[] = {
{"unicode_encodedecimal", unicode_encodedecimal, METH_VARARGS},
{"unicode_transformdecimaltoascii", unicode_transformdecimaltoascii, METH_VARARGS},
{"unicode_legacy_string", unicode_legacy_string, METH_VARARGS},
-#ifdef WITH_THREAD
{"_test_thread_state", test_thread_state, METH_VARARGS},
{"_pending_threadfunc", pending_threadfunc, METH_VARARGS},
-#endif
#ifdef HAVE_GETTIMEOFDAY
{"profile_int", profile_int, METH_NOARGS},
#endif
@@ -4483,10 +4474,8 @@ static PyMethodDef TestMethods[] = {
docstring_with_signature_with_defaults},
{"raise_signal",
(PyCFunction)test_raise_signal, METH_VARARGS},
-#ifdef WITH_THREAD
{"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_O,
PyDoc_STR("set_error_class(error_class) -> None")},
-#endif
{"pymarshal_write_long_to_file",
pymarshal_write_long_to_file, METH_VARARGS},
{"pymarshal_write_object_to_file",
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index da750c0..d58ebc3 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -4,13 +4,6 @@
#include "Python.h"
#include "structmember.h" /* offsetof */
-
-#ifndef WITH_THREAD
-#error "Error! The rest of Python is not compiled with thread support."
-#error "Rerun configure, adding a --with-threads option."
-#error "Then run `make clean' followed by `make'."
-#endif
-
#include "pythread.h"
static PyObject *ThreadError;
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 7ed2b02..91d3dd5 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -26,9 +26,7 @@ Copyright (C) 1994 Steen Lumholt.
#include "Python.h"
#include <ctype.h>
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#ifdef MS_WINDOWS
#include <windows.h>
@@ -161,8 +159,6 @@ _get_tcl_lib_path()
}
#endif /* MS_WINDOWS */
-#ifdef WITH_THREAD
-
/* The threading situation is complicated. Tcl is not thread-safe, except
when configured with --enable-threads.
@@ -264,18 +260,6 @@ static PyThreadState *tcl_tstate = NULL;
return 0; \
}
-#else
-
-#define ENTER_TCL
-#define LEAVE_TCL
-#define ENTER_OVERLAP
-#define LEAVE_OVERLAP_TCL
-#define ENTER_PYTHON
-#define LEAVE_PYTHON
-#define CHECK_TCL_APPARTMENT
-
-#endif
-
#ifndef FREECAST
#define FREECAST (char *)
#endif
@@ -340,7 +324,6 @@ Tkinter_Error(PyObject *v)
static int Tkinter_busywaitinterval = 20;
-#ifdef WITH_THREAD
#ifndef MS_WINDOWS
/* Millisecond sleep() for Unix platforms. */
@@ -374,7 +357,6 @@ WaitForMainloop(TkappObject* self)
PyErr_SetString(PyExc_RuntimeError, "main thread is not in main loop");
return 0;
}
-#endif /* WITH_THREAD */
@@ -652,13 +634,11 @@ Tkapp_New(const char *screenName, const char *className,
return 0;
}
#endif
-#ifdef WITH_THREAD
if (v->threaded && tcl_lock) {
/* If Tcl is threaded, we don't need the lock. */
PyThread_free_lock(tcl_lock);
tcl_lock = NULL;
}
-#endif
v->OldBooleanType = Tcl_GetObjType("boolean");
v->BooleanType = Tcl_GetObjType("booleanString");
@@ -790,7 +770,6 @@ Tkapp_New(const char *screenName, const char *className,
}
-#ifdef WITH_THREAD
static void
Tkapp_ThreadSend(TkappObject *self, Tcl_Event *ev,
Tcl_Condition *cond, Tcl_Mutex *mutex)
@@ -803,7 +782,6 @@ Tkapp_ThreadSend(TkappObject *self, Tcl_Event *ev,
Tcl_MutexUnlock(mutex);
Py_END_ALLOW_THREADS
}
-#endif
/** Tcl Eval **/
@@ -1340,7 +1318,6 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
return newPyTclObject(value);
}
-#ifdef WITH_THREAD
/* This mutex synchronizes inter-thread command calls. */
TCL_DECLARE_MUTEX(call_mutex)
@@ -1353,7 +1330,6 @@ typedef struct Tkapp_CallEvent {
PyObject **exc_type, **exc_value, **exc_tb;
Tcl_Condition *done;
} Tkapp_CallEvent;
-#endif
void
Tkapp_CallDeallocArgs(Tcl_Obj** objv, Tcl_Obj** objStore, int objc)
@@ -1444,7 +1420,6 @@ Tkapp_CallResult(TkappObject *self)
return res;
}
-#ifdef WITH_THREAD
/* Tkapp_CallProc is the event procedure that is executed in the context of
the Tcl interpreter thread. Initially, it holds the Tcl lock, and doesn't
@@ -1490,7 +1465,6 @@ done:
return 1;
}
-#endif
/* This is the main entry point for calling a Tcl command.
It supports three cases, with regard to threading:
@@ -1520,7 +1494,6 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
if (PyTuple_Check(item))
args = item;
}
-#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
/* We cannot call the command directly. Instead, we must
marshal the parameters to the interpreter thread. */
@@ -1554,7 +1527,6 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
Tcl_ConditionFinalize(&cond);
}
else
-#endif
{
objv = Tkapp_CallArgs(args, objStore, &objc);
@@ -1695,7 +1667,6 @@ _tkinter_tkapp_adderrinfo_impl(TkappObject *self, const char *msg)
typedef PyObject* (*EventFunc)(PyObject*, PyObject *args, int flags);
-#ifdef WITH_THREAD
TCL_DECLARE_MUTEX(var_mutex)
typedef struct VarEvent {
@@ -1709,7 +1680,6 @@ typedef struct VarEvent {
PyObject **exc_val;
Tcl_Condition *cond;
} VarEvent;
-#endif
/*[python]
@@ -1765,7 +1735,6 @@ varname_converter(PyObject *in, void *_out)
return 0;
}
-#ifdef WITH_THREAD
static void
var_perform(VarEvent *ev)
@@ -1794,12 +1763,10 @@ var_proc(VarEvent* ev, int flags)
return 1;
}
-#endif
static PyObject*
var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
{
-#ifdef WITH_THREAD
TkappObject *self = (TkappObject*)selfptr;
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
VarEvent *ev;
@@ -1836,7 +1803,6 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
}
return res;
}
-#endif
/* Tcl is not threaded, or this is the interpreter thread. */
return func(selfptr, args, flags);
}
@@ -2455,7 +2421,6 @@ PythonCmdDelete(ClientData clientData)
-#ifdef WITH_THREAD
TCL_DECLARE_MUTEX(command_mutex)
typedef struct CommandEvent{
@@ -2482,7 +2447,6 @@ Tkapp_CommandProc(CommandEvent *ev, int flags)
Tcl_MutexUnlock(&command_mutex);
return 1;
}
-#endif
/*[clinic input]
_tkinter.tkapp.createcommand
@@ -2507,11 +2471,9 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
return NULL;
}
-#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread() &&
!WaitForMainloop(self))
return NULL;
-#endif
data = PyMem_NEW(PythonCmd_ClientData, 1);
if (!data)
@@ -2520,7 +2482,6 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
Py_INCREF(func);
data->self = (PyObject *) self;
data->func = func;
-#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
Tcl_Condition cond = NULL;
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
@@ -2540,7 +2501,6 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
Tcl_ConditionFinalize(&cond);
}
else
-#endif
{
ENTER_TCL
err = Tcl_CreateCommand(
@@ -2575,7 +2535,6 @@ _tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name)
CHECK_STRING_LENGTH(name);
-#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
Tcl_Condition cond = NULL;
CommandEvent *ev;
@@ -2595,7 +2554,6 @@ _tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name)
Tcl_ConditionFinalize(&cond);
}
else
-#endif
{
ENTER_TCL
err = Tcl_DeleteCommand(self->interp, name);
@@ -2898,9 +2856,7 @@ static PyObject *
_tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
/*[clinic end generated code: output=0ba8eabbe57841b0 input=036bcdcf03d5eca0]*/
{
-#ifdef WITH_THREAD
PyThreadState *tstate = PyThreadState_Get();
-#endif
CHECK_TCL_APPARTMENT;
self->dispatching = 1;
@@ -2912,7 +2868,6 @@ _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
{
int result;
-#ifdef WITH_THREAD
if (self->threaded) {
/* Allow other Python threads to run. */
ENTER_TCL
@@ -2930,9 +2885,6 @@ _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
}
-#else
- result = Tcl_DoOneEvent(0);
-#endif
if (PyErr_CheckSignals() != 0) {
self->dispatching = 0;
@@ -3366,9 +3318,7 @@ MyFileProc(void *clientData, int mask)
}
#endif
-#ifdef WITH_THREAD
static PyThreadState *event_tstate = NULL;
-#endif
static int
EventHook(void)
@@ -3376,9 +3326,7 @@ EventHook(void)
#ifndef MS_WINDOWS
int tfile;
#endif
-#ifdef WITH_THREAD
PyEval_RestoreThread(event_tstate);
-#endif
stdin_ready = 0;
errorInCmd = 0;
#ifndef MS_WINDOWS
@@ -3393,7 +3341,6 @@ EventHook(void)
break;
}
#endif
-#if defined(WITH_THREAD) || defined(MS_WINDOWS)
Py_BEGIN_ALLOW_THREADS
if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1);
tcl_tstate = event_tstate;
@@ -3405,9 +3352,6 @@ EventHook(void)
if (result == 0)
Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
-#else
- result = Tcl_DoOneEvent(0);
-#endif
if (result < 0)
break;
@@ -3421,9 +3365,7 @@ EventHook(void)
excInCmd = valInCmd = trbInCmd = NULL;
PyErr_Print();
}
-#ifdef WITH_THREAD
PyEval_SaveThread();
-#endif
return 0;
}
@@ -3434,9 +3376,7 @@ EnableEventHook(void)
{
#ifdef WAIT_FOR_STDIN
if (PyOS_InputHook == NULL) {
-#ifdef WITH_THREAD
event_tstate = PyThreadState_Get();
-#endif
PyOS_InputHook = EventHook;
}
#endif
@@ -3470,11 +3410,9 @@ PyInit__tkinter(void)
{
PyObject *m, *uexe, *cexe, *o;
-#ifdef WITH_THREAD
tcl_lock = PyThread_allocate_lock();
if (tcl_lock == NULL)
return NULL;
-#endif
m = PyModule_Create(&_tkintermodule);
if (m == NULL)
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 6966b86..feb32a0 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -51,7 +51,7 @@ static struct {
int use_domain;
} tracemalloc_config = {TRACEMALLOC_NOT_INITIALIZED, 0, 1, 0};
-#if defined(TRACE_RAW_MALLOC) && defined(WITH_THREAD)
+#if defined(TRACE_RAW_MALLOC)
/* This lock is needed because tracemalloc_free() is called without
the GIL held from PyMem_RawFree(). It cannot acquire the lock because it
would introduce a deadlock in PyThreadState_DeleteCurrent(). */
@@ -164,7 +164,7 @@ tracemalloc_error(const char *format, ...)
#endif
-#if defined(WITH_THREAD) && defined(TRACE_RAW_MALLOC)
+#if defined(TRACE_RAW_MALLOC)
#define REENTRANT_THREADLOCAL
/* If your OS does not provide native thread local storage, you can implement
@@ -212,8 +212,7 @@ set_reentrant(int reentrant)
#else
-/* WITH_THREAD not defined: Python compiled without threads,
- or TRACE_RAW_MALLOC not defined: variable protected by the GIL */
+/* TRACE_RAW_MALLOC not defined: variable protected by the GIL */
static int tracemalloc_reentrant = 0;
static int
@@ -455,11 +454,7 @@ traceback_get_frames(traceback_t *traceback)
PyThreadState *tstate;
PyFrameObject *pyframe;
-#ifdef WITH_THREAD
tstate = PyGILState_GetThisThreadState();
-#else
- tstate = PyThreadState_Get();
-#endif
if (tstate == NULL) {
#ifdef TRACE_DEBUG
tracemalloc_error("failed to get the current thread state");
@@ -483,9 +478,7 @@ traceback_new(void)
traceback_t *traceback;
_Py_hashtable_entry_t *entry;
-#ifdef WITH_THREAD
assert(PyGILState_Check());
-#endif
/* get frames */
traceback = tracemalloc_traceback;
@@ -848,9 +841,7 @@ tracemalloc_realloc_gil(void *ctx, void *ptr, size_t new_size)
static void*
tracemalloc_raw_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
{
-#ifdef WITH_THREAD
PyGILState_STATE gil_state;
-#endif
void *ptr;
if (get_reentrant()) {
@@ -866,13 +857,9 @@ tracemalloc_raw_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
disabled. */
set_reentrant(1);
-#ifdef WITH_THREAD
gil_state = PyGILState_Ensure();
ptr = tracemalloc_alloc(use_calloc, ctx, nelem, elsize);
PyGILState_Release(gil_state);
-#else
- ptr = tracemalloc_alloc(use_calloc, ctx, nelem, elsize);
-#endif
set_reentrant(0);
return ptr;
@@ -896,9 +883,7 @@ tracemalloc_raw_calloc(void *ctx, size_t nelem, size_t elsize)
static void*
tracemalloc_raw_realloc(void *ctx, void *ptr, size_t new_size)
{
-#ifdef WITH_THREAD
PyGILState_STATE gil_state;
-#endif
void *ptr2;
if (get_reentrant()) {
@@ -920,13 +905,9 @@ tracemalloc_raw_realloc(void *ctx, void *ptr, size_t new_size)
not disabled. */
set_reentrant(1);
-#ifdef WITH_THREAD
gil_state = PyGILState_Ensure();
ptr2 = tracemalloc_realloc(ctx, ptr, new_size);
PyGILState_Release(gil_state);
-#else
- ptr2 = tracemalloc_realloc(ctx, ptr, new_size);
-#endif
set_reentrant(0);
return ptr2;
@@ -962,10 +943,8 @@ traceback_free_traceback(_Py_hashtable_t *ht, _Py_hashtable_entry_t *entry,
static void
tracemalloc_clear_traces(void)
{
-#ifdef WITH_THREAD
/* The GIL protects variables againt concurrent access */
assert(PyGILState_Check());
-#endif
TABLES_LOCK();
_Py_hashtable_clear(tracemalloc_traces);
@@ -1007,7 +986,7 @@ tracemalloc_init(void)
}
#endif
-#if defined(WITH_THREAD) && defined(TRACE_RAW_MALLOC)
+#if defined(TRACE_RAW_MALLOC)
if (tables_lock == NULL) {
tables_lock = PyThread_allocate_lock();
if (tables_lock == NULL) {
@@ -1074,7 +1053,7 @@ tracemalloc_deinit(void)
_Py_hashtable_destroy(tracemalloc_filenames);
_Py_hashtable_destroy(tracemalloc_traces);
-#if defined(WITH_THREAD) && defined(TRACE_RAW_MALLOC)
+#if defined(TRACE_RAW_MALLOC)
if (tables_lock != NULL) {
PyThread_free_lock(tables_lock);
tables_lock = NULL;
@@ -1723,9 +1702,7 @@ _PyTraceMalloc_Init(void)
char *p;
int nframe;
-#ifdef WITH_THREAD
assert(PyGILState_Check());
-#endif
if ((p = Py_GETENV("PYTHONTRACEMALLOC")) && *p != '\0') {
char *endptr = p;
@@ -1778,9 +1755,7 @@ _PyTraceMalloc_Init(void)
void
_PyTraceMalloc_Fini(void)
{
-#ifdef WITH_THREAD
assert(PyGILState_Check());
-#endif
tracemalloc_deinit();
}
@@ -1789,26 +1764,20 @@ PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr,
size_t size)
{
int res;
-#ifdef WITH_THREAD
PyGILState_STATE gil_state;
-#endif
if (!tracemalloc_config.tracing) {
/* tracemalloc is not tracing: do nothing */
return -2;
}
-#ifdef WITH_THREAD
gil_state = PyGILState_Ensure();
-#endif
TABLES_LOCK();
res = tracemalloc_add_trace(domain, ptr, size);
TABLES_UNLOCK();
-#ifdef WITH_THREAD
PyGILState_Release(gil_state);
-#endif
return res;
}
diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h
index 4405d60..a4542cc 100644
--- a/Modules/clinic/signalmodule.c.h
+++ b/Modules/clinic/signalmodule.c.h
@@ -363,7 +363,7 @@ exit:
#endif /* defined(HAVE_SIGTIMEDWAIT) */
-#if (defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD))
+#if defined(HAVE_PTHREAD_KILL)
PyDoc_STRVAR(signal_pthread_kill__doc__,
"pthread_kill($module, thread_id, signalnum, /)\n"
@@ -395,7 +395,7 @@ exit:
return return_value;
}
-#endif /* (defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD)) */
+#endif /* defined(HAVE_PTHREAD_KILL) */
#ifndef SIGNAL_ALARM_METHODDEF
#define SIGNAL_ALARM_METHODDEF
@@ -440,4 +440,4 @@ exit:
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
-/*[clinic end generated code: output=9403ef0c5d0f7ee0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3f6e6298696f1b75 input=a9049054013a1b77]*/
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 39b70bc..4f3d971 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -17,9 +17,7 @@
/* Allocate at maximum 100 MB of the stack to raise the stack overflow */
#define STACK_OVERFLOW_MAX_SIZE (100*1024*1024)
-#ifdef WITH_THREAD
-# define FAULTHANDLER_LATER
-#endif
+#define FAULTHANDLER_LATER
#ifndef MS_WINDOWS
/* register() is useless on Windows, because only SIGSEGV, SIGABRT and
@@ -228,7 +226,6 @@ faulthandler_dump_traceback(int fd, int all_threads,
reentrant = 1;
-#ifdef WITH_THREAD
/* SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals and
are thus delivered to the thread that caused the fault. Get the Python
thread state of the current thread.
@@ -238,9 +235,6 @@ faulthandler_dump_traceback(int fd, int all_threads,
used. Read the thread local storage (TLS) instead: call
PyGILState_GetThisThreadState(). */
tstate = PyGILState_GetThisThreadState();
-#else
- tstate = _PyThreadState_UncheckedGet();
-#endif
if (all_threads) {
(void)_Py_DumpTracebackThreads(fd, NULL, tstate);
@@ -977,7 +971,6 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-#ifdef WITH_THREAD
static void
faulthandler_fatal_error_thread(void *plock)
{
@@ -1027,7 +1020,6 @@ faulthandler_fatal_error_c_thread(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-#endif
static PyObject *
faulthandler_sigfpe(PyObject *self, PyObject *args)
@@ -1198,11 +1190,9 @@ static PyMethodDef module_methods[] = {
"a SIGSEGV or SIGBUS signal depending on the platform")},
{"_sigsegv", faulthandler_sigsegv, METH_VARARGS,
PyDoc_STR("_sigsegv(release_gil=False): raise a SIGSEGV signal")},
-#ifdef WITH_THREAD
{"_fatal_error_c_thread", faulthandler_fatal_error_c_thread, METH_NOARGS,
PyDoc_STR("fatal_error_c_thread(): "
"call Py_FatalError() in a new C thread.")},
-#endif
{"_sigabrt", faulthandler_sigabrt, METH_NOARGS,
PyDoc_STR("_sigabrt(): raise a SIGABRT signal")},
{"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
diff --git a/Modules/hashlib.h b/Modules/hashlib.h
index 530b6b1..978593e 100644
--- a/Modules/hashlib.h
+++ b/Modules/hashlib.h
@@ -39,24 +39,19 @@
* an operation.
*/
-#ifdef WITH_THREAD
#include "pythread.h"
- #define ENTER_HASHLIB(obj) \
- if ((obj)->lock) { \
- if (!PyThread_acquire_lock((obj)->lock, 0)) { \
- Py_BEGIN_ALLOW_THREADS \
- PyThread_acquire_lock((obj)->lock, 1); \
- Py_END_ALLOW_THREADS \
- } \
- }
- #define LEAVE_HASHLIB(obj) \
- if ((obj)->lock) { \
- PyThread_release_lock((obj)->lock); \
- }
-#else
- #define ENTER_HASHLIB(obj)
- #define LEAVE_HASHLIB(obj)
-#endif
+#define ENTER_HASHLIB(obj) \
+ if ((obj)->lock) { \
+ if (!PyThread_acquire_lock((obj)->lock, 0)) { \
+ Py_BEGIN_ALLOW_THREADS \
+ PyThread_acquire_lock((obj)->lock, 1); \
+ Py_END_ALLOW_THREADS \
+ } \
+ }
+#define LEAVE_HASHLIB(obj) \
+ if ((obj)->lock) { \
+ PyThread_release_lock((obj)->lock); \
+ }
/* TODO(gps): We should probably make this a module or EVPobject attribute
* to allow the user to optimize based on the platform they're using. */
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 7b57d8b..83135e5 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -359,7 +359,7 @@ static int win32_can_symlink = 0;
/* Don't use the "_r" form if we don't need it (also, won't have a
prototype for it, at least on Solaris -- maybe others as well?). */
-#if defined(HAVE_CTERMID_R) && defined(WITH_THREAD)
+#if defined(HAVE_CTERMID_R)
#define USE_CTERMID_R
#endif
@@ -454,14 +454,12 @@ PyOS_AfterFork_Parent(void)
void
PyOS_AfterFork_Child(void)
{
-#ifdef WITH_THREAD
/* PyThread_ReInitTLS() must be called early, to make sure that the TLS API
* can be called safely. */
PyThread_ReInitTLS();
_PyGILState_Reinit();
PyEval_ReInitThreads();
_PyImport_ReInitLock();
-#endif
_PySignal_AfterFork();
run_at_forkers(PyThreadState_Get()->interp->after_forkers_child, 0);
diff --git a/Modules/readline.c b/Modules/readline.c
index f4a5e5a..951bc82 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -896,13 +896,9 @@ on_startup_hook()
#endif
{
int r;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
-#endif
r = on_hook(readlinestate_global->startup_hook);
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return r;
}
@@ -915,13 +911,9 @@ on_pre_input_hook()
#endif
{
int r;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
-#endif
r = on_hook(readlinestate_global->pre_input_hook);
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return r;
}
#endif
@@ -936,9 +928,7 @@ on_completion_display_matches_hook(char **matches,
{
int i;
PyObject *sub, *m=NULL, *s=NULL, *r=NULL;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
-#endif
m = PyList_New(num_matches);
if (m == NULL)
goto error;
@@ -967,9 +957,7 @@ on_completion_display_matches_hook(char **matches,
Py_XDECREF(m);
Py_XDECREF(r);
}
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
}
#endif
@@ -1002,9 +990,7 @@ on_completion(const char *text, int state)
char *result = NULL;
if (readlinestate_global->completer != NULL) {
PyObject *r = NULL, *t;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
-#endif
rl_attempted_completion_over = 1;
t = decode(text);
r = PyObject_CallFunction(readlinestate_global->completer, "Ni", t, state);
@@ -1026,9 +1012,7 @@ on_completion(const char *text, int state)
PyErr_Clear();
Py_XDECREF(r);
done:
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return result;
}
return result;
@@ -1045,9 +1029,7 @@ flex_complete(const char *text, int start, int end)
char saved;
size_t start_size, end_size;
wchar_t *s;
-#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
-#endif
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
rl_completion_append_character ='\0';
#endif
@@ -1080,9 +1062,7 @@ done:
readlinestate_global->begidx = PyLong_FromLong((long) start);
readlinestate_global->endidx = PyLong_FromLong((long) end);
result = completion_matches((char *)text, *on_completion);
-#ifdef WITH_THREAD
PyGILState_Release(gilstate);
-#endif
return result;
}
@@ -1234,13 +1214,9 @@ readline_until_enter_or_signal(const char *prompt, int *signal)
}
else if (err == EINTR) {
int s;
-#ifdef WITH_THREAD
PyEval_RestoreThread(_PyOS_ReadlineTState);
-#endif
s = PyErr_CheckSignals();
-#ifdef WITH_THREAD
PyEval_SaveThread();
-#endif
if (s < 0) {
rl_free_line_state();
#if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0700
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 1c827ac..6633108 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -85,12 +85,10 @@ module signal
thread. XXX This is a hack.
*/
-#ifdef WITH_THREAD
#include <sys/types.h> /* For pid_t */
#include "pythread.h"
static unsigned long main_thread;
static pid_t main_pid;
-#endif
static volatile struct {
_Py_atomic_int tripped;
@@ -316,10 +314,8 @@ signal_handler(int sig_num)
{
int save_errno = errno;
-#ifdef WITH_THREAD
/* See NOTES section above */
if (getpid() == main_pid)
-#endif
{
trip_signal(sig_num);
}
@@ -439,13 +435,11 @@ signal_signal_impl(PyObject *module, int signalnum, PyObject *handler)
return NULL;
}
#endif
-#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,
"signal only works in main thread");
return NULL;
}
-#endif
if (signalnum < 1 || signalnum >= NSIG) {
PyErr_SetString(PyExc_ValueError,
"signal number out of range");
@@ -571,13 +565,11 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
return NULL;
#endif
-#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,
"set_wakeup_fd only works in main thread");
return NULL;
}
-#endif
#ifdef MS_WINDOWS
is_socket = 0;
@@ -1104,7 +1096,7 @@ signal_sigtimedwait_impl(PyObject *module, PyObject *sigset,
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
-#if defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD)
+#if defined(HAVE_PTHREAD_KILL)
/*[clinic input]
signal.pthread_kill
@@ -1137,7 +1129,7 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
Py_RETURN_NONE;
}
-#endif /* #if defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD) */
+#endif /* #if defined(HAVE_PTHREAD_KILL) */
@@ -1217,10 +1209,8 @@ PyInit__signal(void)
PyObject *m, *d, *x;
int i;
-#ifdef WITH_THREAD
main_thread = PyThread_get_thread_ident();
main_pid = getpid();
-#endif
/* Create the module and add the functions */
m = PyModule_Create(&signalmodule);
@@ -1523,10 +1513,8 @@ PyErr_CheckSignals(void)
if (!_Py_atomic_load(&is_tripped))
return 0;
-#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread)
return 0;
-#endif
/*
* The is_tripped variable is meant to speed up the calls to
@@ -1599,10 +1587,8 @@ int
PyOS_InterruptOccurred(void)
{
if (_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
-#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread)
return 0;
-#endif
_Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
return 1;
}
@@ -1628,20 +1614,14 @@ _PySignal_AfterFork(void)
* in both processes if they came in just before the fork() but before
* the interpreter had an opportunity to call the handlers. issue9535. */
_clear_pending_signals();
-#ifdef WITH_THREAD
main_thread = PyThread_get_thread_ident();
main_pid = getpid();
-#endif
}
int
_PyOS_IsMainThread(void)
{
-#ifdef WITH_THREAD
return PyThread_get_thread_ident() == main_thread;
-#else
- return 1;
-#endif
}
#ifdef MS_WINDOWS
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index a431e25..2c2f98d 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -163,10 +163,6 @@ if_indextoname(index) -- return the corresponding interface name\n\
# include <sys/uio.h>
#endif
-#if !defined(WITH_THREAD)
-# undef HAVE_GETHOSTBYNAME_R
-#endif
-
#if defined(__ANDROID__) && __ANDROID_API__ < 23
# undef HAVE_GETHOSTBYNAME_R
#endif
@@ -185,8 +181,7 @@ if_indextoname(index) -- return the corresponding interface name\n\
# endif
#endif
-#if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && \
- !defined(MS_WINDOWS)
+#if !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
# define USE_GETHOSTBYNAME_LOCK
#endif
@@ -210,8 +205,7 @@ if_indextoname(index) -- return the corresponding interface name\n\
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83
*/
-#if defined(WITH_THREAD) && ( \
- (defined(__APPLE__) && \
+#if ((defined(__APPLE__) && \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \
(defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \
(defined(__OpenBSD__) && OpenBSD+0 < 201311) || \
@@ -656,10 +650,8 @@ internal_select(PySocketSockObject *s, int writing, _PyTime_t interval,
struct timeval tv, *tvp;
#endif
-#ifdef WITH_THREAD
/* must be called with the GIL held */
assert(PyGILState_Check());
-#endif
/* Error condition is for output only */
assert(!(connect && !writing));
@@ -758,10 +750,8 @@ sock_call_ex(PySocketSockObject *s,
int deadline_initialized = 0;
int res;
-#ifdef WITH_THREAD
/* sock_call() must be called with the GIL held. */
assert(PyGILState_Check());
-#endif
/* outer loop to retry select() when select() is interrupted by a signal
or to retry select()+sock_func() on false positive (see above) */
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 32dd817..cf086de 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -10,17 +10,12 @@
#include "zlib.h"
-#ifdef WITH_THREAD
- #include "pythread.h"
- #define ENTER_ZLIB(obj) \
- Py_BEGIN_ALLOW_THREADS; \
- PyThread_acquire_lock((obj)->lock, 1); \
- Py_END_ALLOW_THREADS;
- #define LEAVE_ZLIB(obj) PyThread_release_lock((obj)->lock);
-#else
- #define ENTER_ZLIB(obj)
- #define LEAVE_ZLIB(obj)
-#endif
+#include "pythread.h"
+#define ENTER_ZLIB(obj) \
+ Py_BEGIN_ALLOW_THREADS; \
+ PyThread_acquire_lock((obj)->lock, 1); \
+ Py_END_ALLOW_THREADS;
+#define LEAVE_ZLIB(obj) PyThread_release_lock((obj)->lock);
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1221
# define AT_LEAST_ZLIB_1_2_2_1
@@ -51,9 +46,7 @@ typedef struct
char eof;
int is_initialised;
PyObject *zdict;
- #ifdef WITH_THREAD
- PyThread_type_lock lock;
- #endif
+ PyThread_type_lock lock;
} compobject;
static void
@@ -112,14 +105,12 @@ newcompobject(PyTypeObject *type)
Py_DECREF(self);
return NULL;
}
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
Py_DECREF(self);
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return NULL;
}
-#endif
return self;
}
@@ -615,9 +606,7 @@ zlib_decompressobj_impl(PyObject *module, int wbits, PyObject *zdict)
static void
Dealloc(compobject *self)
{
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
-#endif
Py_XDECREF(self->unused_data);
Py_XDECREF(self->unconsumed_tail);
Py_XDECREF(self->zdict);