]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
5 years agobpo-39573: Add Py_SET_TYPE() function (GH-18394)
Victor Stinner [Fri, 7 Feb 2020 08:17:07 +0000 (09:17 +0100)] 
bpo-39573: Add Py_SET_TYPE() function (GH-18394)

Add Py_SET_TYPE() function to set the type of an object.

5 years agobpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)
Victor Stinner [Fri, 7 Feb 2020 02:37:06 +0000 (03:37 +0100)] 
bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)

Replace direct access to PyObject.ob_type with Py_TYPE().

5 years agobpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)
Victor Stinner [Fri, 7 Feb 2020 02:04:21 +0000 (03:04 +0100)] 
bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)

Replace direct access to PyObject.ob_type with Py_TYPE().

5 years agobpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)
Victor Stinner [Fri, 7 Feb 2020 01:24:48 +0000 (02:24 +0100)] 
bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)

Replace direct access to PyObject.ob_type with Py_TYPE().

5 years agobpo-39491: Mention Annotated in get_origin() docstring (GH-18379)
Jakub Stasiak [Fri, 7 Feb 2020 01:15:12 +0000 (02:15 +0100)] 
bpo-39491: Mention Annotated in get_origin() docstring (GH-18379)

I forgot to do it in https://github.com/python/cpython/pull/18260.

5 years agobpo-39573: Use Py_TYPE() in abstract.c (GH-18390)
Victor Stinner [Fri, 7 Feb 2020 00:53:23 +0000 (01:53 +0100)] 
bpo-39573: Use Py_TYPE() in abstract.c (GH-18390)

Replace direct access to PyObject.ob_type with Py_TYPE().

5 years agobpo-39571: Fix clang warning on PyTypeObject typedef (GH-18385)
Victor Stinner [Fri, 7 Feb 2020 00:43:25 +0000 (01:43 +0100)] 
bpo-39571: Fix clang warning on PyTypeObject typedef (GH-18385)

Only define PyTypeObject type once.

5 years agobpo-39573: Add Py_SET_REFCNT() function (GH-18389)
Victor Stinner [Fri, 7 Feb 2020 00:24:29 +0000 (01:24 +0100)] 
bpo-39573: Add Py_SET_REFCNT() function (GH-18389)

Add a Py_SET_REFCNT() function to set the reference counter of an
object.

5 years agobpo-39573: Use Py_REFCNT() macro (GH-18388)
Victor Stinner [Thu, 6 Feb 2020 23:38:59 +0000 (00:38 +0100)] 
bpo-39573: Use Py_REFCNT() macro (GH-18388)

Replace direct acccess to PyObject.ob_refcnt with usage of the
Py_REFCNT() macro.

5 years agobpo-39534: Doc: Clarify return in finally (GH-18324)
Julien Palard [Thu, 6 Feb 2020 22:16:48 +0000 (23:16 +0100)] 
bpo-39534: Doc: Clarify return in finally (GH-18324)

5 years agoWhat's New in Python 3.9: sort improved modules (GH-18383)
Victor Stinner [Thu, 6 Feb 2020 22:03:01 +0000 (23:03 +0100)] 
What's New in Python 3.9: sort improved modules (GH-18383)

5 years agobpo-39542: Document limited C API changes (GH-18378)
Victor Stinner [Thu, 6 Feb 2020 21:41:34 +0000 (22:41 +0100)] 
bpo-39542: Document limited C API changes (GH-18378)

5 years agobpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)
Sebastian Berg [Thu, 6 Feb 2020 14:54:05 +0000 (06:54 -0800)] 
bpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)

Some numerator types used (specifically NumPy) decides to not
return a Python boolean for the "a != b" operation. Using the equivalent
call to bool() guarantees a bool return also for such types.

5 years agobpo-39245: Make Vectorcall C API public (GH-17893)
Petr Viktorin [Thu, 6 Feb 2020 14:48:27 +0000 (15:48 +0100)] 
bpo-39245: Make Vectorcall C API public (GH-17893)

* Add backcompat defines and move non-limited API declaration to cpython/

This partially reverts commit 2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c
which added PyObject_CallNoArgs to the 3.9+ stable ABI. This should not
be done; there are enough other call APIs in the stable ABI to choose from.

* Adjust documentation

Mark all newly public functions as added in 3.9.
Add a note about the 3.8 provisional names.
Add notes on public API.

* Put PyObject_CallNoArgs back in the limited API

* Rename PyObject_FastCallDict to PyObject_VectorcallDict

5 years agobpo-38823: Fix refleaks in _ast initialization error path (GH-17276)
Brandt Bucher [Thu, 6 Feb 2020 14:45:46 +0000 (06:45 -0800)] 
bpo-38823: Fix refleaks in _ast initialization error path (GH-17276)

5 years agobpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)
Serhiy Storchaka [Thu, 6 Feb 2020 08:26:37 +0000 (10:26 +0200)] 
bpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)

5 years agobpo-39555: Fix distutils test to handle _d suffix on Windows debug build (GH-18357)
Steve Dower [Thu, 6 Feb 2020 04:48:10 +0000 (15:48 +1100)] 
bpo-39555: Fix distutils test to handle _d suffix on Windows debug build (GH-18357)

5 years agobpo-39127: Make _Py_HashPointer's argument be const (GH-17690)
Andy Lester [Wed, 5 Feb 2020 21:09:57 +0000 (15:09 -0600)] 
bpo-39127: Make _Py_HashPointer's argument be const (GH-17690)

5 years agobpo-39559: Remove unused, undocumented argument from uuid.getnode (GH-18369)
Shantanu [Wed, 5 Feb 2020 20:43:09 +0000 (12:43 -0800)] 
bpo-39559: Remove unused, undocumented argument from uuid.getnode (GH-18369)

5 years agobpo-39542: Declare _Py_AddToAllObjects() in pycore_object.h (GH-18368)
Victor Stinner [Wed, 5 Feb 2020 17:24:33 +0000 (18:24 +0100)] 
bpo-39542: Declare _Py_AddToAllObjects() in pycore_object.h (GH-18368)

_Py_AddToAllObjects() is used in bltinmodule.c and typeobject.c when
Py_TRACE_REFS is defined.

Fix Py_TRACE_REFS build.

5 years agobpo-39488: Skip test_largefile tests if not enough disk space (GH-18261)
Giampaolo Rodola [Wed, 5 Feb 2020 17:20:52 +0000 (18:20 +0100)] 
bpo-39488: Skip test_largefile tests if not enough disk space (GH-18261)

5 years agoAdd PyInterpreterState.fs_codec.utf8 (GH-18367)
Victor Stinner [Wed, 5 Feb 2020 16:39:57 +0000 (17:39 +0100)] 
Add PyInterpreterState.fs_codec.utf8 (GH-18367)

Add a fast-path for UTF-8 encoding in PyUnicode_EncodeFSDefault()
and PyUnicode_DecodeFSDefaultAndSize().

Add _PyUnicode_FiniEncodings() helper function for _PyUnicode_Fini().

5 years agobpo-39542: Define PyTypeObject earlier in object.h (GH-18366)
Victor Stinner [Wed, 5 Feb 2020 14:10:39 +0000 (15:10 +0100)] 
bpo-39542: Define PyTypeObject earlier in object.h (GH-18366)

Replace "struct _typeobject" with PyTypeObject in object.h.

5 years agobpo-39542: Convert PyType_Check() to static inline function (GH-18364)
Victor Stinner [Wed, 5 Feb 2020 13:24:17 +0000 (14:24 +0100)] 
bpo-39542: Convert PyType_Check() to static inline function (GH-18364)

Convert PyType_HasFeature(), PyType_Check() and PyType_CheckExact()
macros to static inline functions.

5 years agobpo-39542: Make PyObject_INIT() opaque in limited C API (GH-18363)
Victor Stinner [Wed, 5 Feb 2020 12:12:19 +0000 (13:12 +0100)] 
bpo-39542: Make PyObject_INIT() opaque in limited C API (GH-18363)

In the limited C API, PyObject_INIT() and PyObject_INIT_VAR() are now
defined as aliases to PyObject_Init() and PyObject_InitVar() to make
their implementation opaque. It avoids to leak implementation details
in the limited C API.

Exclude the following functions from the limited C API, move them
from object.h to cpython/object.h:

* _Py_NewReference()
* _Py_ForgetReference()
* _PyTraceMalloc_NewReference()
* _Py_GetRefTotal()

5 years agobpo-39542: Exclude trashcan from the limited C API (GH-18362)
Victor Stinner [Wed, 5 Feb 2020 11:23:27 +0000 (12:23 +0100)] 
bpo-39542: Exclude trashcan from the limited C API (GH-18362)

Exclude trashcan mechanism from the limited C API: it requires access to
PyTypeObject and PyThreadState structure fields, whereas these structures
are opaque in the limited C API.

The trashcan mechanism never worked with the limited C API. Move it
from object.h to cpython/object.h.

5 years agobpo-39543: Remove unused _Py_Dealloc() macro (GH-18361)
Victor Stinner [Wed, 5 Feb 2020 11:18:28 +0000 (12:18 +0100)] 
bpo-39543: Remove unused _Py_Dealloc() macro (GH-18361)

The macro is defined after Py_DECREF() and so is no longer used by
Py_DECREF().

Moving _Py_Dealloc() macro back from cpython/object.h to object.h
would require to move a lot of definitions as well: PyTypeObject and
many related types used by PyTypeObject.

Keep _Py_Dealloc() as an opaque function call to avoid leaking
implementation details in the limited C API (object.h): remove
_Py_Dealloc() macro from cpython/object.h.

5 years agobpo-39505: delete the redundant '/' in $env:VIRTUAL_ENV (GH-18290)
schwarzichet [Wed, 5 Feb 2020 08:16:58 +0000 (16:16 +0800)] 
bpo-39505: delete the redundant '/' in $env:VIRTUAL_ENV (GH-18290)

5 years agobpo-39553: Delete HAVE_SXS protected code (GH-18356)
Zackery Spytz [Wed, 5 Feb 2020 03:13:00 +0000 (20:13 -0700)] 
bpo-39553: Delete HAVE_SXS protected code (GH-18356)

https://bugs.python.org/issue39553

Automerge-Triggered-By: @zooba
5 years agobpo-39491: Merge PEP 593 (typing.Annotated) support (#18260)
Jakub Stasiak [Wed, 5 Feb 2020 01:10:19 +0000 (02:10 +0100)] 
bpo-39491: Merge PEP 593 (typing.Annotated) support (#18260)

* bpo-39491: Merge PEP 593 (typing.Annotated) support

PEP 593 has been accepted some time ago. I got a green light for merging
this from Till, so I went ahead and combined the code contributed to
typing_extensions[1] and the documentation from the PEP 593 text[2].

My changes were limited to:

* removing code designed for typing_extensions to run on older Python
  versions
* removing some irrelevant parts of the PEP text when copying it over as
  documentation and otherwise changing few small bits to better serve
  the purpose
* changing the get_type_hints signature to match reality (parameter
  names)

I wasn't entirely sure how to go about crediting the authors but I used
my best judgment, let me know if something needs changing in this
regard.

[1] https://github.com/python/typing/blob/8280de241fd8c8afe727c7860254b753e383b360/typing_extensions/src_py3/typing_extensions.py
[2] https://github.com/python/peps/blob/17710b879882454d55f82c2d44596e8e9f8e4bff/pep-0593.rst

5 years agobpo-39185 Add the d[etailed] and q[uiet] verbosity levels for msbuild (GH-17791)
Anthony Shaw [Wed, 5 Feb 2020 00:30:19 +0000 (11:30 +1100)] 
bpo-39185 Add the d[etailed] and q[uiet] verbosity levels for msbuild (GH-17791)

5 years agobpo-39184: Add audit events to command execution functions in os and pty modules...
Saiyang Gou [Wed, 5 Feb 2020 00:15:00 +0000 (16:15 -0800)] 
bpo-39184: Add audit events to command execution functions in os and pty modules (GH-17824)

5 years agobpo-39542: Make _Py_NewReference() opaque in C API (GH-18346)
Victor Stinner [Wed, 5 Feb 2020 00:11:10 +0000 (01:11 +0100)] 
bpo-39542: Make _Py_NewReference() opaque in C API (GH-18346)

_Py_NewReference() becomes a regular opaque function, rather than a
static inline function in the C API (object.h), to better hide
implementation details.

Move _Py_tracemalloc_config from public pymem.h to internal
pycore_pymem.h header.

Make _Py_AddToAllObjects() private.

5 years agoFix MinGW library generation command (GH-17917)
Baljak [Wed, 5 Feb 2020 00:10:16 +0000 (01:10 +0100)] 
Fix MinGW library generation command (GH-17917)

To print the exports to stdout, the gendef command requires the option "-". Without this option, no output is generated.

5 years agocloses bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18295)
Philipp Gesang [Tue, 4 Feb 2020 21:25:16 +0000 (22:25 +0100)] 
closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18295)

When called on a closed object, readinto() segfaults on account
of a write to a freed buffer:

    ==220553== Process terminating with default action of signal 11 (SIGSEGV): dumping core
    ==220553==  Access not within mapped region at address 0x2A
    ==220553==    at 0x48408A0: memmove (vg_replace_strmem.c:1272)
    ==220553==    by 0x58DB0C: _buffered_readinto_generic (bufferedio.c:972)
    ==220553==    by 0x58DCBA: _io__Buffered_readinto_impl (bufferedio.c:1053)
    ==220553==    by 0x58DCBA: _io__Buffered_readinto (bufferedio.c.h:253)

Reproducer:

    reader = open ("/dev/zero", "rb")
    _void  = reader.read (42)
    reader.close ()
    reader.readinto (bytearray (42)) ### BANG!

The problem exists since 2012 when commit dc469454ec added code
to free the read buffer on close().

Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
5 years agobpo-39432: Implement PEP-489 algorithm for non-ascii "PyInit_*" symbol names in distu...
Stefan Behnel [Tue, 4 Feb 2020 15:24:30 +0000 (16:24 +0100)] 
bpo-39432: Implement PEP-489 algorithm for non-ascii "PyInit_*" symbol names in distutils (GH-18150)

Make it export the correct init symbol also on Windows.

https://bugs.python.org/issue39432

5 years agoRestore PyObject_IsInstance() comment (GH-18345)
Victor Stinner [Tue, 4 Feb 2020 12:42:13 +0000 (13:42 +0100)] 
Restore PyObject_IsInstance() comment (GH-18345)

Restore PyObject_IsInstance() comment explaining why only tuples of
types are accepted, but not general sequence. Comment written by
Guido van Rossum in commit 03290ecbf1661c0192e6abdbe00ae163af461d77
which implements isinstance(x, (A, B, ...)). The comment was lost in
a PyObject_IsInstance() optimization:
commit ec569b794737be248671d0dfac11b664fc930eef.

Cleanup also the code. recursive_isinstance() is no longer recursive,
so rename it to object_isinstance(), whereas object_isinstance() is
recursive and so rename it to object_recursive_isinstance().

5 years agobpo-38076 Clear the interpreter state only after clearing module globals (GH-18039)
Eddie Elizondo [Tue, 4 Feb 2020 10:29:25 +0000 (02:29 -0800)] 
bpo-38076 Clear the interpreter state only after clearing module globals (GH-18039)

Currently, during runtime destruction, `_PyImport_Cleanup` is clearing the interpreter state before clearing out the modules themselves. This leads to a segfault on modules that rely on the module state to clear themselves up.

For example, let's take the small snippet added in the issue by @DinoV :
```
import _struct

class C:
    def __init__(self):
        self.pack = _struct.pack
    def __del__(self):
        self.pack('I', -42)

_struct.x = C()
```

The module `_struct` uses the module state to run `pack`. Therefore, the module state has to be alive until after the module has been cleared out to successfully run `C.__del__`. This happens at line 606, when `_PyImport_Cleanup` calls `_PyModule_Clear`. In fact, the loop that calls `_PyModule_Clear` has in its comments:

> Now, if there are any modules left alive, clear their globals to minimize potential leaks.  All C extension modules actually end up here, since they are kept alive in the interpreter state.

That means that we can't clear the module state (which is used by C Extensions) before we run that loop.

Moving `_PyInterpreterState_ClearModules` until after it, fixes the segfault in the code snippet.

Finally, this updates a test in `io` to correctly assert the error that it now throws (since it now finds the io module state). The test that uses this is: `test_create_at_shutdown_without_encoding`. Given this test is now working is a proof that the module state now stays alive even when `__del__` is called at module destruction time. Thus, I didn't add a new tests for this.

https://bugs.python.org/issue38076

5 years agoadd whatsnew that was missed from 31d6de5aba009914efa8f0f3c3d7da35217578eb (#18344)
Chris Withers [Tue, 4 Feb 2020 08:05:25 +0000 (08:05 +0000)] 
add whatsnew that was missed from 31d6de5aba009914efa8f0f3c3d7da35217578eb (#18344)

5 years agobpo-38558: Link to further docs from walrus operator mention in tutorial (GH-16973)
Adorilson Bezerra [Mon, 3 Feb 2020 17:11:19 +0000 (14:11 -0300)] 
bpo-38558: Link to further docs from walrus operator mention in tutorial (GH-16973)

5 years agobpo-39542: Simplify _Py_NewReference() (GH-18332)
Victor Stinner [Mon, 3 Feb 2020 16:55:05 +0000 (17:55 +0100)] 
bpo-39542: Simplify _Py_NewReference() (GH-18332)

* Remove _Py_INC_REFTOTAL and _Py_DEC_REFTOTAL macros: modify
  directly _Py_RefTotal.
* _Py_ForgetReference() is no longer defined if the Py_TRACE_REFS
  macro is not defined.
* Remove _Py_NewReference() implementation from object.c:
  unify the two implementations in object.h inline function.
* Fix Py_TRACE_REFS build: _Py_INC_TPALLOCS() macro has been removed.

5 years agoFixes in sorting descriptions (GH-18317)
Stefan Pochmann [Mon, 3 Feb 2020 16:47:20 +0000 (17:47 +0100)] 
Fixes in sorting descriptions (GH-18317)

Improvements in listsort.txt and a comment in sortperf.py.

Automerge-Triggered-By: @csabella
5 years agobpo-39542: Move object.h debug functions to internal C API (GH-18331)
Victor Stinner [Mon, 3 Feb 2020 16:28:26 +0000 (17:28 +0100)] 
bpo-39542: Move object.h debug functions to internal C API (GH-18331)

Move the following functions from the public C API to the internal C
API:

* _PyDebug_PrintTotalRefs(),
* _Py_PrintReferenceAddresses()
* _Py_PrintReferences()

5 years agobpo-39489: Remove COUNT_ALLOCS special build (GH-18259)
Victor Stinner [Mon, 3 Feb 2020 14:17:15 +0000 (15:17 +0100)] 
bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)

Remove:

* COUNT_ALLOCS macro
* sys.getcounts() function
* SHOW_ALLOC_COUNT code in listobject.c
* SHOW_TRACK_COUNT code in tupleobject.c
* PyConfig.show_alloc_count field
* -X showalloccount command line option
* @test.support.requires_type_collecting decorator

5 years agobpo-36051: Fix compiler warning. (GH-18325)
Inada Naoki [Mon, 3 Feb 2020 10:03:34 +0000 (19:03 +0900)] 
bpo-36051: Fix compiler warning. (GH-18325)

5 years agobpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescripti...
Steve Cirelli [Mon, 3 Feb 2020 07:06:50 +0000 (02:06 -0500)] 
bpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescription (GH-18175)

5 years agobpo-39492: Fix a reference cycle between reducer_override and a Pickler instance...
Pierre Glaser [Sun, 2 Feb 2020 18:55:21 +0000 (19:55 +0100)] 
bpo-39492: Fix a reference cycle between reducer_override and a Pickler instance (GH-18266)

This also needs a backport to 3.8

https://bugs.python.org/issue39492

Automerge-Triggered-By: @pitrou
5 years agobpo-39349: Add *cancel_futures* to Executor.shutdown() (GH-18057)
Kyle Stanley [Sun, 2 Feb 2020 12:49:00 +0000 (07:49 -0500)] 
bpo-39349: Add *cancel_futures* to Executor.shutdown() (GH-18057)

5 years agoFix 5-space indentation and trailing whitespace (GH-18311)
Mark Dickinson [Sun, 2 Feb 2020 11:37:02 +0000 (11:37 +0000)] 
Fix 5-space indentation and trailing whitespace (GH-18311)

5 years agobpo-39496: Remove redundant checks from _sqlite/cursor.c (GH-18270)
Alex Henrie [Sat, 1 Feb 2020 20:45:34 +0000 (13:45 -0700)] 
bpo-39496: Remove redundant checks from _sqlite/cursor.c (GH-18270)

5 years agofixes typos in http.client documentation (#18300)
James Corbett [Sat, 1 Feb 2020 12:31:00 +0000 (04:31 -0800)] 
fixes typos in http.client documentation (#18300)

5 years agobpo-34793: Drop old-style context managers in asyncio.locks (GH-17533)
Andrew Svetlov [Sat, 1 Feb 2020 11:12:52 +0000 (13:12 +0200)] 
bpo-34793: Drop old-style context managers in asyncio.locks (GH-17533)

5 years agoUpdate sum comment. (#18240)
Brandt Bucher [Sat, 1 Feb 2020 11:08:34 +0000 (03:08 -0800)] 
Update sum comment. (#18240)

5 years agobpo-39511: PyThreadState_Clear() calls on_delete (GH-18296)
Victor Stinner [Sat, 1 Feb 2020 01:30:25 +0000 (02:30 +0100)] 
bpo-39511: PyThreadState_Clear() calls on_delete (GH-18296)

PyThreadState.on_delete is a callback used to notify Python when a
thread completes. _thread._set_sentinel() function creates a lock
which is released when the thread completes. It sets on_delete
callback to the internal release_sentinel() function. This lock is
known as Threading._tstate_lock in the threading module.

The release_sentinel() function uses the Python C API. The problem is
that on_delete is called late in the Python finalization, when the C
API is no longer fully working.

The PyThreadState_Clear() function now calls the
PyThreadState.on_delete callback. Previously, that happened in
PyThreadState_Delete().

The release_sentinel() function is now called when the C API is still
fully working.

5 years agobpo-39511: Fix multiprocessing semlock_acquire() (GH-18298)
Victor Stinner [Sat, 1 Feb 2020 00:25:59 +0000 (01:25 +0100)] 
bpo-39511: Fix multiprocessing semlock_acquire() (GH-18298)

The Python C API must not be used when the GIL is released: only
access Py_None when the GIL is hold.

5 years agobpo-37224: Improve test__xxsubinterpreters.DestroyTests (GH-18058)
Kyle Stanley [Fri, 31 Jan 2020 20:07:09 +0000 (15:07 -0500)] 
bpo-37224: Improve test__xxsubinterpreters.DestroyTests (GH-18058)

Adds an additional assertion check based on a race condition for `test__xxsubinterpreters.DestroyTests.test_still_running` discovered in the bpo issue.

https://bugs.python.org/issue37224

5 years agoDoc: Fix s/pseudo random/pseudo-random/ (GH-18289)
Julien Palard [Fri, 31 Jan 2020 09:50:14 +0000 (10:50 +0100)] 
Doc: Fix s/pseudo random/pseudo-random/ (GH-18289)

5 years agobpo-38792: Remove IDLE shell calltip before new prompt. (#17150)
Zackery Spytz [Fri, 31 Jan 2020 01:55:42 +0000 (18:55 -0700)] 
bpo-38792: Remove IDLE shell calltip before new prompt. (#17150)

Previously, a calltip might be left after SyntaxError, KeyboardInterrupt, or Shell Restart.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tal Einat <taleinat+github@gmail.com>
5 years agobpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)
Hai Shi [Thu, 30 Jan 2020 23:20:25 +0000 (17:20 -0600)] 
bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)

Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.

5 years agobpo-39502: Skip test_zipfile.test_add_file_after_2107() on AIX (GH-18282)
Victor Stinner [Thu, 30 Jan 2020 14:47:53 +0000 (15:47 +0100)] 
bpo-39502: Skip test_zipfile.test_add_file_after_2107() on AIX (GH-18282)

Skip test_zipfile.test_add_file_after_2107() if time.localtime()
fails with OverflowError. It is the case on AIX 6.1 for example.

5 years agobpo-39434: Improve float __floordiv__ performance and error message (GH-18147)
Dong-hee Na [Thu, 30 Jan 2020 13:23:15 +0000 (22:23 +0900)] 
bpo-39434: Improve float __floordiv__ performance and error message (GH-18147)

5 years agobpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)
Victor Stinner [Thu, 30 Jan 2020 12:09:11 +0000 (13:09 +0100)] 
bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)

Add _Py_NO_RETURN to functions calling Py_FatalError():

* _PyObject_AssertFailed()
* dummy_dealloc()
* faulthandler_fatal_error_thread()
* none_dealloc()
* notimplemented_dealloc()

5 years agobpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)
Victor Stinner [Thu, 30 Jan 2020 11:20:48 +0000 (12:20 +0100)] 
bpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)

Replace a few Py_FatalError() calls if tstate is NULL with
assert(tstate != NULL) in ceval.c.

PyEval_AcquireThread(), PyEval_ReleaseThread() and
PyEval_RestoreThread() must never be called with a NULL tstate.

5 years agobpo-38631: Avoid Py_FatalError() in unicodeobject.c (GH-18281)
Victor Stinner [Thu, 30 Jan 2020 11:18:32 +0000 (12:18 +0100)] 
bpo-38631: Avoid Py_FatalError() in unicodeobject.c (GH-18281)

Replace Py_FatalError() calls with _PyErr_WriteUnraisableMsg(),
_PyObject_ASSERT_FAILED_MSG() or Py_UNREACHABLE()
in unicode_dealloc() and unicode_release_interned().

5 years agobpo-39424: Use assertRaisesRegex instead of assertRaisesRegexp. (GH-18277)
damani42 [Thu, 30 Jan 2020 10:26:22 +0000 (11:26 +0100)] 
bpo-39424: Use assertRaisesRegex instead of assertRaisesRegexp. (GH-18277)

5 years agobpo-39497: Remove unused variable from pysqlite_cursor_executescript (GH-18271)
Alex Henrie [Thu, 30 Jan 2020 09:39:26 +0000 (02:39 -0700)] 
bpo-39497: Remove unused variable from pysqlite_cursor_executescript (GH-18271)

5 years agobpo-39353: binascii.crc_hqx() is no longer deprecated (GH-18276)
Victor Stinner [Thu, 30 Jan 2020 08:56:40 +0000 (09:56 +0100)] 
bpo-39353: binascii.crc_hqx() is no longer deprecated (GH-18276)

The binascii.crc_hqx() function is no longer deprecated.

5 years agobpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)
Victor Stinner [Thu, 30 Jan 2020 08:02:49 +0000 (09:02 +0100)] 
bpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)

tp_new_wrapper() now raises a SystemError if called with non-type
self, rather than calling Py_FatalError() which cannot be catched.

5 years agobpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)
Victor Stinner [Thu, 30 Jan 2020 08:02:14 +0000 (09:02 +0100)] 
bpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)

Rename init_slotdefs() to _PyTypes_InitSlotDefs() and add a return
value of type PyStatus. The function is now called exactly once from
_PyTypes_Init(). Replace calls to init_slotdefs() with an assertion
checking that slotdefs is initialized.

5 years agobpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() (GH-18258)
Victor Stinner [Thu, 30 Jan 2020 08:01:07 +0000 (09:01 +0100)] 
bpo-38631: Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() (GH-18258)

Replace Py_FatalError() with _PyObject_ASSERT_FAILED_MSG() in
object.c and typeobject.c to also dump the involved Python object on
a fatal error. It should ease debug when such fatal error occurs.

If the double linked list is inconsistent, _Py_ForgetReference() no
longer dumps previous and next objects in the fatal error, it now
only dumps the current object. It ensures that the error message
is displayed even if dumping the object does crash Python.

Enhance _Py_ForgetReference() error messages;
_PyObject_ASSERT_FAILED_MSG() logs the "_Py_ForgetReference" function
name.

5 years agobpo-39494: Remove extra null terminators from kwlist vars (GH-18267)
Alex Henrie [Thu, 30 Jan 2020 04:12:53 +0000 (21:12 -0700)] 
bpo-39494: Remove extra null terminators from kwlist vars (GH-18267)

5 years agobpo-39493: Fix definition of IO.closed in typing.py (#18265)
Shantanu [Thu, 30 Jan 2020 02:52:36 +0000 (18:52 -0800)] 
bpo-39493: Fix definition of IO.closed in typing.py (#18265)

5 years agoImprove grammar in the import system reference documentation (GH-18209)
Bonifacio de Oliveira [Thu, 30 Jan 2020 02:23:50 +0000 (23:23 -0300)] 
Improve grammar in the import system reference documentation (GH-18209)

Replaced the period with a comma.

Automerge-Triggered-By: @Mariatta
5 years agoRemove deadcode in _Py_inc_count() (GH-18257)
Victor Stinner [Wed, 29 Jan 2020 18:22:11 +0000 (19:22 +0100)] 
Remove deadcode in _Py_inc_count() (GH-18257)

(tp->tp_next != NULL) check became redundant with
commit 45294a9562e5c360ee8ef8498d8792e05a6eb25e (merged in 2006).

5 years agoGet mock coverage back to 100% (GH-18228)
Chris Withers [Wed, 29 Jan 2020 16:24:54 +0000 (16:24 +0000)] 
Get mock coverage back to 100% (GH-18228)

* use the `: pass` and `: yield` patterns for code that isn't expected to ever be executed.

* The _Call items passed to _AnyComparer are only ever of length two, so assert instead of if/else

* fix typo

* Fix bug, where stop-without-start patching dict blows up with `TypeError: 'NoneType' object is not iterable`, highlighted by lack of coverage of an except branch.

* The fix for bpo-37972 means _Call.count and _Call.index are no longer needed.

* add coverage for calling next() on a mock_open with readline.return_value set.

* __aiter__ is defined on the Mock so the one on _AsyncIterator is never called.

5 years agobpo-39485: fix corner-case in method-detection of mock (GH-18252)
Carl Friedrich Bolz-Tereick [Wed, 29 Jan 2020 15:43:37 +0000 (16:43 +0100)] 
bpo-39485: fix corner-case in method-detection of mock (GH-18252)

Replace check for whether something is a method in the mock module. The
previous version fails on PyPy, because there no method wrappers exist
(everything looks like a regular Python-defined function). Thus the
isinstance(getattr(result, '__get__', None), MethodWrapperTypes) check
returns True for any descriptor, not just methods.

This condition could also return erroneously True in CPython for
C-defined descriptors.

Instead to decide whether something is a method, just check directly
whether it's a function defined on the class. This passes all tests on
CPython and fixes the bug on PyPy.

5 years agobpo-39460: Fix test_zipfile.test_add_file_after_2107() (GH-18247)
Victor Stinner [Wed, 29 Jan 2020 14:23:29 +0000 (15:23 +0100)] 
bpo-39460: Fix test_zipfile.test_add_file_after_2107() (GH-18247)

XFS filesystem is limited to 32-bit timestamp, but the utimensat()
syscall doesn't fail. Moreover, there is a VFS bug which returns
a cached timestamp which is different than the value on disk.

https://bugzilla.redhat.com/show_bug.cgi?id=1795576
https://bugs.python.org/issue39460#msg360952

5 years agoDoc: Fix external links to functional programming tutorial. (GH-18249)
Julien Palard [Wed, 29 Jan 2020 13:10:54 +0000 (14:10 +0100)] 
Doc: Fix external links to functional programming tutorial. (GH-18249)

5 years agobpo-39153: Clarify C API *SetItem refcounting semantics (GH-18220)
Joannah Nanjekye [Wed, 29 Jan 2020 11:20:53 +0000 (07:20 -0400)] 
bpo-39153: Clarify C API *SetItem refcounting semantics (GH-18220)

Some of the *SetItem methods in the C API steal a reference to the
given value. This annotates the better behaved ones to assure the
reader that these are not the ones with the inconsistent behaviour.

* ðŸ“œðŸ¤– Added by blurb_it.

* make docs consistent with signature

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 years agobpo-36051: Drop GIL during large bytes.join() (GH-17757)
Bruce Merry [Wed, 29 Jan 2020 07:09:24 +0000 (09:09 +0200)] 
bpo-36051: Drop GIL during large bytes.join() (GH-17757)

Improve multi-threaded performance by dropping the GIL in the fast path
of bytes.join. To avoid increasing overhead for small joins, it is only
done if the output size exceeds a threshold.

5 years agobpo-39401: Avoid unsafe DLL load on Windows 7 and earlier (GH-18231)
Steve Dower [Wed, 29 Jan 2020 02:46:33 +0000 (13:46 +1100)] 
bpo-39401: Avoid unsafe DLL load on Windows 7 and earlier (GH-18231)

As Windows 7 is not supported by Python 3.9, we just replace the dynamic load with a static import. Backports will have a different fix to ensure they continue to behave the same.

5 years agobpo-39459: include missing test files in windows installer
Dino Viehland [Tue, 28 Jan 2020 21:24:12 +0000 (13:24 -0800)] 
bpo-39459: include missing test files in windows installer

Adds missing test files to Windows installer to wrap up bpo-39459

5 years agobpo-38960: DTrace build fix for FreeBSD. (GH-17451)
David Carlier [Tue, 28 Jan 2020 12:53:32 +0000 (12:53 +0000)] 
bpo-38960: DTrace build fix for FreeBSD. (GH-17451)

DTrace build fix for FreeBSD.

- allowing passing an extra flag as it need to define the arch size.
- casting some probe's arguments.

5 years agobpo-36350: inspect: Replace OrderedDict with dict. (GH-12412)
Rémi Lapeyre [Tue, 28 Jan 2020 12:47:03 +0000 (13:47 +0100)] 
bpo-36350: inspect: Replace OrderedDict with dict. (GH-12412)

5 years agobpo-39439: Fix multiprocessing spawn path in a venv on Windows (GH-18158)
Adam Meily [Tue, 28 Jan 2020 10:34:23 +0000 (05:34 -0500)] 
bpo-39439: Fix multiprocessing spawn path in a venv on Windows (GH-18158)

5 years agobpo-39287: Doc: Add UTF-8 mode section in using/windows. (GH-17935)
Inada Naoki [Tue, 28 Jan 2020 10:12:31 +0000 (19:12 +0900)] 
bpo-39287: Doc: Add UTF-8 mode section in using/windows. (GH-17935)

Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
5 years agobpo-39393: Misleading error message on dependent DLL resolution failure (GH-18093)
Zackery Spytz [Tue, 28 Jan 2020 09:42:43 +0000 (02:42 -0700)] 
bpo-39393: Misleading error message on dependent DLL resolution failure (GH-18093)

5 years agobpo-38883: Don't use POSIX `$HOME` in `pathlib.Path.home/expanduser` on Windows ...
Christoph Reiter [Tue, 28 Jan 2020 09:41:50 +0000 (10:41 +0100)] 
bpo-38883: Don't use POSIX `$HOME` in `pathlib.Path.home/expanduser` on Windows (GH-17961)

In bpo-36264 os.path.expanduser was changed to ignore HOME on Windows.

Path.expanduser/home still honored HOME despite being documented as behaving the same
as os.path.expanduser. This makes them also ignore HOME so that both implementations
behave the same way again.

5 years agobpo-38644: Pass tstate in ceval.c (GH-18222)
Victor Stinner [Tue, 28 Jan 2020 02:37:45 +0000 (03:37 +0100)] 
bpo-38644: Pass tstate in ceval.c (GH-18222)

Pass explicitly the Python thread state (tstate) in ceval.c.

5 years agobpo-36018: Minor fixes to the NormalDist() examples and recipes. (GH-18226)
Raymond Hettinger [Tue, 28 Jan 2020 02:31:46 +0000 (18:31 -0800)] 
bpo-36018: Minor fixes to the NormalDist() examples and recipes. (GH-18226)

* Change the source for the SAT data to a primary source.
* Fix typo in the standard deviation
* Clarify that the binomial probabalities are just for the Python room.

5 years agobpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221)
Brian Quinlan [Tue, 28 Jan 2020 00:50:37 +0000 (16:50 -0800)] 
bpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221)

5 years agobpo-39392: Turtle overlap fill depends on OS (#18223)
Terry Jan Reedy [Mon, 27 Jan 2020 23:41:18 +0000 (18:41 -0500)] 
bpo-39392: Turtle overlap fill depends on OS (#18223)

Whether or not overlap regions for self-intersecting polygons
or multiple shapes are filled depends on the operating system graphics,
typeof overlap, and number of overlaps.

5 years agobpo-38631: Avoid Py_FatalError() in PyCode_New() (GH-18215)
Victor Stinner [Mon, 27 Jan 2020 22:24:13 +0000 (23:24 +0100)] 
bpo-38631: Avoid Py_FatalError() in PyCode_New() (GH-18215)

intern_strings() now raises a SystemError, rather than calling
Py_FatalError().

intern_string_constants() now reports exceptions to the caller,
rather than ignoring silently exceptions.

5 years agobpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() (GH-18217)
Victor Stinner [Mon, 27 Jan 2020 22:23:12 +0000 (23:23 +0100)] 
bpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() (GH-18217)

_PyCodecRegistry_Init() now reports exceptions to the caller,
rather than calling Py_FatalError().

5 years agobpo-30780: Add IDLE configdialog tests (#3592)
Cheryl Sabella [Mon, 27 Jan 2020 22:15:56 +0000 (17:15 -0500)] 
bpo-30780: Add IDLE configdialog tests (#3592)

Expose dialog buttons to test code and complete their test coverage.
Complete test coverage for highlights and keys tabs.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
5 years agoAdd test.test_import.data.unwritable package to makefile (#18211)
Dino Viehland [Mon, 27 Jan 2020 22:04:56 +0000 (14:04 -0800)] 
Add test.test_import.data.unwritable package to makefile (#18211)

5 years agobpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)
Victor Stinner [Mon, 27 Jan 2020 21:37:44 +0000 (22:37 +0100)] 
bpo-38631: Avoid Py_FatalError() in _memory_release() (GH-18214)

If the export count is negative, _memory_release() now raises a
SystemError and returns -1, rather than calling Py_FatalError()
which aborts the process.

5 years agobpo-38631: Avoid Py_FatalError() in PyModule_Create2() (GH-18212)
Victor Stinner [Mon, 27 Jan 2020 21:37:05 +0000 (22:37 +0100)] 
bpo-38631: Avoid Py_FatalError() in PyModule_Create2() (GH-18212)

If PyModule_Create2() is called when the Python import machinery is
not initialized, it now raises a SystemError and returns NULL,
instead of calling Py_FatalError() which aborts the process.

The caller must be prepared to handle NULL anyway.

5 years agobpo-39459: test.pythoninfo logs effective uid/gid (GH-18203)
Victor Stinner [Mon, 27 Jan 2020 17:06:42 +0000 (18:06 +0100)] 
bpo-39459: test.pythoninfo logs effective uid/gid (GH-18203)

Fix also umask formatting: use octal prefix.

5 years agobpo-39453: Add testcase for bpo-39453 (GH-18202)
Dong-hee Na [Mon, 27 Jan 2020 17:04:25 +0000 (02:04 +0900)] 
bpo-39453: Add testcase for bpo-39453 (GH-18202)

https://bugs.python.org/issue39453

Automerge-Triggered-By: @pablogsal
Automerge-Triggered-By: @pablogsal