]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
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)

5 years agobpo-37207: Use _PyArg_CheckPositional() for tuple vectorcall (GH-18986)
Dong-hee Na [Mon, 16 Mar 2020 14:04:14 +0000 (23:04 +0900)] 
bpo-37207: Use _PyArg_CheckPositional() for tuple vectorcall (GH-18986)

5 years agobpo-39968: Convert extension modules' macros of get_module_state() to inline function...
Hai Shi [Mon, 16 Mar 2020 13:15:01 +0000 (21:15 +0800)] 
bpo-39968: Convert extension modules' macros of get_module_state() to inline functions (GH-19017)

5 years agobpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)
Batuhan Taşkaya [Mon, 16 Mar 2020 08:12:53 +0000 (11:12 +0300)] 
bpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)

5 years agobpo-38870: Implement support for ast.FunctionType in ast.unparse (GH-19016)
Batuhan Taşkaya [Sun, 15 Mar 2020 19:56:57 +0000 (22:56 +0300)] 
bpo-38870: Implement support for ast.FunctionType in ast.unparse (GH-19016)

5 years agobpo-39360: Ensure all workers exit when finalizing a multiprocessing Pool (GH-19009)
Batuhan Taşkaya [Sun, 15 Mar 2020 19:45:56 +0000 (22:45 +0300)] 
bpo-39360: Ensure all workers exit when finalizing a multiprocessing Pool (GH-19009)

When the pull is not used via the context manager or terminate() is called, there is a system in multiprocessing.util that handles finalization of all pools via an atexit handler (the Finalize) class. This class registers the _terminate_pool handler in the registry of finalizers of the module, and that registry is called on interpreter exit via _exit_function. The problem is that the "happy" path with the context manager or manual call to finalize() does some extra steps that _terminate_pool does not. The step that is not executed when the atexit() handler calls _terminate_pool is pinging the _change_notifier queue to unblock the maintenance threads.

This commit moves the notification to the _terminate_pool function so is called from both code paths.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agoFix a possible refleak in tupleobject.c (GH-19018)
Hai Shi [Sun, 15 Mar 2020 19:37:49 +0000 (03:37 +0800)] 
Fix a possible refleak in tupleobject.c (GH-19018)

5 years agobpo-39969: Remove ast.Param node class as is no longer used (GH-19020)
Batuhan Taşkaya [Sun, 15 Mar 2020 19:32:17 +0000 (22:32 +0300)] 
bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)

5 years agobpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)
Ross [Sun, 15 Mar 2020 12:24:23 +0000 (12:24 +0000)] 
bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)

5 years agobpo-39965: Correctly raise SyntaxError if await is used outside async functions when...
Pablo Galindo [Sun, 15 Mar 2020 04:29:22 +0000 (04:29 +0000)] 
bpo-39965: Correctly raise SyntaxError if await is used outside async functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)

5 years agoLink to list of keywords in the laguage reference (GH-18024)
Борис Верховский [Sat, 14 Mar 2020 19:09:15 +0000 (15:09 -0400)] 
Link to list of keywords in the laguage reference (GH-18024)

5 years agobpo-38576: Disallow control characters in hostnames in http.client (GH-18995)
Ashwin Ramaswami [Sat, 14 Mar 2020 18:56:06 +0000 (14:56 -0400)] 
bpo-38576: Disallow control characters in hostnames in http.client (GH-18995)

Add host validation for control characters for more CVE-2019-18348 protection.

5 years agobpo-39677: dis: rename the operand of MAKE_FUNCTION from `argc` to `flags` for 3...
Taine Zhao [Sat, 14 Mar 2020 14:24:06 +0000 (23:24 +0900)] 
bpo-39677: dis: rename the operand of MAKE_FUNCTION from `argc` to `flags` for 3.6+ (GC-18550)

5 years agobpo-39509: Update HTTP status code to follow IANA (GH-18294)
Dong-hee Na [Sat, 14 Mar 2020 14:12:01 +0000 (23:12 +0900)] 
bpo-39509: Update HTTP status code to follow IANA (GH-18294)

Add status codes 103 EARLY_HINTS and 425 TOO_EARLY.

5 years agobpo-39582: ossaudiodev module update helpers signature for ioctl calls. (GH-18412)
David CARLIER [Sat, 14 Mar 2020 13:48:56 +0000 (13:48 +0000)] 
bpo-39582: ossaudiodev module update helpers signature for ioctl calls. (GH-18412)

5 years agobpo-39585: Delete a pending comment in _warning.c (GH-18414)
Hai Shi [Sat, 14 Mar 2020 13:40:58 +0000 (21:40 +0800)] 
bpo-39585: Delete a pending comment in _warning.c (GH-18414)

5 years agoMake cpython/abstract.h compatible with C90 (#18481)
Peter Eisentraut [Sat, 14 Mar 2020 11:47:09 +0000 (12:47 +0100)] 
Make cpython/abstract.h compatible with C90 (#18481)

Some inline functions use mixed declarations and code.  These end up
visible in third-party code that includes Python.h, which might not be
using a C99 compiler.  Fix by moving the declarations first, like in
the old days.

5 years agobpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)
Zackery Spytz [Sat, 14 Mar 2020 10:45:32 +0000 (04:45 -0600)] 
bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)

In math_2(), the first PyFloat_AsDouble() call should be checked
for failure before the second call.

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
5 years agoRevert "bpo-39087: Add _PyUnicode_GetUTF8Buffer()" (GH-18985)
Inada Naoki [Sat, 14 Mar 2020 06:59:27 +0000 (15:59 +0900)] 
Revert "bpo-39087: Add _PyUnicode_GetUTF8Buffer()" (GH-18985)

* Revert "bpo-39087: Add _PyUnicode_GetUTF8Buffer() (GH-17659)"

This reverts commit c7ad974d341d3edb6b9d2a2dcae4d3d4794ada6b.

* Update unicodeobject.h

5 years agobpo-39937: Improve suggestions for removal of getchildren and getiterator in changelo...
Rahul Kumaresan [Sat, 14 Mar 2020 05:50:24 +0000 (11:20 +0530)] 
bpo-39937: Improve suggestions for removal of getchildren and getiterator in changelog (GH-18937)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 years agobpo-39087: Add _PyUnicode_GetUTF8Buffer() (GH-17659)
Inada Naoki [Sat, 14 Mar 2020 03:43:18 +0000 (12:43 +0900)] 
bpo-39087: Add _PyUnicode_GetUTF8Buffer() (GH-17659)

Co-authored-by: Victor Stinner <vstinner@python.org>
5 years agobpo-39947: Add PyThreadState_GetInterpreter() (GH-18981)
Victor Stinner [Fri, 13 Mar 2020 22:38:08 +0000 (23:38 +0100)] 
bpo-39947: Add PyThreadState_GetInterpreter() (GH-18981)

Add PyThreadState_GetInterpreter(tstate): get the interpreter of a
Python thread state.

5 years agobpo-39947: Add PyInterpreterState_Get() function (GH-18979)
Victor Stinner [Fri, 13 Mar 2020 17:15:33 +0000 (18:15 +0100)] 
bpo-39947: Add PyInterpreterState_Get() function (GH-18979)

* Rename _PyInterpreterState_Get() to PyInterpreterState_Get() and
  move it the limited C API.
* Add _PyInterpreterState_Get() alias to PyInterpreterState_Get() for
  backward compatibility with Python 3.8.

5 years agobpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)
Victor Stinner [Fri, 13 Mar 2020 17:03:56 +0000 (18:03 +0100)] 
bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)

Replace _PyInterpreterState_Get() function call with
_PyInterpreterState_GET_UNSAFE() macro which is more efficient but
don't check if tstate or interp is NULL.

_Py_GetConfigsAsDict() now uses _PyThreadState_GET().

5 years agobpo-36144: OrderedDict Union (PEP 584) (#18967)
Brandt Bucher [Fri, 13 Mar 2020 16:06:04 +0000 (09:06 -0700)] 
bpo-36144: OrderedDict Union (PEP 584) (#18967)

5 years agobpo-36144: Update os.environ and os.environb for PEP 584 (#18911)
Charles Burkland [Fri, 13 Mar 2020 16:04:43 +0000 (09:04 -0700)] 
bpo-36144: Update os.environ and os.environb for PEP 584  (#18911)

5 years agobpo-39947: Hide implementation detail of trashcan macros (GH-18971)
Victor Stinner [Fri, 13 Mar 2020 15:51:52 +0000 (16:51 +0100)] 
bpo-39947: Hide implementation detail of trashcan macros (GH-18971)

Py_TRASHCAN_BEGIN_CONDITION and Py_TRASHCAN_END macro no longer
access PyThreadState attributes, but call new private
_PyTrash_begin() and _PyTrash_end() functions which hide
implementation details.

5 years agobpo-35370: Add _PyEval_SetTrace() function (GH-18975)
Victor Stinner [Fri, 13 Mar 2020 15:39:12 +0000 (16:39 +0100)] 
bpo-35370: Add _PyEval_SetTrace() function (GH-18975)

* sys.settrace(), sys.setprofile() and _lsprof.Profiler.enable() now
  properly report PySys_Audit() error if "sys.setprofile" or
  "sys.settrace" audit event is denied.
* Add _PyEval_SetProfile() and _PyEval_SetTrace() function: similar
  to PyEval_SetProfile() and PyEval_SetTrace() but take a tstate
  parameter and return -1 on error.
* Add _PyObject_FastCallTstate() function.

5 years agobpo-37207: Use PEP 590 vectorcall to speed up tuple() (GH-18936)
Dong-hee Na [Fri, 13 Mar 2020 13:57:00 +0000 (22:57 +0900)] 
bpo-37207: Use PEP 590 vectorcall to speed up tuple() (GH-18936)

Master:

./python.exe -m pyperf timeit "tuple((1, 2, 3, 4, 5))"
Mean +- std dev: 361 ns +- 15 ns

PEP-590:

./python.exe -m pyperf timeit "tuple((1, 2, 3, 4, 5))"
Mean +- std dev: 203 ns +- 13 ns

5 years agobpo-39947: Move get_recursion_depth() to _testinternalcapi (GH-18974)
Victor Stinner [Fri, 13 Mar 2020 12:07:31 +0000 (13:07 +0100)] 
bpo-39947: Move get_recursion_depth() to _testinternalcapi (GH-18974)

Move get_recursion_depth() function from _testcapi to
_testinternalcapi to avoid accessing PyThreadState attributes
directly in _testcapi.

5 years agobpo-39947: Move Py_EnterRecursiveCall() to internal C API (GH-18972)
Victor Stinner [Fri, 13 Mar 2020 09:19:38 +0000 (10:19 +0100)] 
bpo-39947: Move Py_EnterRecursiveCall() to internal C API (GH-18972)

Move the static inline function flavor of Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() to the internal C API: they access
PyThreadState attributes. The limited C API provides regular
functions which hide implementation details.

5 years agobpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() (GH-17340)
Victor Stinner [Thu, 12 Mar 2020 22:18:39 +0000 (23:18 +0100)] 
bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() (GH-17340)

PyInterpreterState.eval_frame function now requires a tstate (Python
thread state) parameter.

Add private functions to the C API to get and set the frame
evaluation function:

* Add tstate parameter to _PyFrameEvalFunction function type.
* Add _PyInterpreterState_GetEvalFrameFunc() and
  _PyInterpreterState_SetEvalFrameFunc() functions.
* Add tstate parameter to _PyEval_EvalFrameDefault().

5 years agobpo-39936: _aix_support uses _bootsubprocess (GH-18970)
Victor Stinner [Thu, 12 Mar 2020 22:15:34 +0000 (23:15 +0100)] 
bpo-39936: _aix_support uses _bootsubprocess (GH-18970)

AIX: Fix _aix_support module when the subprocess is not available,
when building Python from scratch. It now uses new private
_bootsubprocess module, rather than having two implementations
depending if subprocess is available or not. So
_aix_support.aix_platform() result is now the same if subprocess is
available or not.

5 years agobpo-39689: Do not test undefined casts to _Bool (GH-18964)
Stefan Krah [Thu, 12 Mar 2020 18:35:38 +0000 (19:35 +0100)] 
bpo-39689: Do not test undefined casts to _Bool (GH-18964)

- When casting to _Bool, arrays should only contain zeros or ones.

5 years agoDoc: Fix grammar in PyErr_ResourceWarning (GH-18879)
Daniel Hahler [Thu, 12 Mar 2020 17:09:30 +0000 (18:09 +0100)] 
Doc: Fix grammar in PyErr_ResourceWarning (GH-18879)

5 years agobpo-1294959: Fix typo for new attribute platlibdir. (GH-18960)
Raúl Cumplido [Thu, 12 Mar 2020 14:38:19 +0000 (15:38 +0100)] 
bpo-1294959: Fix typo for new attribute platlibdir. (GH-18960)

Received email on the docs mailing list to fix a typo from `sys.platlitdir` which doesn't exist to the correct new attribute `sys.platlibdir`

Automerge-Triggered-By: @vstinner
5 years agoRemove unused args from two pylifecycle.c functions (GH-18867)
Andy Lester [Thu, 12 Mar 2020 07:49:05 +0000 (02:49 -0500)] 
Remove unused args from two pylifecycle.c functions (GH-18867)

* Remove unused tstate argument from init_set_builtins_open()
* Replace fd (int) with tstate (PyThreadState *) in in _Py_FatalError_PrintExc()

5 years agobpo-39884: Add method name in "bad call flags" error (GH-18944)
Victor Stinner [Thu, 12 Mar 2020 07:38:11 +0000 (08:38 +0100)] 
bpo-39884: Add method name in "bad call flags" error (GH-18944)

PyDescr_NewMethod() and PyCFunction_NewEx() now include the method
name in the SystemError "bad call flags" error message to ease debug.

5 years agoSimplify defaultdict.__or__ (#18931)
Brandt Bucher [Thu, 12 Mar 2020 04:06:46 +0000 (21:06 -0700)] 
Simplify defaultdict.__or__ (#18931)

5 years agoFix syntax error in an example in the ast documentation and sync docstrings (GH-18946)
Pablo Galindo [Thu, 12 Mar 2020 00:48:19 +0000 (00:48 +0000)] 
Fix syntax error in an example in the ast documentation and sync docstrings (GH-18946)

5 years agobpo-38080: Added "getproxies" to urllib fixes in the 2to3 tool (GH-16167)
José Roberto Meza Cabrera [Wed, 11 Mar 2020 23:51:20 +0000 (18:51 -0500)] 
bpo-38080: Added "getproxies" to urllib fixes in the 2to3 tool (GH-16167)

5 years agobpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)
bobince [Wed, 11 Mar 2020 23:39:02 +0000 (23:39 +0000)] 
bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)

The 32-bit (49-day) TickCount relied on in EnterNonRecursiveMutex can overflow
in the gap between the 'target' time and the 'now' time WaitForSingleObjectEx
returns, causing the loop to think it needs to wait another 49 days. This is
most likely to happen when the machine is hibernated during
WaitForSingleObjectEx.

This makes acquiring a lock/event/etc from the _thread or threading module
appear to never timeout.

Replace with GetTickCount64 - this is OK now Python no longer supports XP which
lacks it, and is in use for time.monotonic().

Co-authored-by: And Clover <and.clover@bromium.com>
5 years agobpo-39930: Fix MSBuild detection for Build Tools (GH-18938)
Steve Dower [Wed, 11 Mar 2020 23:24:30 +0000 (23:24 +0000)] 
bpo-39930: Fix MSBuild detection for Build Tools (GH-18938)

Ensure we detect Build Tools installs using the newer logic, and skip looking in the registry for VS 2017.

5 years agobpo-1635741: Fix refleaks of time module error handling (GH-18486)
Hai Shi [Wed, 11 Mar 2020 16:56:08 +0000 (00:56 +0800)] 
bpo-1635741: Fix refleaks of time module error handling (GH-18486)

5 years agobpo-1635741: Fix potential refleaks in binascii module (GH-18613)
Hai Shi [Wed, 11 Mar 2020 16:50:52 +0000 (00:50 +0800)] 
bpo-1635741: Fix potential refleaks in binascii module (GH-18613)

5 years agobpo-1635741: Port audioop extension module to multiphase initialization (PEP 489...
Hai Shi [Wed, 11 Mar 2020 16:49:11 +0000 (00:49 +0800)] 
bpo-1635741: Port audioop extension module to multiphase initialization (PEP 489) (GH-18608)

Co-authored-by: Victor Stinner <vstinner@python.org>
5 years agobpo-1635741: Port _locale extension module to multiphase initialization (PEP 489...
Hai Shi [Wed, 11 Mar 2020 16:46:06 +0000 (00:46 +0800)] 
bpo-1635741: Port _locale extension module to multiphase initialization (PEP 489) (GH-18358)

Co-authored-by: Petr Viktorin <pviktori@redhat.com>
5 years agobpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)
Serhiy Storchaka [Wed, 11 Mar 2020 16:42:03 +0000 (18:42 +0200)] 
bpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)

5 years agobpo-39915: Ensure await_args_list is updated according to the order in which coroutin...
Karthikeyan Singaravelan [Wed, 11 Mar 2020 15:06:12 +0000 (20:36 +0530)] 
bpo-39915: Ensure await_args_list is updated according to the order in which coroutines were awaited (GH-18924)

Create call objects with awaited arguments instead of using call_args which has only last call value.

5 years agobpo-39930: Convert error to warning for more silent failure (GH-18921)
Steve Dower [Wed, 11 Mar 2020 14:12:31 +0000 (14:12 +0000)] 
bpo-39930: Convert error to warning for more silent failure (GH-18921)

Makes it an error to create a layout without vcruntime DLL

5 years agobpo-39761: Fix dtrace build with empty $DFLAGS (GH-18766)
Petr Viktorin [Wed, 11 Mar 2020 13:27:42 +0000 (14:27 +0100)] 
bpo-39761: Fix dtrace build with empty $DFLAGS (GH-18766)

This fixes a regression introduced in bpo-38960.

When DFLAGS was empty, "$DFLAGS" results in an empty argument ("").
Without the quotes, an empty variable will be ignored by the shell.

5 years agobpo-39930: Ensure vcruntime140.dll is included in all Windows packages (GH-18918)
Steve Dower [Wed, 11 Mar 2020 11:18:12 +0000 (11:18 +0000)] 
bpo-39930: Ensure vcruntime140.dll is included in all Windows packages (GH-18918)

Also adds GitHub CI test for Windows installer changes

5 years agoFix download.html (GH-18902)
Inada Naoki [Wed, 11 Mar 2020 04:23:24 +0000 (13:23 +0900)] 
Fix download.html (GH-18902)

`<tt>` is not allowed.

Co-authored-by: Kyle Stanley <aeros167@gmail.com>
5 years agobpo-39926: Update unicodedata checksum tests for Unicode 13.0 update. (GH-18913)
Benjamin Peterson [Wed, 11 Mar 2020 04:18:33 +0000 (21:18 -0700)] 
bpo-39926: Update unicodedata checksum tests for Unicode 13.0 update. (GH-18913)

I forget these tests required the cpu resource.

5 years agoUpdate some www.unicode.org URLs to use HTTPS. (GH-18912)
Benjamin Peterson [Wed, 11 Mar 2020 04:10:59 +0000 (21:10 -0700)] 
Update some www.unicode.org URLs to use HTTPS. (GH-18912)

5 years agocloses bpo-39926: Update Unicode to 13.0.0. (GH-18910)
Benjamin Peterson [Wed, 11 Mar 2020 03:41:34 +0000 (20:41 -0700)] 
closes bpo-39926: Update Unicode to 13.0.0. (GH-18910)

5 years agocloses bpo-39922: Remove unused args from four functions. (GH-18893)
Andy Lester [Wed, 11 Mar 2020 02:18:12 +0000 (21:18 -0500)] 
closes bpo-39922: Remove unused args from four functions. (GH-18893)

5 years agoUpdates functools.py with consistent quotes (GH-18825)
Nikita Sobolev [Wed, 11 Mar 2020 00:32:15 +0000 (03:32 +0300)] 
Updates functools.py with consistent quotes (GH-18825)

I have noticed that `'` quotes are used everywhere except this particular case,
which was introduced in https://github.com/python/cpython/pull/18726

So, this is a trivial fix to enforce better consistency.

5 years agobpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)
Victor Stinner [Tue, 10 Mar 2020 22:49:16 +0000 (23:49 +0100)] 
bpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)

_PyGILState_Init() now returns PyStatus rather than calling
Py_FatalError() on failure.

5 years agobpo-38662: ensurepip invokes pip via runpy (GH-18901)
Miro Hrončok [Tue, 10 Mar 2020 21:16:28 +0000 (22:16 +0100)] 
bpo-38662: ensurepip invokes pip via runpy (GH-18901)

The ensurepip module now invokes pip via the runpy module.
Hence it is no longer tightly coupled with the internal API of the bundled
pip version, allowing easier updates to a newer pip version both
internally and for distributors.

This way, any changes to the internal pip API won't mean ensurepip needs to be
changed as well. Also, distributors can update their pip wheels independent on
CPython release schedule.

Co-Authored-By: Pradyun Gedam <pradyunsg@gmail.com>
Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
5 years agotracemalloc: 'pretty top' example no longer changes the filename (GH-18903)
Adam Johnson [Tue, 10 Mar 2020 18:18:50 +0000 (18:18 +0000)] 
tracemalloc: 'pretty top' example no longer changes the filename (GH-18903)

I've used this recipe a couple times and the filename editing has always
been less than useful and something I've removed. This is because many
modules end up losing which package they are located in, e.g. `util/date.py`.

5 years agobpo-34822: Simplify AST for subscription. (GH-9605)
Serhiy Storchaka [Tue, 10 Mar 2020 16:52:34 +0000 (18:52 +0200)] 
bpo-34822: Simplify AST for subscription. (GH-9605)

* Remove the slice type.
* Make Slice a kind of the expr type instead of the slice type.
* Replace ExtSlice(slices) with Tuple(slices, Load()).
* Replace Index(value) with a value itself.

All non-terminal nodes in AST for expressions are now of the expr type.

5 years agobpo-39869: Fix typo in 'Instance objects' section. (GH-18889)
Antoine [Tue, 10 Mar 2020 14:17:40 +0000 (15:17 +0100)] 
bpo-39869: Fix typo in 'Instance objects' section. (GH-18889)

5 years agobpo-38075: Fix random_seed(): use PyObject_CallOneArg() (GH-18897)
Victor Stinner [Tue, 10 Mar 2020 14:15:14 +0000 (15:15 +0100)] 
bpo-38075: Fix random_seed(): use PyObject_CallOneArg() (GH-18897)

Fix the random.Random.seed() method when a bool is passed as the
seed.

PyObject_Vectorcall() was misused: use PyObject_CallOneArg() instead.