]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
5 years agobpo-39812: Remove daemon threads in concurrent.futures (GH-19149)
Kyle Stanley [Fri, 27 Mar 2020 19:31:22 +0000 (15:31 -0400)] 
bpo-39812: Remove daemon threads in concurrent.futures (GH-19149)

Remove daemon threads from :mod:`concurrent.futures` by adding
an internal `threading._register_atexit()`, which calls registered functions
prior to joining all non-daemon threads. This allows for compatibility
with subinterpreters, which don't support daemon threads.

5 years agobpo-40045: Make "dunder" method documentation easier to locate (#19153)
Javad Mokhtari [Fri, 27 Mar 2020 19:02:51 +0000 (23:32 +0430)] 
bpo-40045: Make "dunder" method documentation easier to locate (#19153)

* issue 40045

* Update lexical_analysis.rst

Make "dunder" method documentation easier(GH-19153)

Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
5 years agobpo-40089: Fix threading._after_fork() (GH-19191)
Victor Stinner [Fri, 27 Mar 2020 16:50:42 +0000 (17:50 +0100)] 
bpo-40089: Fix threading._after_fork() (GH-19191)

If fork was not called by a thread spawned by threading.Thread,
threading._after_fork() now creates a _MainThread instance for
_main_thread, instead of a _DummyThread instance.

5 years agobpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)
Ammar Askar [Fri, 27 Mar 2020 16:37:43 +0000 (09:37 -0700)] 
bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)

5 years agobpo-38644: Use _PySys_Audit(): pass tstate explicitly (GH-19183)
Victor Stinner [Fri, 27 Mar 2020 14:11:45 +0000 (15:11 +0100)] 
bpo-38644: Use _PySys_Audit(): pass tstate explicitly (GH-19183)

Add the dependency to tstate more explicit.

5 years agobpo-40077: Convert _json module to use PyType_FromSpec() (GH-19177)
Dong-hee Na [Fri, 27 Mar 2020 10:59:59 +0000 (19:59 +0900)] 
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.

5 years agobpo-38644: Make tstate more explicit inside pystate.c (GH-19182)
Victor Stinner [Thu, 26 Mar 2020 21:46:14 +0000 (22:46 +0100)] 
bpo-38644: Make tstate more explicit inside pystate.c (GH-19182)

Fix PyInterpreterState_New(): Don't call PyErr_SetString() when there
is no current Python thread state (if tstate is NULL).

5 years agobpo-38644: Pass tstate explicitly in signalmodule.c (GH-19184)
Victor Stinner [Thu, 26 Mar 2020 21:28:11 +0000 (22:28 +0100)] 
bpo-38644: Pass tstate explicitly in signalmodule.c (GH-19184)

PyOS_InterruptOccurred() now checks _Py_ThreadCanHandleSignals()
before checking if SIGINT is tripped.

5 years agobpo-38644: Add _PySys_Audit() which takes tstate (GH-19180)
Victor Stinner [Thu, 26 Mar 2020 17:57:32 +0000 (18:57 +0100)] 
bpo-38644: Add _PySys_Audit() which takes tstate (GH-19180)

Add _PySys_Audit() function to the internal C API: similar to
PySys_Audit(), but requires a mandatory tstate parameter.

Cleanup sys_audit_tstate() code: remove code path for NULL tstate,
since the function exits at entry if tstate is NULL. Remove also code
path for NULL tstate->interp: should_audit() now ensures that it is
not NULL (even if tstate->interp cannot be NULL in practice).

PySys_AddAuditHook() now checks if tstate is not NULL to decide if
tstate can be used or not, and tstate is set to NULL if the runtime
is not initialized yet.

Use _PySys_Audit() in sysmodule.c.

5 years agobpo-1812: Fix newline conversion when doctest.testfile loads from a package whose...
Peter Donis [Thu, 26 Mar 2020 15:53:16 +0000 (11:53 -0400)] 
bpo-1812: Fix newline conversion when doctest.testfile loads from a package whose loader has a get_data method (GH-17385)

This pull request fixes the newline conversion bug originally reported in bpo-1812. When that issue was originally submitted, the open builtin did not default to universal newline mode; now it does, which makes the issue fix simpler, since the only code path that needs to be changed is the one in doctest._load_testfile where the file is loaded from a package whose loader has a get_data method.

5 years agobpo-39879: Update datamodel docs to include dict ordering (GH-19006)
Lahfa Samy [Thu, 26 Mar 2020 14:54:04 +0000 (15:54 +0100)] 
bpo-39879: Update datamodel docs to include dict ordering (GH-19006)

Co-authored-by: furkanonder <furkantahaonder@gmail.com>
5 years agobpo-40069: Clear out .lst files on make clean (GH-19169)
Batuhan Taşkaya [Thu, 26 Mar 2020 13:10:04 +0000 (16:10 +0300)] 
bpo-40069: Clear out .lst files on make clean (GH-19169)

Files created on AIX by xlc (C compiler).

5 years agobpo-40071: Fix refleak in _functools module (GH19172)
Paulo Henrique Silva [Thu, 26 Mar 2020 12:47:45 +0000 (09:47 -0300)] 
bpo-40071: Fix refleak in _functools module (GH19172)

5 years agobpo-38410: Properly handle PySys_Audit() failures (GH-16657)
Zackery Spytz [Thu, 26 Mar 2020 12:11:13 +0000 (06:11 -0600)] 
bpo-38410: Properly handle PySys_Audit() failures (GH-16657)

5 years agobpo-39943: Properly const the pointers in dictkeys_get_index (GH-19170)
Andy Lester [Thu, 26 Mar 2020 04:13:01 +0000 (23:13 -0500)] 
bpo-39943: Properly const the pointers in dictkeys_get_index (GH-19170)

5 years agobpo-40067: Improve error messages for multiple star expressions in assignments (GH...
Furkan Önder [Thu, 26 Mar 2020 01:54:31 +0000 (04:54 +0300)] 
bpo-40067: Improve error messages for multiple star expressions in assignments (GH-19168)

Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com>
Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-39947: Add PyThreadState_GetID() function (GH-19163)
Victor Stinner [Wed, 25 Mar 2020 20:23:53 +0000 (21:23 +0100)] 
bpo-39947: Add PyThreadState_GetID() function (GH-19163)

Add PyThreadState_GetID() function: get the unique identifier of a
Python thread state.

5 years agobpo-39947: Add _PyThreadState_GetDict() function (GH-19160)
Victor Stinner [Wed, 25 Mar 2020 20:22:55 +0000 (21:22 +0100)] 
bpo-39947: Add _PyThreadState_GetDict() function (GH-19160)

5 years agobpo-19698: Document when importlib.machinery.FrozenImporter gained spec-related metho...
Brett Cannon [Wed, 25 Mar 2020 18:57:47 +0000 (11:57 -0700)] 
bpo-19698: Document when importlib.machinery.FrozenImporter gained spec-related methods (GH-19158)

5 years agobpo-39947: Use PyThreadState_GetFrame() (GH-19159)
Victor Stinner [Wed, 25 Mar 2020 18:52:02 +0000 (19:52 +0100)] 
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.

5 years agobpo-40016: re docstring: Clarify relationship of inline and argument flags (#19078)
Ram Rachum [Wed, 25 Mar 2020 18:44:47 +0000 (20:44 +0200)] 
bpo-40016: re docstring: Clarify relationship of inline and argument flags (#19078)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
5 years agobpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)
Victor Stinner [Wed, 25 Mar 2020 18:27:36 +0000 (19:27 +0100)] 
bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)

5 years agobpo-40050: Rephrase NEWS entry (GH-19148)
Victor Stinner [Wed, 25 Mar 2020 17:31:55 +0000 (18:31 +0100)] 
bpo-40050: Rephrase NEWS entry (GH-19148)

5 years agoUse calloc-based functions, not malloc. (GH-19152)
Andy Lester [Wed, 25 Mar 2020 04:26:44 +0000 (23:26 -0500)] 
Use calloc-based functions, not malloc. (GH-19152)

5 years agobpo-1635741: Port _functools module to multiphase initialization (PEP 489) (GH-19151)
Paulo Henrique Silva [Wed, 25 Mar 2020 02:19:58 +0000 (23:19 -0300)] 
bpo-1635741: Port _functools module to multiphase initialization (PEP 489) (GH-19151)

5 years agobpo-1635741: Port operator module to multiphase initialization (PEP 489) (GH-19150)
Paulo Henrique Silva [Wed, 25 Mar 2020 02:18:47 +0000 (23:18 -0300)] 
bpo-1635741: Port operator module to multiphase initialization (PEP 489) (GH-19150)

5 years agobpo-36144: Add union operators to WeakValueDictionary584 (#19127)
Curtis Bucher [Wed, 25 Mar 2020 01:51:29 +0000 (18:51 -0700)] 
bpo-36144: Add union operators to WeakValueDictionary584 (#19127)

5 years agobpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)
Dong-hee Na [Tue, 24 Mar 2020 22:08:51 +0000 (07:08 +0900)] 
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().

5 years agobpo-40029 mark test_importlib.test_zip as requiring zlib (#19105)
Roman Yurchak [Tue, 24 Mar 2020 19:02:53 +0000 (20:02 +0100)] 
bpo-40029 mark test_importlib.test_zip as requiring zlib (#19105)

* bpo-40029 mark test_importlib.test_zip as requiring zlib

* Decorate TestZip / TestEgg classes as requiring zlib

5 years agobpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489...
Victor Stinner [Tue, 24 Mar 2020 17:31:19 +0000 (18:31 +0100)] 
bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19140)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
5 years agobpo-40014: Fix os.getgrouplist() (GH-19126)
Victor Stinner [Tue, 24 Mar 2020 17:22:10 +0000 (18:22 +0100)] 
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.

5 years agobpo-40013: Clarify documentation of restval in csv.DictReader (GH-19099)
Juhana Jauhiainen [Tue, 24 Mar 2020 17:11:42 +0000 (19:11 +0200)] 
bpo-40013: Clarify documentation of restval in csv.DictReader (GH-19099)

5 years agobpo-40050: Fix importlib._bootstrap_external (GH-19135)
Victor Stinner [Tue, 24 Mar 2020 17:03:34 +0000 (18:03 +0100)] 
bpo-40050: Fix importlib._bootstrap_external (GH-19135)

Remove two unused imports: _thread and _weakref. Avoid creating a new
winreg builtin module if it's already available in sys.modules.

The winreg module is now stored as "winreg" rather than "_winreg".

5 years agoClarify a guarantee of the logging module. (GH-19132)
Gregory P. Smith [Tue, 24 Mar 2020 16:48:32 +0000 (09:48 -0700)] 
Clarify a guarantee of the logging module. (GH-19132)

When no additional arguments are passed to logging.debug() and related
methods, no % operation is performed on the passed in message.

5 years agobpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120)
Victor Stinner [Tue, 24 Mar 2020 15:32:26 +0000 (16:32 +0100)] 
bpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120)

PyThreadState.frame is a borrowed reference, not a strong reference:
PyThreadState_Clear() must not call Py_CLEAR(tstate->frame).

Remove test_threading.test_warnings_at_exit(): we cannot warranty
that the Python thread state of daemon threads is cleared in a
reliable way during Python shutdown.

5 years agobpo-39689: Do not use native packing for format "?" with standard size (GH-18969)
Stefan Krah [Tue, 24 Mar 2020 13:01:13 +0000 (14:01 +0100)] 
bpo-39689: Do not use native packing for format "?" with standard size (GH-18969)

5 years agocloses bpo-40017: Add CLOCK_TAI constant to the time module. (GH-19096)
Russell Owen [Tue, 24 Mar 2020 03:41:40 +0000 (20:41 -0700)] 
closes bpo-40017: Add CLOCK_TAI constant to the time module. (GH-19096)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
5 years agoUpdated documentation for FOR_ITER (GH-19113)
laike9m [Tue, 24 Mar 2020 01:03:06 +0000 (18:03 -0700)] 
Updated documentation for FOR_ITER (GH-19113)

Added a comma to make the sentence less confusing.

5 years agoRevert "bpo-1635741: Port _weakref extension module to multiphase initialization...
Victor Stinner [Mon, 23 Mar 2020 23:48:03 +0000 (00:48 +0100)] 
Revert "bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084)" (#19128)

bpo-1635741, bpo-40050: This reverts
commit 8334f30a74abcf7e469b901afc307887aa85a888.

5 years agoPost 3.9.0a5
Łukasz Langa [Mon, 23 Mar 2020 22:00:48 +0000 (23:00 +0100)] 
Post 3.9.0a5

5 years agoMerge tag 'v3.9.0a5'
Łukasz Langa [Mon, 23 Mar 2020 22:00:18 +0000 (23:00 +0100)] 
Merge tag 'v3.9.0a5'

Python 3.9.0a5

5 years agobpo-36144: Add union operators to WeakKeyDictionary (#19106)
Curtis Bucher [Mon, 23 Mar 2020 20:49:46 +0000 (13:49 -0700)] 
bpo-36144: Add union operators to WeakKeyDictionary (#19106)

5 years agobpo-40036: Deleting duplicates in itertoolsmodule.c (GH-18958)
AlphaHot [Mon, 23 Mar 2020 20:14:39 +0000 (01:14 +0500)] 
bpo-40036: Deleting duplicates in itertoolsmodule.c (GH-18958)

5 years agobpo-36144: Add PEP 584 operators to collections.ChainMap (#18832)
Curtis Bucher [Mon, 23 Mar 2020 19:02:05 +0000 (12:02 -0700)] 
bpo-36144: Add PEP 584 operators to collections.ChainMap (#18832)

* Update ChainMap to include | and |=

Created __ior__, __or__ and __ror__ methods in ChainMap class.

* Update ACKS

* Update docs

* Update test_collections.py to include test_issue584().

Added testing for | and |= operators for ChainMap objects.

* Update test_union_operators

Renamed test_union operators, fixed errors and style problems raised by brandtbucher.

* Update test_union_operators in TestChainMap

Added testing for union operator between ChainMap and iterable of key-value pairs.

* Update test_union operators in test_collections.py

Gave more descriptive variable names and eliminated unnecessary tmp variable.

* Update test_union_operators in test_collections.py

Added cm3

* Check .maps rather than Chainmap equality.

* Add news entry

* Update Lib/test/test_collections.py

Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>
* Removed whitespace

* Added Guido's changes

* Fixed Docs

* Removed whitespace

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
5 years agobpo-40014: Fix os.getgrouplist() on macOS (GH-19118)
Victor Stinner [Mon, 23 Mar 2020 19:00:57 +0000 (20:00 +0100)] 
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.

5 years agobpo-1635741: Port time module to multiphase initialization (PEP 489) (GH-19107)
Paulo Henrique Silva [Mon, 23 Mar 2020 18:58:23 +0000 (15:58 -0300)] 
bpo-1635741: Port time module to multiphase initialization (PEP 489) (GH-19107)

5 years agoPython 3.9.0a5 v3.9.0a5
Łukasz Langa [Mon, 23 Mar 2020 16:19:13 +0000 (17:19 +0100)] 
Python 3.9.0a5

5 years agobpo-39830: Add zipfile.Path to __all__ (GH-19115)
Zackery Spytz [Mon, 23 Mar 2020 13:29:36 +0000 (07:29 -0600)] 
bpo-39830: Add zipfile.Path to __all__ (GH-19115)

5 years agobpo-39999: Improve compatibility of the ast module. (GH-19056)
Serhiy Storchaka [Sun, 22 Mar 2020 18:33:34 +0000 (20:33 +0200)] 
bpo-39999: Improve compatibility of the ast module. (GH-19056)

* Re-add removed classes Suite, slice, Param, AugLoad and AugStore.
* Add docstrings for dummy classes.
* Add docstrings for attribute aliases.
* Set __module__ to "ast" instead of "_ast".

5 years agobpo-22490: Remove __PYVENV_LAUNCHER__ from environment during launch (GH-9516)
Ronald Oussoren [Sun, 22 Mar 2020 18:31:46 +0000 (19:31 +0100)] 
bpo-22490: Remove __PYVENV_LAUNCHER__ from environment during launch (GH-9516)

* bpo-22490: Remove "__PYVENV_LAUNCHER__" from the shell environment on macOS

This changeset removes the environment varialbe "__PYVENV_LAUNCHER__"
during interpreter launch as it is only needed to communicate between
the stub executable in framework installs and the actual interpreter.

Leaving the environment variable present may lead to misbehaviour when
launching other scripts.

* Actually commit the changes for issue 22490...

* Correct typo

Co-Authored-By: Nicola Soranzo <nicola.soranzo@gmail.com>
* Run make patchcheck

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
5 years agobpo-40024: Add PyModule_AddType() helper function (GH-19088)
Dong-hee Na [Sun, 22 Mar 2020 16:17:34 +0000 (01:17 +0900)] 
bpo-40024: Add PyModule_AddType() helper function (GH-19088)

5 years agobpo-36543: Remove the xml.etree.cElementTree module. (GH-19108)
Serhiy Storchaka [Sun, 22 Mar 2020 12:31:38 +0000 (14:31 +0200)] 
bpo-36543: Remove the xml.etree.cElementTree module. (GH-19108)

5 years agobpo-39652: Truncate the column name after '[' only if PARSE_COLNAMES is set. (GH...
Serhiy Storchaka [Sat, 21 Mar 2020 13:53:28 +0000 (15:53 +0200)] 
bpo-39652: Truncate the column name after '[' only if PARSE_COLNAMES is set. (GH-18942)

5 years agobpo-24916: Remove an outdated comment. (GH-19101)
Serhiy Storchaka [Sat, 21 Mar 2020 13:45:30 +0000 (15:45 +0200)] 
bpo-24916: Remove an outdated comment. (GH-19101)

5 years agobpo-39946: Remove _PyThreadState_GetFrame (GH-19094)
Victor Stinner [Fri, 20 Mar 2020 16:46:56 +0000 (17:46 +0100)] 
bpo-39946: Remove _PyThreadState_GetFrame (GH-19094)

Remove _PyRuntime.getframe hook and remove _PyThreadState_GetFrame
macro which was an alias to _PyRuntime.getframe. They were only
exposed by the internal C API. Remove also PyThreadFrameGetter type.

5 years agobpo-39947: Add PyThreadState_GetFrame() function (GH-19092)
Victor Stinner [Fri, 20 Mar 2020 14:51:45 +0000 (15:51 +0100)] 
bpo-39947: Add PyThreadState_GetFrame() function (GH-19092)

Add PyThreadState_GetFrame() function: get the current frame
of a Python thread state.

5 years agobpo-40010: Optimize pending calls in multithreaded applications (GH-19091)
Victor Stinner [Fri, 20 Mar 2020 13:50:35 +0000 (14:50 +0100)] 
bpo-40010: Optimize pending calls in multithreaded applications (GH-19091)

If a thread different than the main thread schedules a pending call
(Py_AddPendingCall()), the bytecode evaluation loop is no longer
interrupted at each bytecode instruction to check for pending calls
which cannot be executed. Only the main thread can execute pending
calls.

Previously, the bytecode evaluation loop was interrupted at each
instruction until the main thread executes pending calls.

* Add _Py_ThreadCanHandlePendingCalls() function.
* SIGNAL_PENDING_CALLS() now only sets eval_breaker to 1 if the
  current thread can execute pending calls. Only the main thread can
  execute pending calls.

5 years agobpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087)
Victor Stinner [Fri, 20 Mar 2020 12:38:58 +0000 (13:38 +0100)] 
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.

5 years agobpo-40010: Pass tstate to ceval GIL functions (GH-19077)
Victor Stinner [Fri, 20 Mar 2020 08:29:08 +0000 (09:29 +0100)] 
bpo-40010: Pass tstate to ceval GIL functions (GH-19077)

* Add eval_frame_handle_pending() helper function: cold code path.
* Fix PyEval_ReleaseLock(): don't dereference tstate if it's NULL.

5 years agobpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489...
Hai Shi [Fri, 20 Mar 2020 08:16:45 +0000 (16:16 +0800)] 
bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084)

5 years agobpo-39797 Changes to socketserver.BaseServer's shutdown() method. (GH-18929)
amaajemyfren [Fri, 20 Mar 2020 08:03:18 +0000 (11:03 +0300)] 
bpo-39797 Changes to socketserver.BaseServer's shutdown() method. (GH-18929)

Automerge-Triggered-By: @ned-deily
5 years agobpo-40019: Skip test_gdb if Python was optimized (GH-19081)
Victor Stinner [Fri, 20 Mar 2020 07:23:26 +0000 (08:23 +0100)] 
bpo-40019: Skip test_gdb if Python was optimized (GH-19081)

test_gdb now skips tests if it detects that gdb failed to read debug
information because the Python binary is optimized.

5 years agobpo-39877: 4th take_gil() fix for daemon threads (GH-19080)
Victor Stinner [Thu, 19 Mar 2020 18:48:25 +0000 (19:48 +0100)] 
bpo-39877: 4th take_gil() fix for daemon threads (GH-19080)

bpo-39877, bpo-40010: Add a third tstate_must_exit() check in
take_gil() to prevent using tstate which has been freed.

5 years agoFix "versionchanged" for pow named arguments (GH-19042)
Mark Dickinson [Thu, 19 Mar 2020 18:12:59 +0000 (18:12 +0000)] 
Fix "versionchanged" for pow named arguments (GH-19042)

The ability to use named arguments in "pow" was introduced in Python 3.8, not Python 3.9. See https://bugs.python.org/issue38237

5 years agobpo-39824: Convert PyModule_GetState() to get_module_state() (GH-19076)
Hai Shi [Thu, 19 Mar 2020 17:11:33 +0000 (01:11 +0800)] 
bpo-39824: Convert PyModule_GetState() to get_module_state() (GH-19076)

Automerge-Triggered-By: @vstinner
5 years agobpo-40010: Optimize signal handling in multithreaded applications (GH-19067)
Victor Stinner [Thu, 19 Mar 2020 16:40:12 +0000 (17:40 +0100)] 
bpo-40010: Optimize signal handling in multithreaded applications (GH-19067)

If a thread different than the main thread gets a signal, the
bytecode evaluation loop is no longer interrupted at each bytecode
instruction to check for pending signals which cannot be handled.
Only the main thread of the main interpreter can handle signals.

Previously, the bytecode evaluation loop was interrupted at each
instruction until the main thread handles signals.

Changes:

* COMPUTE_EVAL_BREAKER() and SIGNAL_PENDING_SIGNALS() no longer set
  eval_breaker to 1 if the current thread cannot handle signals.
* take_gil() now always recomputes eval_breaker.

5 years agobpo-1635741: Port _collections module to multiphase initialization (GH-19074)
Dong-hee Na [Thu, 19 Mar 2020 16:16:04 +0000 (01:16 +0900)] 
bpo-1635741: Port _collections module to multiphase initialization (GH-19074)

5 years agobpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)
Batuhan Taşkaya [Thu, 19 Mar 2020 11:35:44 +0000 (14:35 +0300)] 
bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-40000: Improve error messages when validating invalid ast.Constant nodes (GH...
Batuhan Taşkaya [Thu, 19 Mar 2020 11:32:28 +0000 (14:32 +0300)] 
bpo-40000: Improve error messages when validating invalid ast.Constant nodes (GH-19055)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-39984: Move pending calls to PyInterpreterState (GH-19066)
Victor Stinner [Thu, 19 Mar 2020 01:41:21 +0000 (02:41 +0100)] 
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.

5 years agoRemove unused variable to fix compiler warning in _threadmodule.c (GH-19064)
Pablo Galindo [Wed, 18 Mar 2020 23:33:57 +0000 (23:33 +0000)] 
Remove unused variable to fix compiler warning in _threadmodule.c (GH-19064)

5 years agobpo-39220: Do not optimise annotation if 'from __future__ import annotations' is...
Pablo Galindo [Wed, 18 Mar 2020 23:02:09 +0000 (23:02 +0000)] 
bpo-39220: Do not optimise annotation if 'from __future__ import annotations' is used (GH-17866)

Do not apply AST-based optimizations if 'from __future__ import annotations' is used in order to
prevent information lost in the final version of the annotations.

5 years agobpo-39984: trip_signal() uses PyGILState_GetThisThreadState() (GH-19061)
Victor Stinner [Wed, 18 Mar 2020 18:28:53 +0000 (19:28 +0100)] 
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.

5 years agobpo-37207: Use PEP 590 vectorcall to speed up frozenset() (GH-19053)
Dong-hee Na [Wed, 18 Mar 2020 17:30:50 +0000 (02:30 +0900)] 
bpo-37207: Use PEP 590 vectorcall to speed up frozenset() (GH-19053)

5 years agobpo-27807: Skip test_site.test_startup_imports() if pth file (GH-19060)
Victor Stinner [Wed, 18 Mar 2020 17:27:32 +0000 (18:27 +0100)] 
bpo-27807: Skip test_site.test_startup_imports() if pth file (GH-19060)

test_site.test_startup_imports() is now skipped if a path of sys.path
contains a .pth file.

Sort test_site imports.

5 years agobpo-1635741: Port _heapq module to multiphase initialization (GH19057)
Dong-hee Na [Wed, 18 Mar 2020 14:29:34 +0000 (23:29 +0900)] 
bpo-1635741: Port _heapq module to multiphase initialization (GH19057)

5 years agobpo-39984: Pass tstate to _PyEval_SignalAsyncExc() (GH-19049)
Victor Stinner [Wed, 18 Mar 2020 08:26:25 +0000 (09:26 +0100)] 
bpo-39984: Pass tstate to _PyEval_SignalAsyncExc() (GH-19049)

_PyEval_SignalAsyncExc() and _PyEval_FiniThreads() now expect tstate,
instead of ceval.

5 years agobpo-39957: Change Signature.parameters to OrderedDict (GH-18988)
Jens Reidel [Wed, 18 Mar 2020 02:22:46 +0000 (03:22 +0100)] 
bpo-39957: Change Signature.parameters to OrderedDict (GH-18988)

5 years agobpo-39877: Fix take_gil() for daemon threads (GH-19054)
Victor Stinner [Wed, 18 Mar 2020 02:04:33 +0000 (03:04 +0100)] 
bpo-39877: Fix take_gil() for daemon threads (GH-19054)

bpo-39877, bpo-39984: If the thread must exit, don't access tstate to
prevent a potential crash: tstate memory has been freed.

5 years agobpo-39984: _PyThreadState_DeleteCurrent() takes tstate (GH-19051)
Victor Stinner [Wed, 18 Mar 2020 01:26:04 +0000 (02:26 +0100)] 
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".

5 years agobpo-39984: Pass tstate to handle_signals() (GH-19050)
Victor Stinner [Wed, 18 Mar 2020 00:56:21 +0000 (01:56 +0100)] 
bpo-39984: Pass tstate to handle_signals() (GH-19050)

handle_signals() and make_pending_calls() now expect tstate rather
than runtime.

5 years agobpo-38373: Change list overallocating strategy. (GH-18952)
Serhiy Storchaka [Tue, 17 Mar 2020 21:46:00 +0000 (23:46 +0200)] 
bpo-38373: Change list overallocating strategy. (GH-18952)

* Add padding to make the allocated size multiple of 4.
* Do not overallocate if the new size is closer to overalocated size
  than to the old size.

5 years agobpo-39719: Remove softspace from tempfile.SpooledTemporaryFile (GH-18599)
Shantanu [Tue, 17 Mar 2020 21:43:20 +0000 (14:43 -0700)] 
bpo-39719: Remove softspace from tempfile.SpooledTemporaryFile (GH-18599)

5 years agobpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)
Serhiy Storchaka [Tue, 17 Mar 2020 21:41:08 +0000 (23:41 +0200)] 
bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)

5 years agobpo-39984: Add PyInterpreterState.ceval (GH-19047)
Victor Stinner [Tue, 17 Mar 2020 17:56:44 +0000 (18:56 +0100)] 
bpo-39984: Add PyInterpreterState.ceval (GH-19047)

subinterpreters: Move _PyRuntimeState.ceval.tracing_possible to
PyInterpreterState.ceval.tracing_possible: each interpreter now has
its own variable.

Changes:

* Add _ceval_state structure.
* Add PyInterpreterState.ceval field.
* _PyEval_EvalFrameDefault(): add ceval2 variable (struct _ceval_state*).
* Rename _PyEval_Initialize() to _PyEval_InitRuntimeState().
* Add _PyEval_InitState().
* Don't export internal _Py_FinishPendingCalls() and
  _PyEval_FiniThreads() functions anymore.

5 years agobpo-1635741: Port itertools module to multiphase initialization (GH-19044)
Dong-hee Na [Tue, 17 Mar 2020 17:46:24 +0000 (02:46 +0900)] 
bpo-1635741: Port itertools module to multiphase initialization (GH-19044)

5 years agobpo-39991: Enhance uuid parser for MAC address (GH-19045)
Victor Stinner [Tue, 17 Mar 2020 17:36:44 +0000 (18:36 +0100)] 
bpo-39991: Enhance uuid parser for MAC address (GH-19045)

Reject valid IPv6 addresses which doesn't contain "::" but have
a length of 17 characters.

5 years agobpo-39824: module_traverse() don't call m_traverse if md_state=NULL (GH-18738)
Victor Stinner [Tue, 17 Mar 2020 17:09:46 +0000 (18:09 +0100)] 
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>
5 years agobpo-26067: Do not fail test_shutil / chown when gid/uid cannot be resolved (#19032)
Matthias Braun [Tue, 17 Mar 2020 16:51:44 +0000 (09:51 -0700)] 
bpo-26067: Do not fail test_shutil / chown when gid/uid cannot be resolved (#19032)

* bpo-26067: Do not fail test_shutil.chown when gid/uid cannot be resolved

There is no guarantee that the users primary uid or gid can be resolved
in the unix group/account databases. Skip the last part of the chown
test if we cannot resolve the gid or uid to a name.

* 📜🤖 Added by blurb_it.

* Address review feedback

* address review feedback correctly

* fix typo

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 years agobpo-39943: Remove unused self from find_nfc_index() (GH-18973)
Andy Lester [Tue, 17 Mar 2020 16:38:12 +0000 (11:38 -0500)] 
bpo-39943: Remove unused self from find_nfc_index() (GH-18973)

5 years agobpo-39987: Simplify setting lineno in the compiler. (GH-19037)
Serhiy Storchaka [Tue, 17 Mar 2020 16:07:30 +0000 (18:07 +0200)] 
bpo-39987: Simplify setting lineno in the compiler. (GH-19037)

5 years agobpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)
Victor Stinner [Tue, 17 Mar 2020 14:51:42 +0000 (15:51 +0100)] 
bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)

uuid.getnode() now skips IPv6 addresses with the same string length
than a MAC address (17 characters): only use MAC addresses.

5 years agobpo-39973: Fix the docs for PyObject_GenericSetDict() (GH-19026)
Zackery Spytz [Tue, 17 Mar 2020 08:19:28 +0000 (02:19 -0600)] 
bpo-39973: Fix the docs for PyObject_GenericSetDict() (GH-19026)

PyObject_GenericSetDict() takes three arguments, not two.

5 years agobpo-39656: Ensure `bin/python3.#` is always present in virtual environments on POSIX...
Anthony Sottile [Tue, 17 Mar 2020 07:29:11 +0000 (00:29 -0700)] 
bpo-39656: Ensure `bin/python3.#` is always present in virtual environments on POSIX (GH-19030)

5 years agobpo-1635741: Port _ctypes_test extension to multiphase initialization (PEP 489)...
Hai Shi [Tue, 17 Mar 2020 01:15:23 +0000 (09:15 +0800)] 
bpo-1635741: Port  _ctypes_test extension to multiphase initialization (PEP 489) (GH-19012)

5 years agobpo-37207: Use PEP 590 vectorcall to speed up set() constructor (GH-19019)
Dong-hee Na [Mon, 16 Mar 2020 17:17:38 +0000 (02:17 +0900)] 
bpo-37207: Use PEP 590 vectorcall to speed up set() constructor (GH-19019)

5 years agobpo-39968: Fix a typo error in get_readline_state() (GH-19028)
Hai Shi [Mon, 16 Mar 2020 17:16:32 +0000 (01:16 +0800)] 
bpo-39968: Fix a typo error in get_readline_state() (GH-19028)

5 years agobpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977)
Victor Stinner [Mon, 16 Mar 2020 16:41:44 +0000 (17:41 +0100)] 
bpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977)

If PySys_Audit() fails in PyEval_SetProfile() or PyEval_SetTrace(),
log the error as an unraisable exception.

5 years agobpo-1635741: Port _statistics module to multiphase initialization (GH-19015)
Dong-hee Na [Mon, 16 Mar 2020 15:10:21 +0000 (00:10 +0900)] 
bpo-1635741: Port _statistics module to multiphase initialization (GH-19015)

5 years agobpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)
Dong-hee Na [Mon, 16 Mar 2020 14:06:20 +0000 (23:06 +0900)] 
bpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)