Commit Graph

11583 Commits

Author SHA1 Message Date
Victor Stinner 9cc3ebd7e0
bpo-40149: Implement traverse in _abc._abc_data (GH-19412)
Implement traverse and clear slots in _abc._abc_data type.
2020-04-07 18:36:04 +02:00
Victor Stinner 38aefc585f
bpo-40170: PyObject_GET_WEAKREFS_LISTPTR() becomes a function (GH-19377)
Convert the PyObject_GET_WEAKREFS_LISTPTR() macro to a function to
hide implementation details: the macro accessed directly to the
PyTypeObject.tp_weaklistoffset member.

Add _PyObject_GET_WEAKREFS_LISTPTR() static inline function to the
internal C API.
2020-04-06 14:07:02 +02:00
Batuhan Taşkaya 909f4a3009
bpo-40190: Add support for _SC_AIX_REALMEM in sysconf (GH-19380) 2020-04-05 02:40:49 +02:00
Hai Shi b709302f31
bpo-40077: Fix potential refleaks of _json: traverse memo (GH-19344)
Fix possible refleaks in _json module, memo of PyScannerObject
should be traversed.
2020-04-04 21:24:16 +02:00
Hai Shi 7a6f3bcc43
bpo-1635741: Fix refleak in _locale init error handling (GH-19307) 2020-04-02 20:00:47 +02:00
Hai Shi 45f7008a66
bpo-1635741: Port resource extension module to multiphase initialization (PEP 489) (GH-19252)
Fix also reference leaks on error.
2020-04-02 14:35:08 +02:00
Victor Stinner 65a796e527
bpo-40094: Add os.waitstatus_to_exitcode() (GH-19201)
Add os.waitstatus_to_exitcode() function to convert a wait status to an
exitcode.

Suggest waitstatus_to_exitcode() usage in the documentation when
appropriate.

Use waitstatus_to_exitcode() in:

* multiprocessing, os, subprocess and _bootsubprocess modules;
* test.support.wait_process();
* setup.py: run_command();
* and many tests.
2020-04-01 18:49:29 +02:00
Paulo Henrique Silva eacc074395
bpo-40071: Fix potential crash in _functoolsmodule.c (GH-19273)
Changes on 7dd549eb08 made _functools compatible with
PEP-489 and we could have multiple modules instances loaded.

But, right now there is no way to make `kwd_mark` global into
a per module instance variable. kwd_mark is used on lru_cache_new
which does not have a reference to a PyModule*, necessary to use
PyModule_GetState.

PEP-573 will solve this problem and will allow us to move the global
state to per-module data and properly clear the state when unloading
a module instance.

This change temporarily disable cleaning of kwd_mark to avoid NULL
pointer dereference if we clear kwd_mark and other module instances
still alive use it.
2020-04-01 17:06:21 +02:00
Dong-hee Na 5be8241392
bpo-1635741: Port math module to multiphase initialization (GH-19243) 2020-03-31 16:33:22 +02:00
Dong-hee Na 1cb763b880
bpo-1635741: Port _uuid module to multiphase initialization (GH-19242) 2020-03-31 14:43:47 +02:00
Steve Dower 63ba5cccf4
bpo-40121: Fixes audit event raised on creating a new socket (GH-19238) 2020-03-31 12:38:53 +01:00
Dong-hee Na 53e4c91725
bpo-40077: Convert _abc module to use PyType_FromSpec() (GH-19202)
Replace statically allocated types with heap allocated types:
use PyType_FromSpec().

Add a module state to store the _abc_data_type.
Add traverse, clear and free functions to the module.
2020-03-30 16:35:38 +02:00
Dong-hee Na 016bdd519d
bpo-40024: Update _elementtree to use PyModule_AddType() (GH-19205) 2020-03-29 16:12:11 +02:00
Dong-hee Na 33f15a16d4
bpo-40077: Convert _json module to use PyType_FromSpec() (GH-19177)
Replace statically allocated types with heap allocated types:
use PyType_FromSpec().

Add a module state to store the Scanner and Encoder types.
Add traverse, clear and free functions to the module.
2020-03-27 11:59:59 +01:00
Victor Stinner 728189884e
bpo-38644: Pass tstate explicitly in signalmodule.c (GH-19184)
PyOS_InterruptOccurred() now checks _Py_ThreadCanHandleSignals()
before checking if SIGINT is tripped.
2020-03-26 22:28:11 +01:00
Paulo Henrique Silva b09ae3ff43
bpo-40071: Fix refleak in _functools module (GH19172) 2020-03-26 13:47:45 +01:00
Victor Stinner 5c3cda0d1a
bpo-39947: Add PyThreadState_GetID() function (GH-19163)
Add PyThreadState_GetID() function: get the unique identifier of a
Python thread state.
2020-03-25 21:23:53 +01:00
Victor Stinner 0e427c6d15
bpo-39947: Add _PyThreadState_GetDict() function (GH-19160) 2020-03-25 21:22:55 +01:00
Victor Stinner 3072338642
bpo-39947: Use PyThreadState_GetFrame() (GH-19159)
_tracemalloc.c and _xxsubinterpretersmodule.c use
PyThreadState_GetFrame() and PyThreadState_GetInterpreter() to no
longer depend on the PyThreadState structure.
2020-03-25 19:52:02 +01:00
Victor Stinner 87d3b9db4a
bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157) 2020-03-25 19:27:36 +01:00
Andy Lester 7668a8bc93
Use calloc-based functions, not malloc. (GH-19152) 2020-03-24 23:26:44 -05:00
Paulo Henrique Silva 7dd549eb08
bpo-1635741: Port _functools module to multiphase initialization (PEP 489) (GH-19151) 2020-03-25 03:19:58 +01:00
Paulo Henrique Silva f3d5ac4772
bpo-1635741: Port operator module to multiphase initialization (PEP 489) (GH-19150) 2020-03-25 03:18:47 +01:00
Dong-hee Na 37fcbb65d4
bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)
Update _asyncio, _bz2, _csv, _curses, _datetime,
_io, _operator, _pickle, _queue, blake2,
multibytecodec and overlapped C extension modules
to use PyModule_AddType().
2020-03-24 23:08:51 +01:00
Victor Stinner 93460d097f
bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19140)
Co-authored-by: Hai Shi <shihai1992@gmail.com>
2020-03-24 18:31:19 +01:00
Victor Stinner f5c7cabb2b
bpo-40014: Fix os.getgrouplist() (GH-19126)
Fix os.getgrouplist(): if getgrouplist() function fails because the
group list is too small, retry with a larger group list.

On failure, the glibc implementation of getgrouplist() sets ngroups
to the total number of groups. For other implementations, double the
group list size.
2020-03-24 18:22:10 +01:00
Stefan Krah 472fc843ca
bpo-39689: Do not use native packing for format "?" with standard size (GH-18969) 2020-03-24 06:01:13 -07:00
Russell Owen 6000087fe9
closes bpo-40017: Add CLOCK_TAI constant to the time module. (GH-19096)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
2020-03-23 22:41:40 -05:00
Victor Stinner 188078c39d
Revert "bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084)" (#19128)
bpo-1635741, bpo-40050: This reverts
commit 8334f30a74.
2020-03-24 00:48:03 +01:00
AlphaHot 8dd1792c68
bpo-40036: Deleting duplicates in itertoolsmodule.c (GH-18958) 2020-03-23 13:14:39 -07:00
Victor Stinner 8ec7370c89
bpo-40014: Fix os.getgrouplist() on macOS (GH-19118)
On macOS, getgrouplist() returns a non-zero value without setting
errno if the group list is too small. Double the list size and call
it again in this case.
2020-03-23 20:00:57 +01:00
Paulo Henrique Silva bd409bb5b7
bpo-1635741: Port time module to multiphase initialization (PEP 489) (GH-19107) 2020-03-23 19:58:23 +01:00
Dong-hee Na 05e4a296ec
bpo-40024: Add PyModule_AddType() helper function (GH-19088) 2020-03-22 17:17:34 +01:00
Serhiy Storchaka b146568dfc
bpo-39652: Truncate the column name after '[' only if PARSE_COLNAMES is set. (GH-18942) 2020-03-21 15:53:28 +02:00
Victor Stinner d2a8e5b42c
bpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087)
COMPUTE_EVAL_BREAKER() now also checks if the Python thread state
belongs to the main interpreter. Don't break the evaluation loop if
there are pending signals but the Python thread state it belongs to a
subinterpeter.

* Add _Py_IsMainThread() function.
* Add _Py_ThreadCanHandleSignals() function.
2020-03-20 13:38:58 +01:00
Hai Shi 8334f30a74
bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084) 2020-03-20 09:16:45 +01:00
Hai Shi 13397ee47d
bpo-39824: Convert PyModule_GetState() to get_module_state() (GH-19076)
Automerge-Triggered-By: @vstinner
2020-03-19 10:11:33 -07:00
Dong-hee Na 77248a2889
bpo-1635741: Port _collections module to multiphase initialization (GH-19074) 2020-03-19 17:16:04 +01:00
Victor Stinner 50e6e99178
bpo-39984: Move pending calls to PyInterpreterState (GH-19066)
If Py_AddPendingCall() is called in a subinterpreter, the function is
now scheduled to be called from the subinterpreter, rather than being
called from the main interpreter.

Each subinterpreter now has its own list of scheduled calls.

* Move pending and eval_breaker fields from _PyRuntimeState.ceval
  to PyInterpreterState.ceval.
* new_interpreter() now calls _PyEval_InitThreads() to create
  pending calls lock.
* Fix Py_AddPendingCall() for subinterpreters. It now calls
  _PyThreadState_GET() which works in a subinterpreter if the
  caller holds the GIL, and only falls back on
  PyGILState_GetThisThreadState() if _PyThreadState_GET()
  returns NULL.
2020-03-19 02:41:21 +01:00
Pablo Galindo 3cde88439d
Remove unused variable to fix compiler warning in _threadmodule.c (GH-19064) 2020-03-18 23:33:57 +00:00
Victor Stinner 8849e5962b
bpo-39984: trip_signal() uses PyGILState_GetThisThreadState() (GH-19061)
bpo-37127, bpo-39984:

* trip_signal() and Py_AddPendingCall() now get the current Python
  thread state using PyGILState_GetThisThreadState() rather than
  _PyRuntimeState_GetThreadState() to be able to get it even if the
  GIL is released.
* _PyEval_SignalReceived() now expects tstate rather than ceval.
* Remove ceval parameter of _PyEval_AddPendingCall(): ceval is now
  get from tstate parameter.
2020-03-18 19:28:53 +01:00
Dong-hee Na 4657a8a0d0
bpo-1635741: Port _heapq module to multiphase initialization (GH19057) 2020-03-18 15:29:34 +01:00
Victor Stinner 23ef89db7a
bpo-39984: _PyThreadState_DeleteCurrent() takes tstate (GH-19051)
* _PyThreadState_DeleteCurrent() now takes tstate rather than
  runtime.
* Add ensure_tstate_not_null() helper to pystate.c.
* Add _PyEval_ReleaseLock() function.
* _PyThreadState_DeleteCurrent() now calls
  _PyEval_ReleaseLock(tstate) and frees PyThreadState memory after
  this call, not before.
* PyGILState_Release(): rename "tcur" variable to "tstate".
2020-03-18 02:26:04 +01:00
Dong-hee Na 514c469719
bpo-1635741: Port itertools module to multiphase initialization (GH-19044) 2020-03-17 18:46:24 +01:00
Victor Stinner 5b1ef200d3
bpo-39824: module_traverse() don't call m_traverse if md_state=NULL (GH-18738)
Extension modules: m_traverse, m_clear and m_free functions of
PyModuleDef are no longer called if the module state was requested
but is not allocated yet. This is the case immediately after the
module is created and before the module is executed (Py_mod_exec
function). More precisely, these functions are not called if m_size is
greater than 0 and the module state (as returned by
PyModule_GetState()) is NULL.

Extension modules without module state (m_size <= 0) are not affected.

Co-Authored-By: Petr Viktorin <encukou@gmail.com>
2020-03-17 18:09:46 +01:00
Andy Lester 982307b9cc
bpo-39943: Remove unused self from find_nfc_index() (GH-18973) 2020-03-17 17:38:12 +01:00
Hai Shi 2037502613
bpo-1635741: Port _ctypes_test extension to multiphase initialization (PEP 489) (GH-19012) 2020-03-17 02:15:23 +01:00
Hai Shi 5f104d56fa
bpo-39968: Fix a typo error in get_readline_state() (GH-19028) 2020-03-16 18:16:32 +01:00
Dong-hee Na 356c878fbf
bpo-1635741: Port _statistics module to multiphase initialization (GH-19015) 2020-03-16 16:10:21 +01:00
Hai Shi f707d94af6
bpo-39968: Convert extension modules' macros of get_module_state() to inline functions (GH-19017) 2020-03-16 14:15:01 +01:00