]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
5 years agobpo-35134: Add Include/cpython/bytesobject.h file (GH-18494)
Victor Stinner [Wed, 12 Feb 2020 22:54:31 +0000 (23:54 +0100)] 
bpo-35134: Add Include/cpython/bytesobject.h file (GH-18494)

Add Include/cpython/bytearrayobject.h and
Include/cpython/bytesobject.h header files.

Move CPython C API from Include/bytesobject.h into a new
Include/cpython/bytesobject.h header file which is included by
Include/bytesobject.h. Do a similar change for
Include/bytearrayobject.h.

5 years agobpo-35081: Move dtoa.h header to the internal C API (GH-18489)
Victor Stinner [Wed, 12 Feb 2020 21:54:42 +0000 (22:54 +0100)] 
bpo-35081: Move dtoa.h header to the internal C API (GH-18489)

Move the dtoa.h header file to the internal C API as pycore_dtoa.h:
it only contains private functions (prefixed by "_Py").

The math and cmath modules must now be compiled with the
Py_BUILD_CORE macro defined.

5 years agobpo-35081: Move bytes_methods.h to the internal C API (GH-18492)
Victor Stinner [Wed, 12 Feb 2020 21:32:34 +0000 (22:32 +0100)] 
bpo-35081: Move bytes_methods.h to the internal C API (GH-18492)

Move the bytes_methods.h header file to the internal C API as
pycore_bytes_methods.h: it only contains private symbols (prefixed by
"_Py"), except of the PyDoc_STRVAR_shared() macro.

5 years agobpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477)
Serhiy Storchaka [Wed, 12 Feb 2020 20:37:49 +0000 (22:37 +0200)] 
bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477)

5 years agobpo-18819: tarfile: only set device fields for device files (GH-18080)
William Chargin [Wed, 12 Feb 2020 19:56:02 +0000 (11:56 -0800)] 
bpo-18819: tarfile: only set device fields for device files (GH-18080)

The GNU docs describe the `devmajor` and `devminor` fields of the tar
header struct only in the context of character and block special files,
suggesting that in other cases they are not populated. Typical utilities
behave accordingly; this patch teaches `tarfile` to do the same.

5 years agobpo-21016: pydoc and trace use sysconfig (GH-18476)
Victor Stinner [Wed, 12 Feb 2020 12:02:29 +0000 (13:02 +0100)] 
bpo-21016: pydoc and trace use sysconfig (GH-18476)

bpo-21016, bpo-1294959: The pydoc and trace modules now use the
sysconfig module to get the path to the Python standard library, to
support uncommon installation path like /usr/lib64/python3.9/ on
Fedora.

Co-Authored-By: Jan Matฤ›jek <jmatejek@suse.com>
5 years agobpo-32856: Optimize the assignment idiom in comprehensions. (GH-16814)
Serhiy Storchaka [Wed, 12 Feb 2020 10:18:59 +0000 (12:18 +0200)] 
bpo-32856: Optimize the assignment idiom in comprehensions. (GH-16814)

Now `for y in [expr]` in comprehensions is as fast as a simple
assignment `y = expr`.

5 years agobpo-39219: Fix SyntaxError attributes in the tokenizer. (GH-17828)
Serhiy Storchaka [Wed, 12 Feb 2020 10:17:00 +0000 (12:17 +0200)] 
bpo-39219: Fix SyntaxError attributes in the tokenizer. (GH-17828)

* Always set the text attribute.
* Correct the offset attribute for non-ascii sources.

5 years agobpo-39567: Add audit for os.walk(), os.fwalk(), Path.glob() and Path.rglob(). (GH...
Serhiy Storchaka [Wed, 12 Feb 2020 10:11:34 +0000 (12:11 +0200)] 
bpo-39567: Add audit for os.walk(), os.fwalk(), Path.glob() and Path.rglob(). (GH-18372)

5 years agobpo-39605: Remove a cast that causes a warning. (GH-18473)
Benjamin Peterson [Wed, 12 Feb 2020 03:36:14 +0000 (19:36 -0800)] 
bpo-39605: Remove a cast that causes a warning. (GH-18473)

5 years agobpo-39595: Improve zipfile.Path performance (#18406)
Jason R. Coombs [Wed, 12 Feb 2020 02:58:47 +0000 (21:58 -0500)] 
bpo-39595: Improve zipfile.Path performance (#18406)

* Improve zipfile.Path performance on zipfiles with a large number of entries.

* ๐Ÿ“œ๐Ÿค– Added by blurb_it.

* Add bpo to blurb

* Sync with importlib_metadata 1.5 (6fe70ca)

* Update blurb.

* Remove compatibility code

* Add stubs module, omitted from earlier commit

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 years agocloses bpo-39605: Fix some casts to not cast away const. (GH-18453)
Andy Lester [Wed, 12 Feb 2020 02:28:35 +0000 (20:28 -0600)] 
closes bpo-39605: Fix some casts to not cast away const. (GH-18453)

gcc -Wcast-qual turns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either:

Adding the const to the type cast, as in:

-    return _PyUnicode_FromUCS1((unsigned char*)s, size);
+    return _PyUnicode_FromUCS1((const unsigned char*)s, size);

or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in:

-    PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno);
+    PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno);

These changes will not change code, but they will make it much easier to check for errors in consts

5 years agodocs: macos - change "versiona" to "versions" (GH-18467)
@RandyMcMillan [Wed, 12 Feb 2020 01:20:05 +0000 (20:20 -0500)] 
docs: macos - change "versiona" to "versions" (GH-18467)

5 years agoFix ordering issue in Windows release upload script (GH-18465)
Steve Dower [Tue, 11 Feb 2020 17:32:52 +0000 (17:32 +0000)] 
Fix ordering issue in Windows release upload script (GH-18465)

Automerge-Triggered-By: @zooba
5 years agobpo-38644: Rephrase What's New entry (GH-18461)
Victor Stinner [Tue, 11 Feb 2020 16:50:10 +0000 (17:50 +0100)] 
bpo-38644: Rephrase What's New entry (GH-18461)

5 years agobpo-39245: Switch to public API for Vectorcall (GH-18460)
Petr Viktorin [Tue, 11 Feb 2020 16:46:57 +0000 (17:46 +0100)] 
bpo-39245: Switch to public API for Vectorcall (GH-18460)

The bulk of this patch was generated automatically with:

    for name in \
        PyObject_Vectorcall \
        Py_TPFLAGS_HAVE_VECTORCALL \
        PyObject_VectorcallMethod \
        PyVectorcall_Function \
        PyObject_CallOneArg \
        PyObject_CallMethodNoArgs \
        PyObject_CallMethodOneArg \
    ;
    do
        echo $name
        git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g"
    done

    old=_PyObject_FastCallDict
    new=PyObject_VectorcallDict
    git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g"

and then cleaned up:

- Revert changes to in docs & news
- Revert changes to backcompat defines in headers
- Nudge misaligned comments

5 years agobpo-39500: Document PyUnicode_IsIdentifier() function (GH-18397)
Victor Stinner [Tue, 11 Feb 2020 13:29:33 +0000 (14:29 +0100)] 
bpo-39500: Document PyUnicode_IsIdentifier() function (GH-18397)

PyUnicode_IsIdentifier() does not call Py_FatalError() anymore if the
string is not ready.

5 years agobpo-1635741: Port _codecs extension module to multiphase initialization (PEP 489...
Hai Shi [Tue, 11 Feb 2020 11:16:38 +0000 (05:16 -0600)] 
bpo-1635741: Port _codecs extension module to multiphase initialization (PEP 489) (GH-18065)

https://bugs.python.org/issue1635741

5 years agobpo-38374: Remove weakref.ReferenceError from docs (GH-18452)
Roger Hurwitz [Tue, 11 Feb 2020 06:56:02 +0000 (22:56 -0800)] 
bpo-38374: Remove weakref.ReferenceError from docs (GH-18452)

Reflecting changes to the code, removed weakref.ReferenceError from weakref.rst and exceptions.rst.

Issue submitter provided evidence that the `weakref.ReferenceError` alias for `ReferenceError` was removed from the code in 2007.  Working with @gvanrossum at PyCascades CPython sprint we looked at the code and confirmed that `weakref.ReferenceError` was no longer in `weakref.py`.

Based on that analysis I removed references `weakref.ReferenceError` from the two documents where it was still being referenced: `weakref.rst` and `exceptions.rst`.

https://bugs.python.org/issue38374

5 years agobpo-39600: Adjust code, add idlelib/NEWS item (GH-18449)
Terry Jan Reedy [Tue, 11 Feb 2020 01:08:58 +0000 (20:08 -0500)] 
bpo-39600: Adjust code, add idlelib/NEWS item (GH-18449)

Complete previous patch.

5 years agobpo-38325: Skip non-BMP tests of test_winconsoleio (GH-18448)
Victor Stinner [Mon, 10 Feb 2020 23:58:23 +0000 (00:58 +0100)] 
bpo-38325: Skip non-BMP tests of test_winconsoleio (GH-18448)

Skip tests on non-BMP characters of test_winconsoleio.

5 years agobpo-39417: Fix broken link to guide to building venvs (GH-18432)
Ogi Moore [Mon, 10 Feb 2020 23:51:01 +0000 (15:51 -0800)] 
bpo-39417: Fix broken link to guide to building venvs (GH-18432)

5 years agoCorrect the documented default encoding (GH-18429)
Eric Wieser [Mon, 10 Feb 2020 23:32:18 +0000 (23:32 +0000)] 
Correct the documented default encoding (GH-18429)

From the source for `PyUnicode_Decode`, the implementation is:
```
if (encoding == NULL) {
    return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
}
```
which is pretty clearly not defaulting to ASCII.

---

I assume this needs neither a news entry nor bpo link.

5 years agobpo-13826: Clarify Popen constructor example (GH-18438)
Tim D. Smith [Mon, 10 Feb 2020 22:51:01 +0000 (14:51 -0800)] 
bpo-13826: Clarify Popen constructor example (GH-18438)

Clarifies that the use of `shlex.split` is more instructive than
normative, and provides a simpler example.

https://bugs.python.org/issue13826

5 years agobpo-39594: Fix typo in os.times documentation (GH-18443)
Roger Hurwitz [Mon, 10 Feb 2020 22:50:19 +0000 (14:50 -0800)] 
bpo-39594: Fix typo in os.times documentation (GH-18443)

There was an extra space in the url markup, causing the documentation not rendered properly.

https://bugs.python.org/issue39594

5 years agoIssue3950: Fix docs for default locale used by gettext to match implementation (...
Carl [Mon, 10 Feb 2020 21:15:34 +0000 (13:15 -0800)] 
Issue3950: Fix docs for default locale used by gettext to match implementation (#18435)

documentation for default locale directory Doc/library/gettext.rst changed to match gettext implementation line 63.

5 years agoRemove redundant references in struct doc (GH-18053)
Christophe Nanteuil [Mon, 10 Feb 2020 20:17:54 +0000 (21:17 +0100)] 
Remove redundant references in struct doc (GH-18053)

5 years agobpo-39369 Doc: Update mmap readline method documentation (GH-17957)
Wellington Pardim [Mon, 10 Feb 2020 20:13:41 +0000 (17:13 -0300)] 
bpo-39369 Doc: Update mmap readline method documentation (GH-17957)

* Update mmap readline method documentation

Update mmap `readline` method description. The fact that the `readline` method does update the file position should not be ignored since this might give the impression for the programmer that it doesn't update it.

* ๐Ÿ“œ๐Ÿค– Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
5 years agobpo-39600, IDLE: Remove duplicated font names (GH-18430)
Victor Stinner [Mon, 10 Feb 2020 19:41:26 +0000 (20:41 +0100)] 
bpo-39600, IDLE: Remove duplicated font names (GH-18430)

In the font configuration window, remove duplicated font names.

5 years agoRemove note saying patch is straightforward (#18431)
Brian Curtin [Mon, 10 Feb 2020 17:47:17 +0000 (10:47 -0700)] 
Remove note saying patch is straightforward (#18431)

While `unittest.mock.patch` is a great thing, it is not straightforward.
If it were straightforward there wouldn't be such a huge amount of
documentation for it, and frankly, when myself and others who I've
read about often struggle to figure out what on earth `patch()` wants,
coming to the docs to read that it's straightforward is not helpful.

5 years agobpo-39586: Deprecate distutils bdist_msi command (GH-18415)
Hugo van Kemenade [Mon, 10 Feb 2020 13:26:40 +0000 (15:26 +0200)] 
bpo-39586: Deprecate distutils bdist_msi command (GH-18415)

5 years agobpo-39128: Added happy_eyeballs_delay, interleave to function signature (GH-18315)
idomic [Mon, 10 Feb 2020 09:48:40 +0000 (04:48 -0500)] 
bpo-39128: Added happy_eyeballs_delay, interleave to function signature (GH-18315)

5 years agoGrammar fix in tutorial (GH-18425)
Don Kirkby [Mon, 10 Feb 2020 00:57:46 +0000 (16:57 -0800)] 
Grammar fix in tutorial (GH-18425)

5 years agobpo-39590: make deque.__contains__ and deque.count hold strong references (GH-18421)
sweeneyde [Sun, 9 Feb 2020 08:16:43 +0000 (03:16 -0500)] 
bpo-39590: make deque.__contains__ and deque.count hold strong references (GH-18421)

5 years agobpo-39573: Use Py_TYPE() macro in ctypes.h (GH-18411)
Dong-hee Na [Sat, 8 Feb 2020 23:45:52 +0000 (08:45 +0900)] 
bpo-39573: Use Py_TYPE() macro in ctypes.h (GH-18411)

5 years agoDoc: sys.__unraisablehook__ and bytearray.hex separators are new in 3.8 (GH-17884)
Saiyang Gou [Sat, 8 Feb 2020 00:48:06 +0000 (16:48 -0800)] 
Doc: sys.__unraisablehook__ and bytearray.hex separators are new in 3.8 (GH-17884)

Minor fix in documentation:

- `sys.__unraisablehook__` is new in version 3.8
- Optional `sep` and `bytes_per_sep` parameters for `bytearray.hex` is also supported in Python 3.8 (just like `bytes.hex`)

5 years agocloses bpo-39575: Change -lgcov to --coverage. (GH-18382)
Fangrui Song [Fri, 7 Feb 2020 23:46:29 +0000 (15:46 -0800)] 
closes bpo-39575: Change -lgcov to --coverage. (GH-18382)

This allows clang to get rid of the dependency on libgcov.
When linking, GCC passes -lgcov while clang passes the path to libclang_rt.profile-$arch.a

5 years agobpo-39579: Fix Attribute end_col_offset to point at the current node (GH-18405)
Lysandros Nikolaou [Fri, 7 Feb 2020 23:36:32 +0000 (00:36 +0100)] 
bpo-39579: Fix Attribute end_col_offset to point at the current node (GH-18405)

5 years agobpo-39350: Fix fractions for int subclasses (GH-18375)
Victor Stinner [Fri, 7 Feb 2020 22:42:51 +0000 (23:42 +0100)] 
bpo-39350: Fix fractions for int subclasses (GH-18375)

Fix regression in fractions.Fraction if the numerator and/or the
denominator is an int subclass. The math.gcd() function is now
used to normalize the numerator and denominator. math.gcd() always
return a int type. Previously, the GCD type depended on numerator
and denominator.

5 years agobpo-39573: Use Py_SET_SIZE() function (GH-18402)
Victor Stinner [Fri, 7 Feb 2020 22:18:08 +0000 (23:18 +0100)] 
bpo-39573: Use Py_SET_SIZE() function (GH-18402)

Replace direct acccess to PyVarObject.ob_size with usage of
the Py_SET_SIZE() function.

5 years agobpo-39502: Fix 64-bit Python PyTime_localtime() on AIX (GH-18285)
Michael Felt [Fri, 7 Feb 2020 17:56:16 +0000 (18:56 +0100)] 
bpo-39502: Fix 64-bit Python PyTime_localtime() on AIX  (GH-18285)

Fix time.localtime() on 64-bit AIX to support years before 1902 and after 2038.

5 years agobpo-39573: Add Py_SET_SIZE() function (GH-18400)
Victor Stinner [Fri, 7 Feb 2020 11:05:12 +0000 (12:05 +0100)] 
bpo-39573: Add Py_SET_SIZE() function (GH-18400)

Add Py_SET_SIZE() function to set the size of an object.

5 years agobpo-38644: Add Py_EnterRecursiveCall() to python3.def (GH-18399)
Victor Stinner [Fri, 7 Feb 2020 10:22:54 +0000 (11:22 +0100)] 
bpo-38644: Add Py_EnterRecursiveCall() to python3.def (GH-18399)

Add Py_EnterRecursiveCall and Py_LeaveRecursiveCall functions to
python3.def.

5 years agobpo-39573: Use Py_TYPE() macro in object.c (GH-18398)
Victor Stinner [Fri, 7 Feb 2020 10:18:33 +0000 (11:18 +0100)] 
bpo-39573: Use Py_TYPE() macro in object.c (GH-18398)

Replace direct acccess to PyVarObject.ob_size with usage of the
Py_SIZE() macro.

5 years agobpo-35134: Create Include/cpython/listobject.h (GH-18395)
Victor Stinner [Fri, 7 Feb 2020 08:20:22 +0000 (09:20 +0100)] 
bpo-35134: Create Include/cpython/listobject.h (GH-18395)

Move listobject.h code surrounded by "#ifndef Py_LIMITED_API"
to a new Include/cpython/listobject.h header file.

Add cpython/ header files to Makefile.pre.in and pythoncore project
of PCbuild.

Add _PyList_CAST() macro.

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.