Commit Graph

11605 Commits

Author SHA1 Message Date
Victor Stinner 4a3fe08353
bpo-40268: Include explicitly pycore_interp.h (GH-19505)
pycore_pystate.h no longer includes pycore_interp.h:
it's now included explicitly in files accessing PyInterpreterState.
2020-04-14 14:26:24 +02:00
Ethan Smith cecf049673
bpo-39481: Make functools.cached_property, partial, partialmethod generic (#19427) 2020-04-13 21:53:04 -07:00
Benjamin Peterson 584a3cfda4
closes bpo-40266, closes bpo-39953: Use numeric lib code if compiling against old OpenSSL. (GH-19506) 2020-04-13 22:11:40 -05:00
Victor Stinner 0135598d72
bpo-40241: Add pycore_gc.h header file (GH-19494)
Move the PyGC_Head structure and the following private macros to the
internal C API:

* _PyGCHead_FINALIZED()
* _PyGCHead_NEXT()
* _PyGCHead_PREV()
* _PyGCHead_SET_FINALIZED()
* _PyGCHead_SET_NEXT()
* _PyGCHead_SET_PREV()
* _PyGC_FINALIZED()
* _PyGC_PREV_MASK
* _PyGC_PREV_MASK_COLLECTING
* _PyGC_PREV_MASK_FINALIZED
* _PyGC_PREV_SHIFT
* _PyGC_SET_FINALIZED()
* _PyObject_GC_IS_TRACKED()
* _PyObject_GC_MAY_BE_TRACKED()
* _Py_AS_GC(o)

Keep the private _PyGC_FINALIZED() macro in the public C API for
backward compatibility with Python 3.8: make it an alias to the new
PyObject_GC_IsFinalized() function.

Move the SIZEOF_PYGC_HEAD constant from _testcapi module to
_testinternalcapi module.
2020-04-13 11:38:42 +02:00
Victor Stinner da7933ecc3
bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)
Don't access PyInterpreterState.config member directly anymore, but
use new functions:

* _PyInterpreterState_GetConfig()
* _PyInterpreterState_SetConfig()
* _Py_GetConfig()
2020-04-13 03:04:28 +02:00
Victor Stinner 14d5331eb5
bpo-40234: Revert "bpo-37266: Daemon threads are now denied in subinterpreters (GH-14049)" (GH-19456)
This reverts commit 066e5b1a91.
2020-04-12 23:45:09 +02:00
Benjamin Peterson 909b87d2bb
closes bpo-39953: Generate ifdefs around library code definitions. (GH-19490) 2020-04-12 13:59:31 -05:00
Oren Milman 402e1cdb13
bpo-31758: Prevent crashes when using an uninitialized _elementtree.XMLParser object (GH-3997) 2020-04-12 16:36:41 +02:00
Serhiy Storchaka 8f87eefe7f
bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472) 2020-04-12 14:58:27 +03:00
Benjamin Peterson 3e0dd3730b
closes bpo-39953: Update OpenSSL error codes table. (GH-19082)
I updated the error codes using the OpenSSL 1.1.1f source tree.
2020-04-11 15:36:12 -05:00
Serhiy Storchaka cd8295ff75
bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. (GH-19345) 2020-04-11 10:48:40 +03:00
Pablo Galindo f13072b8a8
bpo-40241: Add PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public C-API (GH-19461)
Add the functions PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public API to allow to query if Python objects are being currently tracked or have been already finalized by the garbage collector respectively.
2020-04-11 01:21:54 +01:00
Batuhan Taşkaya 0361556537
bpo-39481: PEP 585 for a variety of modules (GH-19423)
- concurrent.futures
- ctypes
- http.cookies
- multiprocessing
- queue
- tempfile
- unittest.case
- urllib.parse
2020-04-10 07:46:36 -07:00
Ethan Smith 7c4185d62d
bpo-39481: PEP 585 for enumerate, AsyncGeneratorType, mmap (GH-19421) 2020-04-09 21:25:53 -07:00
Ethan Smith a8403d057d
Generic itertools.chain (GH-19417) 2020-04-09 20:28:08 -07:00
Hai Shi dcb04d9c6d
bpo-40077: Remove redundant cast in json module (GH-19438) 2020-04-10 00:10:29 +09:00
Zackery Spytz 97e0de04b8
bpo-25780: Expose CAN_RAW_JOIN_FILTERS in the socket module (GH-19190)
Co-Authored-By: Stefan Tatschner <stefan@rumpelsepp.org>
2020-04-09 13:03:49 +01:00
Victor Stinner b54a99d643
bpo-40082: trip_signal() uses the main interpreter (GH-19441)
Fix the signal handler: it now always uses the main interpreter,
rather than trying to get the current Python thread state.

The following function now accepts an interpreter, instead of a
Python thread state:

* _PyEval_SignalReceived()
* _Py_ThreadCanHandleSignals()
* _PyEval_AddPendingCall()
* COMPUTE_EVAL_BREAKER()
* SET_GIL_DROP_REQUEST(), RESET_GIL_DROP_REQUEST()
* SIGNAL_PENDING_CALLS(), UNSIGNAL_PENDING_CALLS()
* SIGNAL_PENDING_SIGNALS(), UNSIGNAL_PENDING_SIGNALS()
* SIGNAL_ASYNC_EXC(), UNSIGNAL_ASYNC_EXC()

Py_AddPendingCall() now uses the main interpreter if it fails to the
current Python thread state.

Convert _PyThreadState_GET() and PyInterpreterState_GET_UNSAFE()
macros to static inline functions.
2020-04-08 23:35:05 +02:00
Victor Stinner 9205520d8c
bpo-40170: PyObject_NEW() becomes an alias to PyObject_New() (GH-19379)
The PyObject_NEW() macro becomes an alias to the PyObject_New()
macro, and the PyObject_NEW_VAR() macro becomes an alias to the
PyObject_NewVar() macro, to hide implementation details. They no
longer access directly the PyTypeObject.tp_basicsize member.

Exclude _PyObject_SIZE() and _PyObject_VAR_SIZE() macros from
the limited C API.

Replace PyObject_NEW() with PyObject_New() and replace
PyObject_NEW_VAR() with PyObject_NewVar().
2020-04-08 00:38:15 +02:00
Batuhan Taşkaya f9dd51e7db
bpo-39481: Make os.DirEntry generic (GH-19415) 2020-04-07 14:37:19 -07:00
Victor Stinner 87255be696
bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)
Add a private _at_fork_reinit() method to _thread.Lock,
_thread.RLock, threading.RLock and threading.Condition classes:
reinitialize the lock after fork in the child process; reset the lock
to the unlocked state.

Rename also the private _reset_internal_locks() method of
threading.Event to _at_fork_reinit().

* Add _PyThread_at_fork_reinit() private function. It is excluded
  from the limited C API.
* threading.Thread._reset_internal_locks() now calls
  _at_fork_reinit() on self._tstate_lock rather than creating a new
  Python lock object.
2020-04-07 23:11:49 +02:00
Guido van Rossum 48b069a003
bpo-39481: Implementation for PEP 585 (#18239)
This implements things like `list[int]`,
which returns an object of type `types.GenericAlias`.
This object mostly acts as a proxy for `list`,
but has attributes `__origin__` and `__args__`
that allow recovering the parts (with values `list` and `(int,)`.

There is also an approximate notion of type variables;
e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`.
Type variables are objects of type `typing.TypeVar`.
2020-04-07 09:50:06 -07:00
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