From a60fd7e6a8f59fb3f0fb7feae62c8a8df9ca33e7 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 16 Feb 2015 09:40:12 +0200 Subject: Fixed few compiler warnings. --- Python/pystate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 2ac2fd5274..32a635c789 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -403,7 +403,7 @@ tstate_delete_common(PyThreadState *tstate) void PyThreadState_Delete(PyThreadState *tstate) { - if (tstate == _Py_atomic_load_relaxed(&_PyThreadState_Current)) + if (tstate == (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) Py_FatalError("PyThreadState_Delete: tstate is still current"); #ifdef WITH_THREAD if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate) @@ -662,7 +662,7 @@ PyThreadState_IsCurrent(PyThreadState *tstate) { /* Must be the tstate for this thread */ assert(PyGILState_GetThisThreadState()==tstate); - return tstate == _Py_atomic_load_relaxed(&_PyThreadState_Current); + return tstate == (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current); } /* Internal initialization/finalization functions called by -- cgit v1.2.1 From 6139bc8c6c02db0e084b495d1fe5ac9707635ecb Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 6 Mar 2015 14:47:02 -0800 Subject: Issue #23524: Replace _PyVerify_fd function with calling _set_thread_local_invalid_parameter_handler on every thread. --- Python/pystate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 32a635c789..ee1e469635 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -22,6 +22,12 @@ to avoid the expense of doing their own locking). #endif #endif +#if defined _MSC_VER && _MSC_VER >= 1900 +/* Issue #23524: Temporary fix to disable termination due to invalid parameters */ +PyAPI_DATA(void*) _Py_silent_invalid_parameter_handler; +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -222,6 +228,11 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK(); + +#if defined _MSC_VER && _MSC_VER >= 1900 + /* Issue #23524: Temporary fix to disable termination due to invalid parameters */ + _set_thread_local_invalid_parameter_handler((_invalid_parameter_handler)_Py_silent_invalid_parameter_handler); +#endif } return tstate; -- cgit v1.2.1 From ab401006bd13992bf70ebf394f974c20001c2f4f Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 18 Mar 2015 21:53:15 +0200 Subject: Removed unintentional trailing spaces in non-external and non-generated C files. --- Python/pystate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index ee1e469635..926ef07e21 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -228,7 +228,7 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK(); - + #if defined _MSC_VER && _MSC_VER >= 1900 /* Issue #23524: Temporary fix to disable termination due to invalid parameters */ _set_thread_local_invalid_parameter_handler((_invalid_parameter_handler)_Py_silent_invalid_parameter_handler); -- cgit v1.2.1 From e07a52f272f00b6707b40f557e481749b73dd0fd Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 12 Apr 2015 00:26:27 -0400 Subject: Issue #23524: Replace _PyVerify_fd function with calls to _set_thread_local_invalid_parameter_handler. --- Python/pystate.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 926ef07e21..32a635c789 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -22,12 +22,6 @@ to avoid the expense of doing their own locking). #endif #endif -#if defined _MSC_VER && _MSC_VER >= 1900 -/* Issue #23524: Temporary fix to disable termination due to invalid parameters */ -PyAPI_DATA(void*) _Py_silent_invalid_parameter_handler; -#include -#endif - #ifdef __cplusplus extern "C" { #endif @@ -228,11 +222,6 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK(); - -#if defined _MSC_VER && _MSC_VER >= 1900 - /* Issue #23524: Temporary fix to disable termination due to invalid parameters */ - _set_thread_local_invalid_parameter_handler((_invalid_parameter_handler)_Py_silent_invalid_parameter_handler); -#endif } return tstate; -- cgit v1.2.1 From ea639832c36905ecb07caba111f614c4bbf9bdd6 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Mon, 11 May 2015 22:57:16 -0400 Subject: PEP 0492 -- Coroutines with async and await syntax. Issue #24017. --- Python/pystate.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 32a635c789..e214f50497 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -212,6 +212,8 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->on_delete = NULL; tstate->on_delete_data = NULL; + tstate->coroutine_wrapper = NULL; + if (init) _PyThreadState_Init(tstate); @@ -372,6 +374,8 @@ PyThreadState_Clear(PyThreadState *tstate) tstate->c_tracefunc = NULL; Py_CLEAR(tstate->c_profileobj); Py_CLEAR(tstate->c_traceobj); + + Py_CLEAR(tstate->coroutine_wrapper); } -- cgit v1.2.1 From 599ed75a674f7ad2c983783ed6f3a75bd5ccae18 Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Sat, 23 May 2015 22:24:10 +1000 Subject: PEP 489: Multi-phase extension module initialization Known limitations of the current implementation: - documentation changes are incomplete - there's a reference leak I haven't tracked down yet The leak is most visible by running: ./python -m test -R3:3 test_importlib However, you can also see it by running: ./python -X showrefcount Importing the array or _testmultiphase modules, and then deleting them from both sys.modules and the local namespace shows significant increases in the total number of active references each cycle. By contrast, with _testcapi (which continues to use single-phase initialisation) the global refcounts stabilise after a couple of cycles. --- Python/pystate.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index e214f50497..4ac05d6625 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -255,6 +255,9 @@ PyState_FindModule(struct PyModuleDef* module) Py_ssize_t index = module->m_base.m_index; PyInterpreterState *state = PyThreadState_GET()->interp; PyObject *res; + if (module->m_slots) { + return NULL; + } if (index == 0) return NULL; if (state->modules_by_index == NULL) @@ -268,7 +271,13 @@ PyState_FindModule(struct PyModuleDef* module) int _PyState_AddModule(PyObject* module, struct PyModuleDef* def) { - PyInterpreterState *state = PyThreadState_GET()->interp; + PyInterpreterState *state; + if (def->m_slots) { + PyErr_SetString(PyExc_SystemError, + "PyState_AddModule called on module with slots"); + return -1; + } + state = PyThreadState_GET()->interp; if (!def) return -1; if (!state->modules_by_index) { @@ -308,8 +317,14 @@ PyState_AddModule(PyObject* module, struct PyModuleDef* def) int PyState_RemoveModule(struct PyModuleDef* def) { + PyInterpreterState *state; Py_ssize_t index = def->m_base.m_index; - PyInterpreterState *state = PyThreadState_GET()->interp; + if (def->m_slots) { + PyErr_SetString(PyExc_SystemError, + "PyState_RemoveModule called on module with slots"); + return -1; + } + state = PyThreadState_GET()->interp; if (index == 0) { Py_FatalError("PyState_RemoveModule: Module index invalid."); return -1; -- cgit v1.2.1 From f28b7448cd4c7d325fee3c4bf4584f655eafccdb Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 2 Jun 2015 18:43:51 -0400 Subject: Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully --- Python/pystate.c | 1 + 1 file changed, 1 insertion(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 4ac05d6625..7e0267ae1d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -213,6 +213,7 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->on_delete_data = NULL; tstate->coroutine_wrapper = NULL; + tstate->in_coroutine_wrapper = 0; if (init) _PyThreadState_Init(tstate); -- cgit v1.2.1