summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
Commit message (Collapse)AuthorAgeFilesLines
* Add more checks on the GILVictor Stinner2016-03-141-5/+19
| | | | | | | | | | | | Issue #10915, #15751, #26558: * PyGILState_Check() now returns 1 (success) before the creation of the GIL and after the destruction of the GIL. It allows to use the function early in Python initialization and late in Python finalization. * Add a flag to disable PyGILState_Check(). Disable PyGILState_Check() when Py_NewInterpreter() is called * Add assert(PyGILState_Check()) to: _Py_dup(), _Py_fstat(), _Py_read() and _Py_write()
* Use Py_uintptr_t for atomic pointersVictor Stinner2016-01-221-23/+24
| | | | | | | | Issue #26161: Use Py_uintptr_t instead of void* for atomic pointers in pyatomic.h. Use atomic_uintptr_t when <stdatomic.h> is used. Using void* causes compilation warnings depending on which implementation of atomic types is used.
* Merge 3.5Victor Stinner2016-01-201-13/+20
|\ | | | | | | Issue #26154: Add a new private _PyThreadState_UncheckedGet() function.
| * Add _PyThreadState_UncheckedGet()Victor Stinner2016-01-201-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26154: Add a new private _PyThreadState_UncheckedGet() function which gets the current thread state, but don't call Py_FatalError() if it is NULL. Python 3.5.1 removed the _PyThreadState_Current symbol from the Python C API to no more expose complex and private atomic types. Atomic types depends on the compiler or can even depend on compiler options. The new function _PyThreadState_UncheckedGet() allows to get the variable value without having to care of the exact implementation of atomic types. Changes: * Replace direct usage of the _PyThreadState_Current variable with a call to _PyThreadState_UncheckedGet(). * In pystate.c, replace direct usage of the _PyThreadState_Current variable with the PyThreadState_GET() macro for readability. * Document also PyThreadState_Get() in pystate.h
* | Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failureMartin Panter2015-11-301-1/+1
|/
* Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefullyYury Selivanov2015-06-021-0/+1
|
* PEP 489: Multi-phase extension module initializationNick Coghlan2015-05-231-2/+17
| | | | | | | | | | | | | | | | | | | | | | | 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.
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-0/+4
|
* Issue #23524: Replace _PyVerify_fd function with calls to ↵Steve Dower2015-04-121-11/+0
| | | | _set_thread_local_invalid_parameter_handler.
* Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka2015-03-181-1/+1
|
* Issue #23524: Replace _PyVerify_fd function with calling ↵Steve Dower2015-03-061-0/+11
| | | | _set_thread_local_invalid_parameter_handler on every thread.
* Fixed few compiler warnings.Serhiy Storchaka2015-02-161-2/+2
|
* Issue #19255: The builtins module is restored to initial value beforeSerhiy Storchaka2014-02-101-0/+2
| | | | cleaning other modules. The sys and builtins modules are cleaned last.
* Issue #19787: PyThread_set_key_value() now always set the valueVictor Stinner2013-12-131-9/+9
| | | | | | | | | | In Python 3.3, PyThread_set_key_value() did nothing if the key already exists (if the current value is a non-NULL pointer). When _PyGILState_NoteThreadState() is called twice on the same thread with a different Python thread state, it still keeps the old Python thread state to keep the old behaviour. Replacing the Python thread state with the new state introduces new bugs: see issues #10915 and #15751.
* Close #19576: PyGILState_Ensure() now initializes threads. At startup, PythonVictor Stinner2013-12-131-0/+5
| | | | | | has no concrete GIL. If PyGILState_Ensure() is called from a new thread for the first time and PyEval_InitThreads() was not called yet, a GIL needs to be created.
* Close #19199: Remove ``PyThreadState.tick_counter`` fieldVictor Stinner2013-10-091-1/+0
|
* Issue #18808: Thread.join() now waits for the underlying thread state to be ↵Antoine Pitrou2013-09-071-0/+5
| | | | | | destroyed before returning. This prevents unpredictable aborts in Py_EndInterpreter() when some non-daemon threads are still running.
* Issue #10241: Clear extension module dict copies at interpreter shutdown.Antoine Pitrou2013-08-101-0/+25
| | | | | | Patch by Neil Schemenauer, minimally modified. (re-apply after fix for tkinter-related crash)
* Backout 62658d9d8926 (issue #10241): it causes a crash at shutdown when ↵Antoine Pitrou2013-08-021-25/+0
| | | | deallocating a Tkapp object.
* Issue #10241: Clear extension module dict copies at interpreter shutdown.Antoine Pitrou2013-08-011-0/+25
| | | | Patch by Neil Schemenauer, minimally modified.
* Issue #18203: Replace malloc() with PyMem_RawMalloc() at Python initializationVictor Stinner2013-07-071-10/+10
| | | | | | | * Replace malloc() with PyMem_RawMalloc() * Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held. * _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead of PyMem_Malloc()
* Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now theChristian Heimes2013-07-011-2/+2
|\ | | | | | | | | | | tstate is first removed from TLS and then deallocated. CID 1019639 (#1 of 1): Use after free (USE_AFTER_FREE) use_after_free: Using freed pointer tstate.
| * Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now theChristian Heimes2013-07-011-2/+2
| | | | | | | | | | | | tstate is first removed from TLS and then deallocated. CID 1019639 (#1 of 1): Use after free (USE_AFTER_FREE) use_after_free: Using freed pointer tstate.
* | Issue #17912: Use a doubly linked-list for thread states.Charles-Francois Natali2013-05-081-41/+17
| |
* | Issue #17094: Clear stale thread states after fork().Antoine Pitrou2013-05-051-0/+47
| | | | | | | | | | | | | | Note that this is a potentially disruptive change since it may release some system resources which would otherwise remain perpetually alive (e.g. database connections kept in thread-local storage).
* | Issue #17522: Add the PyGILState_Check() API.Kristján Valur Jónsson2013-03-231-0/+9
|/
* Issue #13992: The trashcan mechanism is now thread-safe. This eliminatesAntoine Pitrou2012-09-051-0/+3
| | | | | | | | | | | sporadic crashes in multi-thread programs when several long deallocator chains ran concurrently and involved subclasses of built-in container types. Because of this change, a couple extension modules compiled for 3.2.4 (those which use the trashcan mechanism, despite it being undocumented) will not be loadable by 3.2.3 and earlier. However, extension modules compiled for 3.2.3 and earlier will be loadable by 3.2.4.
* Issue #15726: Fix incorrect bounds checking in PyState_FindModule.Antoine Pitrou2012-08-201-1/+1
|\ | | | | | | Patch by Robin Schreiber.
| * Issue #15726: Fix incorrect bounds checking in PyState_FindModule.Antoine Pitrou2012-08-201-1/+1
| | | | | | | | Patch by Robin Schreiber.
* | Issue #15042: Add PyState_AddModule and PyState_RemoveModule.Martin v. Löwis2012-06-221-2/+43
| | | | | | | | | | | | Add version guard for Py_LIMITED_API additions. Issue #15081: Document PyState_FindModule. Patch by Robin Schreiber.
* | Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.Brett Cannon2012-04-291-2/+0
| | | | | | | | Thanks to Eric Snow for the patch.
* | Issue #2377: Make importlib the implementation of __import__().Brett Cannon2012-04-141-0/+2
|/ | | | | | | importlib._bootstrap is now frozen into Python/importlib.h and stored as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen code along with sys and imp and then uses _frozen_importlib._install() to set builtins.__import__() w/ _frozen_importlib.__import__().
* move outside WITH_THREAD conditionalBenjamin Peterson2012-04-131-2/+2
|
* take linkage def outside of WITH_THREAD conditional (closes #14569)Benjamin Peterson2012-04-131-4/+3
|
* Issue #13156: _PyGILState_Reinit(): Re-associate the auto thread state with theCharles-François Natali2011-11-221-4/+5
| | | | | | TLS key only if the thread that called fork() had an associated auto thread state (this might not be the case for example for a thread created outside of Python calling into a subinterpreter).
* Issue #10363: Deallocate global locks in Py_Finalize().Antoine Pitrou2011-10-301-0/+6
|
* Issue #10914: Initialize correctly the filesystem codec when creating a newVictor Stinner2011-04-261-0/+1
| | | | | | | subinterpreter to fix a bootstrap issue with codecs implemented in Python, as the ISO-8859-15 codec. Add fscodec_initialized attribute to the PyInterpreterState structure.
* Issue #10517: After fork(), reinitialize the TLS used by the PyGILState_*Antoine Pitrou2011-04-271-0/+17
| | | | | APIs, to avoid a crash with the pthread implementation in RHEL 5. Patch by Charles-François Natali.
* #11565: Merge with 3.1.Ezio Melotti2011-03-161-1/+1
|\
| * #11565: Fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-161-1/+1
| |
| * Merged revisions 84623 via svnmerge fromAntoine Pitrou2010-09-081-8/+7
| | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84623 | antoine.pitrou | 2010-09-08 14:37:10 +0200 (mer., 08 sept. 2010) | 4 lines Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid thread-local storage key. ........
| * Recorded merge of revisions 81032 via svnmerge fromAntoine Pitrou2010-05-091-388/+388
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines Recorded merge of revisions 81029 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........ ................
| * Merged revisions 78639 via svnmerge fromVictor Stinner2010-03-031-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78639 | victor.stinner | 2010-03-04 00:28:07 +0100 (jeu., 04 mars 2010) | 10 lines Merged revisions 78638 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78638 | victor.stinner | 2010-03-04 00:20:25 +0100 (jeu., 04 mars 2010) | 3 lines Issue #7544: Preallocate thread memory before creating the thread to avoid a fatal error in low memory condition. ........ ................
* | issue 9786 Native TLS support for pthreadsKristján Valur Jónsson2010-09-201-0/+2
| | | | | | | | PyThread_create_key now has a failure mode that the applicatino can detect.
* | Issue #9797: pystate.c wrongly assumed that zero couldn't be a validAntoine Pitrou2010-09-081-8/+7
| | | | | | | | thread-local storage key.
* | Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-393/+393
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* | Make (most of) Python's tests pass under Thread Sanitizer.Jeffrey Yasskin2010-05-031-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://code.google.com/p/data-race-test/wiki/ThreadSanitizer is a dynamic data race detector that runs on top of valgrind. With this patch, the binaries at http://code.google.com/p/data-race-test/wiki/ThreadSanitizer#Binaries pass many but not all of the Python tests. All of regrtest still passes outside of tsan. I've implemented part of the C1x atomic types so that we can explicitly mark variables that are used across threads, and get defined behavior as compilers advance. I've added tsan's client header and implementation to the codebase in dynamic_annotations.{h,c} (docs at http://code.google.com/p/data-race-test/wiki/DynamicAnnotations). Unfortunately, I haven't been able to get helgrind and drd to give sensible error messages, even when I use their client annotations, so I'm not supporting them.
* | Merged revisions 78638 via svnmerge fromVictor Stinner2010-03-031-5/+24
| | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78638 | victor.stinner | 2010-03-04 00:20:25 +0100 (jeu., 04 mars 2010) | 3 lines Issue #7544: Preallocate thread memory before creating the thread to avoid a fatal error in low memory condition. ........
* | Merge in the new GIL.Antoine Pitrou2009-11-101-0/+1
|/
* Issue #3327: Don't overallocate in the modules_by_index list.Martin v. Löwis2008-11-171-1/+1
|