]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
5 years agobpo-1635741: Add PyModule_AddObjectRef() function (GH-23122)
Victor Stinner [Wed, 4 Nov 2020 12:59:15 +0000 (13:59 +0100)] 
bpo-1635741: Add PyModule_AddObjectRef() function (GH-23122)

Added PyModule_AddObjectRef() function: similar to
PyModule_AddObjectRef() but don't steal a reference to the value on
success.

5 years agobpo-42236: os.device_encoding() respects UTF-8 Mode (GH-23119)
Victor Stinner [Wed, 4 Nov 2020 10:20:10 +0000 (11:20 +0100)] 
bpo-42236: os.device_encoding() respects UTF-8 Mode (GH-23119)

On Unix, the os.device_encoding() function now returns 'UTF-8' rather
than the device encoding if the Python UTF-8 Mode is enabled.

5 years agobpo-42251: Add gettrace and getprofile to threading (GH-23125)
Mario Corchero [Wed, 4 Nov 2020 09:27:43 +0000 (10:27 +0100)] 
bpo-42251: Add gettrace and getprofile to threading (GH-23125)

This allows to retrieve the functions that were set in these two, which might differ from sys.gettrace and sys.getprofile within a thread.

5 years agoEnable signing of nuget.org packages and update to supported timestamp server (GH...
Steve Dower [Tue, 3 Nov 2020 22:31:49 +0000 (22:31 +0000)] 
Enable signing of nuget.org packages and update to supported timestamp server (GH-23132)

5 years agoFix incorrect links in ast docs (GH-23017)
Matthew Suozzo [Tue, 3 Nov 2020 21:28:42 +0000 (16:28 -0500)] 
Fix incorrect links in ast docs (GH-23017)

5 years agoAdd _PyType_GetModuleByDef (GH-22835)
Petr Viktorin [Tue, 3 Nov 2020 21:27:12 +0000 (22:27 +0100)] 
Add _PyType_GetModuleByDef (GH-22835)

See https://mail.python.org/archives/list/capi-sig@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU/ for discussion.

https://bugs.python.org/issue42100

5 years agoPost 3.10.0a2
Pablo Galindo [Tue, 3 Nov 2020 17:31:32 +0000 (17:31 +0000)] 
Post 3.10.0a2

5 years agoMerge tag 'v3.10.0a2' into master
Pablo Galindo [Tue, 3 Nov 2020 17:30:57 +0000 (17:30 +0000)] 
Merge tag 'v3.10.0a2' into master

Python 3.10.0a2

5 years agobpo-41796: Call _PyAST_Fini() earlier to fix a leak (GH-23131)
Victor Stinner [Tue, 3 Nov 2020 17:07:15 +0000 (18:07 +0100)] 
bpo-41796: Call _PyAST_Fini() earlier to fix a leak (GH-23131)

Call _PyAST_Fini() on all interpreters, not only on the main
interpreter. Also, call it ealier to fix a reference leak.

Python types contain a reference to themselves in in their
PyTypeObject.tp_mro member. _PyAST_Fini() must called before the last
GC collection to destroy AST types.

_PyInterpreterState_Clear() now calls _PyAST_Fini(). It now also
calls _PyWarnings_Fini() on subinterpeters, not only on the main
interpreter.

Add an assertion in AST init_types() to ensure that the _ast module
is no longer used after _PyAST_Fini() has been called.

5 years agobpo-42249: Fix writing binary Plist files larger than 4 GiB. (GH-23121)
Serhiy Storchaka [Tue, 3 Nov 2020 14:15:56 +0000 (16:15 +0200)] 
bpo-42249: Fix writing binary Plist files larger than 4 GiB. (GH-23121)

5 years agobpo-40077: Convert mmap.mmap static type to a heap type (GH-23108)
Erlend Egeberg Aasland [Tue, 3 Nov 2020 09:38:31 +0000 (10:38 +0100)] 
bpo-40077: Convert mmap.mmap static type to a heap type (GH-23108)

5 years agoPython 3.10.0a2 v3.10.0a2
Pablo Galindo [Tue, 3 Nov 2020 00:00:12 +0000 (00:00 +0000)] 
Python 3.10.0a2

5 years agobpo-35455: Fix thread_time for Solaris OS (GH-11118)
Jakub Kulík [Mon, 2 Nov 2020 23:10:01 +0000 (00:10 +0100)] 
bpo-35455: Fix thread_time for Solaris OS (GH-11118)

5 years agobpo-26789: Fix logging.FileHandler._open() at exit (GH-23053)
Victor Stinner [Mon, 2 Nov 2020 22:17:46 +0000 (23:17 +0100)] 
bpo-26789: Fix logging.FileHandler._open() at exit (GH-23053)

The logging.FileHandler class now keeps a reference to the builtin
open() function to be able to open or reopen the file during Python
finalization.

Fix errors like:

    Exception ignored in: (...)
    Traceback (most recent call last):
      (...)
      File ".../logging/__init__.py", line 1463, in error
      File ".../logging/__init__.py", line 1577, in _log
      File ".../logging/__init__.py", line 1587, in handle
      File ".../logging/__init__.py", line 1649, in callHandlers
      File ".../logging/__init__.py", line 948, in handle
      File ".../logging/__init__.py", line 1182, in emit
      File ".../logging/__init__.py", line 1171, in _open
    NameError: name 'open' is not defined

5 years agobpo-41796: Make _ast module state per interpreter (GH-23024)
Victor Stinner [Mon, 2 Nov 2020 21:03:28 +0000 (22:03 +0100)] 
bpo-41796: Make _ast module state per interpreter (GH-23024)

The ast module internal state is now per interpreter.

* Rename "astmodulestate" to "struct ast_state"
* Add pycore_ast.h internal header: the ast_state structure is now
  declared in pycore_ast.h.
* Add PyInterpreterState.ast (struct ast_state)
* Remove get_ast_state()
* Rename get_global_ast_state() to get_ast_state()
* PyAST_obj2mod() now handles get_ast_state() failures

5 years agobpo-42103: Improve validation of Plist files. (GH-22882)
Serhiy Storchaka [Mon, 2 Nov 2020 21:01:40 +0000 (23:01 +0200)] 
bpo-42103: Improve validation of Plist files. (GH-22882)

* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files.

5 years agobpo-41943: Fix bug where assertLogs doesn't correctly filter messages… (GH-22565)
Irit Katriel [Mon, 2 Nov 2020 19:25:29 +0000 (19:25 +0000)] 
bpo-41943: Fix bug where assertLogs doesn't correctly filter messages… (GH-22565)

… by level

@vsajip , @pitrou

Automerge-Triggered-By: GH:vsajip
5 years agoRevert "bpo-37193: remove thread objects which finished process its request (GH-13893...
Jason R. Coombs [Mon, 2 Nov 2020 16:48:56 +0000 (11:48 -0500)] 
Revert "bpo-37193: remove thread objects which finished process its request (GH-13893)" (GH-23107)

This reverts commit c41559021213cfc9dc62a83fc63306b3bdc3e64b.

5 years agobpo-42236: Enhance init and encoding documentation (GH-23109)
Victor Stinner [Mon, 2 Nov 2020 15:49:54 +0000 (16:49 +0100)] 
bpo-42236: Enhance init and encoding documentation (GH-23109)

Enhance the documentation of the Python startup, filesystem encoding
and error handling, locale encoding. Add a new "Python UTF-8 Mode"
section.

* Add "locale encoding" and "filesystem encoding and error handler"
  to the glossary
* Remove documentation from Include/cpython/initconfig.h: move it to
  Doc/c-api/init_config.rst.
* Doc/c-api/init_config.rst:

  * Document command line options and environment variables
  * Document default values.

* Add a new "Python UTF-8 Mode" section in Doc/library/os.rst.
* Add warnings to Py_DecodeLocale() and Py_EncodeLocale() docs.
* Document how Python selects the filesystem encoding and error
  handler at a single place: PyConfig.filesystem_encoding and
  PyConfig.filesystem_errors.
* PyConfig: move orig_argv member at the right place.

5 years agobpo-42224: Fix test_format when locale does not expect number grouping (GH-23067)
Lysandros Nikolaou [Mon, 2 Nov 2020 15:27:30 +0000 (17:27 +0200)] 
bpo-42224: Fix test_format when locale does not expect number grouping (GH-23067)

5 years agobpo-41435: Add sys._current_exceptions() function (GH-21689)
Julien Danjou [Mon, 2 Nov 2020 14:16:25 +0000 (15:16 +0100)] 
bpo-41435: Add sys._current_exceptions() function (GH-21689)

This adds a new function named sys._current_exceptions() which is equivalent ot
sys._current_frames() except that it returns the exceptions currently handled
by other threads. It is equivalent to calling sys.exc_info() for each running
thread.

5 years agobpo-42230: Improve asyncio documentation regarding accepting sets vs iterables (GH...
Jakub Stasiak [Mon, 2 Nov 2020 10:56:35 +0000 (11:56 +0100)] 
bpo-42230: Improve asyncio documentation regarding accepting sets vs iterables (GH-23073)

People call wait() and as_completed() with various non-set iterables,
a list should be the most common but there are others as well[1].

Considering typeshed also documents wait()[2] and as_completed()[3]
as accepting arbitrary iterables I think it's a good idea to document
the status quo better.

[1] https://github.com/aio-libs/aiokafka/pull/672
[2] https://github.com/python/typeshed/blob/620989bac572f30349b95590ebe81a73ce0fe862/stdlib/3/asyncio/tasks.pyi#L161
[3] https://github.com/python/typeshed/blob/620989bac572f30349b95590ebe81a73ce0fe862/stdlib/3/asyncio/tasks.pyi#L40

5 years agobpo-41229: Update docs for explicit aclose()-required cases and add contextlib.aclosi...
Joongi Kim [Mon, 2 Nov 2020 08:02:48 +0000 (17:02 +0900)] 
bpo-41229: Update docs for explicit aclose()-required cases and add contextlib.aclosing() method (GH-21545)

This is a PR to:

 * Add `contextlib.aclosing` which ia analogous to `contextlib.closing` but for async-generators with an explicit test case for [bpo-41229]()
 * Update the docs to describe when we need explicit `aclose()` invocation.

which are motivated by the following issues, articles, and examples:

 * [bpo-41229]()
 * https://github.com/njsmith/async_generator
 * https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#cleanup-in-generators-and-async-generators
 * https://www.python.org/dev/peps/pep-0533/
 * https://github.com/achimnol/aiotools/blob/ef7bf0cea7af/src/aiotools/context.py#L152

Particuarly regarding [PEP-533](https://www.python.org/dev/peps/pep-0533/), its acceptance (`__aiterclose__()`) would make this little addition of `contextlib.aclosing()` unnecessary for most use cases, but until then this could serve as a good counterpart and analogy to `contextlib.closing()`. The same applies for `contextlib.closing` with `__iterclose__()`.
Also, still there are other use cases, e.g., when working with non-generator objects with `aclose()` methods.

5 years agoMinor formatting edits to the descriptor howto guide (GH-23092)
Raymond Hettinger [Mon, 2 Nov 2020 04:15:50 +0000 (20:15 -0800)] 
Minor formatting edits to the descriptor howto guide (GH-23092)

5 years agobpo-40511: Stop unwanted flashing of IDLE calltips (GH-20910)
Tal Einat [Mon, 2 Nov 2020 03:59:52 +0000 (05:59 +0200)] 
bpo-40511: Stop unwanted flashing of IDLE calltips (GH-20910)

They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
5 years agoAdd member objects to the descriptor howto guide (GH-23084)
Raymond Hettinger [Mon, 2 Nov 2020 02:02:37 +0000 (18:02 -0800)] 
Add member objects to the descriptor howto guide (GH-23084)

5 years agobpo-37193: remove thread objects which finished process its request (GH-13893)
MARUYAMA Norihiro [Sun, 1 Nov 2020 23:51:04 +0000 (08:51 +0900)] 
bpo-37193: remove thread objects which finished process its request (GH-13893)

* bpo-37193: remove the thread which finished process request from threads list

* rename variable t to thread.

* don't remove thread from list if it is daemon.

* use lock to protect self._threads.

* use finally block in case of exception from shutdown_request().

* check "not thread.daemon" before lock to avoid holding the lock if it's unnecessary.

* fix the place of _threads_lock.

* separate code to remove a current thread into a function.

* check ValueError when removing thread.

* fix wrong code which all instance shared same lock.

* Extract thread management into a _Threads class to encapsulate atomic operations and separate concerns.

* Replace multiple references of 'block_on_close' with one, avoiding the possibility that 'block_on_close' could change during the course of processing requests. Now, there's exactly one _threads object with behavior fixed for the duration.

* Add docstrings to private classes.

* Add test to ensure that a ThreadingTCPServer can be closed without serving any requests.

* Use _NoThreads as the default value. Fixes AttributeError when server is closed without serving any requests.

* Add blurb

* Add test capturing failure.

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
5 years agobpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086)
Victor Stinner [Sun, 1 Nov 2020 22:07:23 +0000 (23:07 +0100)] 
bpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086)

If the nl_langinfo(CODESET) function returns an empty string, Python
now uses UTF-8 as the filesystem encoding.

In May 2010 (commit b744ba1d14c5487576c95d0311e357b707600b47), I
modified Python to log a warning and use UTF-8 as the filesystem
encoding (instead of None) if nl_langinfo(CODESET) returns an empty
string.

In August 2020 (commit 94908bbc1503df830d1d615e7b57744ae1b41079), I
modified Python startup to fail with a fatal error and a specific
error message if nl_langinfo(CODESET) returns an empty string. The
intent was to prevent guessing the encoding and also investigate user
configuration where this case happens.

In 10 years (2010 to 2020), I saw zero user report about the error
message related to nl_langinfo(CODESET) returning an empty string.

Today, UTF-8 became the defacto standard and it's safe to make the
assumption that the user expects UTF-8. For example,
nl_langinfo(CODESET) can return an empty string on macOS if the
LC_CTYPE locale is not supported, and UTF-8 is the default encoding
on macOS.

While this change is likely to not affect anyone in practice, it
should make UTF-8 lover happy ;-)

Rewrite also the documentation explaining how Python selects the
filesystem encoding and error handler.

5 years agobpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)
Victor Stinner [Sun, 1 Nov 2020 19:59:35 +0000 (20:59 +0100)] 
bpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)

* Rename _Py_GetLocaleEncoding() to _Py_GetLocaleEncodingObject()
* Add _Py_GetLocaleEncoding() which returns a wchar_t* string to
  share code between _Py_GetLocaleEncodingObject()
  and config_get_locale_encoding().
* _Py_GetLocaleEncodingObject() now decodes nl_langinfo(CODESET)
  from the current locale encoding with surrogateescape,
  rather than using UTF-8.

5 years agobpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)
kj [Sun, 1 Nov 2020 18:13:38 +0000 (02:13 +0800)] 
bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)

Noticed by @serhiy-storchaka in the bpo.  `typing`'s types were not showing the parameterized generic.
Eg. previously:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict, list]'
```
Now:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict[str, float], list[int]]'
```

Automerge-Triggered-By: GH:gvanrossum
5 years agoExpand and clarify the "Invoking Descriptors" section of the Descriptor HowTo (GH...
Raymond Hettinger [Sun, 1 Nov 2020 17:10:06 +0000 (09:10 -0800)] 
Expand and clarify the "Invoking Descriptors" section of the Descriptor HowTo (GH-23078)

5 years agobpo-37483: Add PyObject_CallOneArg() in the What's New in Python 3.9 (GH-23062)
Dong-hee Na [Sun, 1 Nov 2020 13:04:35 +0000 (22:04 +0900)] 
bpo-37483: Add PyObject_CallOneArg() in the What's New in Python 3.9 (GH-23062)

5 years agotempfile: Use random.choises() instead of choise() (GH-23068)
Inada Naoki [Sun, 1 Nov 2020 11:02:03 +0000 (20:02 +0900)] 
tempfile: Use random.choises() instead of choise() (GH-23068)

5 years agobpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059)
Ronald Oussoren [Sun, 1 Nov 2020 09:08:48 +0000 (10:08 +0100)] 
bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059)

[bpo-29566]() notes that binhex.binhex uses inconsistent line endings (both Unix and MacOS9 line endings are used). This PR changes this to use the MacOS9 line endings everywhere.

5 years agobpo-42146: Unify cleanup in subprocess_fork_exec() (GH-22970)
Alexey Izbyshev [Sun, 1 Nov 2020 05:33:08 +0000 (08:33 +0300)] 
bpo-42146: Unify cleanup in subprocess_fork_exec() (GH-22970)

* bpo-42146: Unify cleanup in subprocess_fork_exec()

Also ignore errors from _enable_gc():
* They are always suppressed by the current code due to a bug.
* _enable_gc() is only used if `preexec_fn != None`, which is unsafe.
* We don't have a good way to handle errors in case we successfully
  created a child process.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
5 years agobpo-42198: New section in stdtypes for type annotation types (GH-23063)
kj [Sat, 31 Oct 2020 20:25:44 +0000 (04:25 +0800)] 
bpo-42198: New section in stdtypes for type annotation types (GH-23063)

5 years agobpo-42218: Correctly handle errors in left-recursive rules (GH-23065)
Lysandros Nikolaou [Sat, 31 Oct 2020 18:31:41 +0000 (20:31 +0200)] 
bpo-42218: Correctly handle errors in left-recursive rules (GH-23065)

Left-recursive rules need to check for errors explicitly, since
even if the rule returns NULL, the parsing might continue and lead
to long-distance failures.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-42198: Improve consistency of Union docs (GH-23029)
kj [Sat, 31 Oct 2020 15:08:17 +0000 (23:08 +0800)] 
bpo-42198: Improve consistency of Union docs (GH-23029)

No backport is required since union is only in 3.10.

This addresses "3. Consistency nitpicks for Union's docs" in the bpo.

Please skip news. Thank you.

5 years agobpo-40956: Convert _sqlite3 module level functions to Argument Clinic (GH-22484)
Erlend Egeberg Aasland [Sat, 31 Oct 2020 06:07:44 +0000 (07:07 +0100)] 
bpo-40956: Convert _sqlite3 module level functions to Argument Clinic (GH-22484)

5 years agobpo-42198: Document __new__ for types.GenericAlias (GH-23039)
kj [Sat, 31 Oct 2020 06:02:38 +0000 (14:02 +0800)] 
bpo-42198: Document __new__ for types.GenericAlias (GH-23039)

5 years agoRevert "bpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)"
Inada Naoki [Sat, 31 Oct 2020 02:15:38 +0000 (11:15 +0900)] 
Revert "bpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)"

`_RandomNameSequence` is not true singleton so using `os.register_at_fork` doesn't make sense unlike `random._inst`.

This reverts commit 8e409cebad42032bb7d0f2cadd8b1e36081d98af.

5 years agobpo-42208: Add _locale._get_locale_encoding() (GH-23052)
Victor Stinner [Sat, 31 Oct 2020 00:32:11 +0000 (01:32 +0100)] 
bpo-42208: Add _locale._get_locale_encoding() (GH-23052)

* Add a new _locale._get_locale_encoding() function to get the
  current locale encoding.
* Modify locale.getpreferredencoding() to use it.
* Remove the _bootlocale module.

5 years agobpo-42208: Add _Py_GetLocaleEncoding() (GH-23050)
Victor Stinner [Sat, 31 Oct 2020 00:02:09 +0000 (01:02 +0100)] 
bpo-42208: Add _Py_GetLocaleEncoding() (GH-23050)

_io.TextIOWrapper no longer calls getpreferredencoding(False) of
_bootlocale to get the locale encoding, but calls
_Py_GetLocaleEncoding() instead.

Add config_get_fs_encoding() sub-function. Reorganize also
config_get_locale_encoding() code.

5 years agobpo-42214: Fix check for NOTEQUAL token in the PEG parser for the barry_as_flufl...
Pablo Galindo [Fri, 30 Oct 2020 23:48:42 +0000 (23:48 +0000)] 
bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the barry_as_flufl rule (GH-23048)

5 years agoGitHub Action: Add gdb to posix dependencies (GH-23043)
Victor Stinner [Fri, 30 Oct 2020 21:52:30 +0000 (22:52 +0100)] 
GitHub Action: Add gdb to posix dependencies (GH-23043)

Sort also dependencies and remove duplicates (liblzma-dev).

5 years agobpo-42208: Call GC collect earlier in PyInterpreterState_Clear() (GH-23044)
Victor Stinner [Fri, 30 Oct 2020 21:51:02 +0000 (22:51 +0100)] 
bpo-42208: Call GC collect earlier in PyInterpreterState_Clear() (GH-23044)

The last GC collection is now done before clearing builtins and sys
dictionaries. Add also assertions to ensure that gc.collect() is no
longer called after _PyGC_Fini().

Pass also the tstate to PyInterpreterState_Clear() to pass the
correct tstate to _PyGC_CollectNoFail() and _PyGC_Fini().

5 years agobpo-36876: Small adjustments to the C-analyzer tool. (GH-23045)
Eric Snow [Fri, 30 Oct 2020 21:46:52 +0000 (15:46 -0600)] 
bpo-36876: Small adjustments to the C-analyzer tool. (GH-23045)

This is a little bit of clean-up, small fixes, and additional helpers prior to building an updated & accurate list of globals to eliminate.

5 years agobpo-42208: Fix test_gdb for gc_collect_main() name (GH-23041)
Victor Stinner [Fri, 30 Oct 2020 20:09:48 +0000 (21:09 +0100)] 
bpo-42208: Fix test_gdb for gc_collect_main() name (GH-23041)

The gcmodule.c collect() function was renamed to gc_collect_main():
update gdb/libpython.py (python-gdb.py).

5 years agobpo-42208: Move _PyImport_Cleanup() to pylifecycle.c (GH-23040)
Victor Stinner [Fri, 30 Oct 2020 17:03:28 +0000 (18:03 +0100)] 
bpo-42208: Move _PyImport_Cleanup() to pylifecycle.c (GH-23040)

Move _PyImport_Cleanup() to pylifecycle.c, rename it to
finalize_modules(), split it (200 lines) into many smaller
sub-functions and cleanup the code.

5 years agobpo-42208: Pass tstate to _PyGC_CollectNoFail() (GH-23038)
Victor Stinner [Fri, 30 Oct 2020 16:00:00 +0000 (17:00 +0100)] 
bpo-42208: Pass tstate to _PyGC_CollectNoFail() (GH-23038)

Move private _PyGC_CollectNoFail() to the internal C API.

Remove the private _PyGC_CollectIfEnabled() which was just an alias
to the public PyGC_Collect() function since Python 3.8.

Rename functions:

* collect() => gc_collect_main()
* collect_with_callback() => gc_collect_with_callback()
* collect_generations() => gc_collect_generations()

5 years agoDOC: attribute PyPy for the idea behind LOAD_ATTR cache (GH-23036)
Matti Picus [Fri, 30 Oct 2020 14:52:39 +0000 (16:52 +0200)] 
DOC: attribute PyPy for the idea behind LOAD_ATTR cache (GH-23036)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-42206: Propagate and raise errors from PyAST_Validate in the parser (GH-23035)
Batuhan Taskaya [Fri, 30 Oct 2020 11:48:41 +0000 (14:48 +0300)] 
bpo-42206: Propagate and raise errors from PyAST_Validate in the parser (GH-23035)

5 years agobpo-42172: Correct typo for test_socket.py (GH-23013)
Akashkumar D Khunt [Fri, 30 Oct 2020 06:03:51 +0000 (11:33 +0530)] 
bpo-42172: Correct typo for test_socket.py  (GH-23013)

5 years agobpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)
Eric W [Fri, 30 Oct 2020 04:56:28 +0000 (05:56 +0100)] 
bpo-42160: tempfile: Reduce overhead of pid check. (GH-22997)

The _RandomSequence class in tempfile used to check the current pid every time its rng property was used.
This commit replaces this code with `os.register_at_fork` to reduce the overhead.

5 years agobpo-42198: Link to GenericAlias in typing and expressions (GH-23030)
kj [Fri, 30 Oct 2020 04:01:17 +0000 (12:01 +0800)] 
bpo-42198: Link to GenericAlias in typing and expressions (GH-23030)

Follow up to 7cdf30fff39ea97f403b5472096349998d190e30 and 4173320920706b49a004bdddd8d7108e8984e3fc. This addresses the point "1. Update links in typing, subscription and union to point to GenericAlias." in the bpo for this PR.

5 years agobpo-42061: Document __format__ for IP addresses (GH-23018)
Teugea Ioan-Teodor [Thu, 29 Oct 2020 22:17:59 +0000 (00:17 +0200)] 
bpo-42061: Document __format__ for IP addresses (GH-23018)

Automerge-Triggered-By: GH:ericvsmith
5 years agobpo-42180: fix plural in arguments and control (GH-23015)
Rafael Fontenelle [Thu, 29 Oct 2020 20:48:21 +0000 (17:48 -0300)] 
bpo-42180: fix plural in arguments and control (GH-23015)

https://bugs.python.org/issue42180

5 years agobpo-42029: Remove IRIX code (GH-23023)
Victor Stinner [Thu, 29 Oct 2020 14:16:23 +0000 (15:16 +0100)] 
bpo-42029: Remove IRIX code (GH-23023)

IRIX code was slowy removed in Python 2.4 (--with-sgi-dl), Python 3.3
(Irix threads), and Python 3.7.

5 years agobpo-42143: Ensure PyFunction_NewWithQualName() can't fail after creating the func...
Yonatan Goldschmidt [Thu, 29 Oct 2020 09:58:52 +0000 (11:58 +0200)] 
bpo-42143: Ensure PyFunction_NewWithQualName() can't fail after creating the func object (GH-22953)

func_dealloc() does not handle partially-created objects. Best not to give it any.

5 years agobpo-34204: Use pickle.DEFAULT_PROTOCOL in shelve (GH-19639)
Zackery Spytz [Thu, 29 Oct 2020 09:44:35 +0000 (03:44 -0600)] 
bpo-34204: Use pickle.DEFAULT_PROTOCOL in shelve (GH-19639)

Use pickle.DEFAULT_PROTOCOL (currently 5) in shelve instead of a
hardcoded 3.

5 years agobpo-41805: Documentation for PEP 585 (GH-22615)
kj [Tue, 27 Oct 2020 21:37:18 +0000 (05:37 +0800)] 
bpo-41805: Documentation for PEP 585 (GH-22615)

5 years agobpo-42161: Micro-optimize _collections._count_elements() (GH-23008)
Victor Stinner [Tue, 27 Oct 2020 21:24:33 +0000 (22:24 +0100)] 
bpo-42161: Micro-optimize _collections._count_elements() (GH-23008)

Move the _PyLong_GetOne() call outside the fast-path loop.

5 years agobpo-42161: Remove private _PyLong_Zero and _PyLong_One (GH-23003)
Victor Stinner [Tue, 27 Oct 2020 20:34:33 +0000 (21:34 +0100)] 
bpo-42161: Remove private _PyLong_Zero and _PyLong_One (GH-23003)

Use PyLong_FromLong(0) and PyLong_FromLong(1) of the public C API
instead. For Python internals, _PyLong_GetZero() and _PyLong_GetOne()
of pycore_long.h can be used.

5 years agobpo-42099: Fix reference to ob_type in unionobject.c and ceval (GH-22829)
Neil Schemenauer [Tue, 27 Oct 2020 18:55:52 +0000 (11:55 -0700)] 
bpo-42099: Fix reference to ob_type in unionobject.c and ceval (GH-22829)

* Use Py_TYPE() rather than o->ob_type.

5 years agobpo-41659: Disallow curly brace directly after primary (GH-22996)
Lysandros Nikolaou [Tue, 27 Oct 2020 18:54:20 +0000 (20:54 +0200)] 
bpo-41659: Disallow curly brace directly after primary (GH-22996)

5 years agobpo-6761: Enhance __call__ documentation (GH-7987)
Andre Delfino [Tue, 27 Oct 2020 16:18:57 +0000 (13:18 -0300)] 
bpo-6761: Enhance __call__ documentation (GH-7987)

5 years agobpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)
Victor Stinner [Tue, 27 Oct 2020 16:12:53 +0000 (17:12 +0100)] 
bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)

Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory.

_cursesmodule.c and zoneinfo.c are now built with
Py_BUILD_CORE_MODULE macro defined.

5 years agobpo-41474, Makefile: Add dependency on cpython/frameobject.h (GH-22999)
Victor Stinner [Tue, 27 Oct 2020 03:41:30 +0000 (04:41 +0100)] 
bpo-41474, Makefile: Add dependency on cpython/frameobject.h (GH-22999)

Co-Authored-By: Skip Montanaro <skip.montanaro@gmail.com>
5 years agobpo-42157: Rename unicodedata.ucnhash_CAPI (GH-22994)
Victor Stinner [Tue, 27 Oct 2020 03:36:22 +0000 (04:36 +0100)] 
bpo-42157: Rename unicodedata.ucnhash_CAPI (GH-22994)

Removed the unicodedata.ucnhash_CAPI attribute which was an internal
PyCapsule object. The related private _PyUnicode_Name_CAPI structure
was moved to the internal C API.

Rename unicodedata.ucnhash_CAPI as unicodedata._ucnhash_CAPI.

5 years agobpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)
Victor Stinner [Tue, 27 Oct 2020 01:24:34 +0000 (02:24 +0100)] 
bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)

Use _PyLong_GetZero() and _PyLong_GetOne()
in Objects/ and Python/ directories.

5 years agobpo-30681: Support invalid date format or value in email Date header (GH-22090)
Georges Toth [Tue, 27 Oct 2020 00:31:06 +0000 (01:31 +0100)] 
bpo-30681: Support invalid date format or value in email Date header (GH-22090)

I am re-submitting an older PR which was abandoned but is still relevant, #10783 by @timb07.

The issue being solved () is still relevant. The original PR #10783 was closed as
the final request changes were not applied and since abandoned.

In this new PR I have re-used the original patch plus applied both comments from the review, by @maxking and @pganssle.

For reference, here is the original PR description:
In email.utils.parsedate_to_datetime(), a failure to parse the date, or invalid date components (such as hour outside 0..23) raises an exception. Document this behaviour, and add tests to test_email/test_utils.py to confirm this behaviour.

In email.headerregistry.DateHeader.parse(), check when parsedate_to_datetime() raises an exception and add a new defect InvalidDateDefect; preserve the invalid value as the string value of the header, but set the datetime attribute to None.

Add tests to test_email/test_headerregistry.py to confirm this behaviour; also added test to test_email/test_inversion.py to confirm emails with such defective date headers round trip successfully.

This pull request incorporates feedback gratefully received from @bitdancer, @brettcannon, @Mariatta and @warsaw, and replaces the earlier PR #2254.

Automerge-Triggered-By: GH:warsaw
5 years agobpo-42161: Add _PyLong_GetZero() and _PyLong_GetOne() (GH-22993)
Victor Stinner [Mon, 26 Oct 2020 23:00:03 +0000 (00:00 +0100)] 
bpo-42161: Add _PyLong_GetZero() and _PyLong_GetOne() (GH-22993)

Add _PyLong_GetZero() and _PyLong_GetOne() functions and a new
internal pycore_long.h header file.

Python cannot be built without small integer singletons anymore.

5 years agobpo-42123: Run the parser two times and only enable invalid rules on the second run...
Lysandros Nikolaou [Mon, 26 Oct 2020 22:42:04 +0000 (00:42 +0200)] 
bpo-42123: Run the parser two times and only enable invalid rules on the second run (GH-22111)

* Implement running the parser a second time for the errors messages

The first parser run is only responsible for detecting whether
there is a `SyntaxError` or not. If there isn't the AST gets returned.
Otherwise, the parser is run a second time with all the `invalid_*`
rules enabled so that all the customized error messages get produced.

5 years agobpo-42157: Convert unicodedata.UCD to heap type (GH-22991)
Victor Stinner [Mon, 26 Oct 2020 22:19:22 +0000 (23:19 +0100)] 
bpo-42157: Convert unicodedata.UCD to heap type (GH-22991)

Convert the unicodedata extension module to the multiphase
initialization API (PEP 489) and convert the unicodedata.UCD static
type to a heap type.

Co-Authored-By: Mohamed Koubaa <koubaa.m@gmail.com>
5 years agobpo-42157: unicodedata avoids references to UCD_Type (GH-22990)
Victor Stinner [Mon, 26 Oct 2020 18:19:36 +0000 (19:19 +0100)] 
bpo-42157: unicodedata avoids references to UCD_Type (GH-22990)

* UCD_Check() uses PyModule_Check()
* Simplify the internal _PyUnicode_Name_CAPI structure:

  * Remove size and state members
  * Remove state and self parameters of getcode() and getname()
    functions

* Remove global_module_state

5 years agobpo-39101: Fixes BaseException hang in IsolatedAsyncioTestCase. (GH-22654)
Lisa Roach [Mon, 26 Oct 2020 16:28:17 +0000 (09:28 -0700)] 
bpo-39101: Fixes BaseException hang in IsolatedAsyncioTestCase. (GH-22654)

5 years agobpo-1635741: _PyUnicode_Name_CAPI moves to internal C API (GH-22713)
Victor Stinner [Mon, 26 Oct 2020 15:43:47 +0000 (16:43 +0100)] 
bpo-1635741: _PyUnicode_Name_CAPI moves to internal C API (GH-22713)

The private _PyUnicode_Name_CAPI structure of the PyCapsule API
unicodedata.ucnhash_CAPI moves to the internal C API. Moreover, the
structure gets a new state member which must be passed to the
getcode() and getname() functions.

* Move Include/ucnhash.h to Include/internal/pycore_ucnhash.h
* unicodedata module is now built with Py_BUILD_CORE_MODULE.
* unicodedata: move hashAPI variable into unicodedata_module_state.

5 years agobpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)
Serhiy Storchaka [Mon, 26 Oct 2020 10:47:57 +0000 (12:47 +0200)] 
bpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)

If PyDict_GetItemWithError is only used to check whether the key is in dict,
it is better to use PyDict_Contains instead.

And if it is used in combination with PyDict_SetItem, PyDict_SetDefault can
replace the combination.

5 years agobpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and _PyDict_GetItemId...
Serhiy Storchaka [Mon, 26 Oct 2020 06:43:39 +0000 (08:43 +0200)] 
bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and _PyDict_GetItemId. (GH-22648)

These functions are considered not safe because they suppress all internal errors
and can return wrong result.  PyDict_GetItemString and _PyDict_GetItemId can
also silence current exception in rare cases.

Remove no longer used _PyDict_GetItemId.
Add _PyDict_ContainsId and rename _PyDict_Contains into
_PyDict_Contains_KnownHash.

5 years agoAdded some makefile generated files to .gitignore (GH-22435)
Marco Sulla [Mon, 26 Oct 2020 05:30:51 +0000 (06:30 +0100)] 
Added some makefile generated files to .gitignore (GH-22435)

5 years agoAdd a link to buffer protocol in bytearray() doc (GH-22675)
Antoine [Mon, 26 Oct 2020 05:26:34 +0000 (06:26 +0100)] 
Add a link to buffer protocol in bytearray() doc (GH-22675)

5 years agobpo-42146: Fix memory leak in subprocess.Popen() in case of uid/gid overflow (GH...
Alexey Izbyshev [Mon, 26 Oct 2020 00:09:32 +0000 (03:09 +0300)] 
bpo-42146: Fix memory leak in subprocess.Popen() in case of uid/gid overflow (GH-22966)

Fix memory leak in subprocess.Popen() in case of uid/gid overflow

Also add a test that would catch this leak with `--huntrleaks`.

Alas, the test for `extra_groups` also exposes an inconsistency
in our error reporting: we use a custom ValueError for `extra_groups`,
but propagate OverflowError for `user` and `group`.

5 years agobpo-42150: Avoid buffer overflow in the new parser (GH-22978)
Pablo Galindo [Sun, 25 Oct 2020 23:03:41 +0000 (23:03 +0000)] 
bpo-42150: Avoid buffer overflow in the new parser (GH-22978)

5 years agobpo-42043: Add support for zipfile.Path subclasses (#22716)
Jason R. Coombs [Sun, 25 Oct 2020 18:45:05 +0000 (14:45 -0400)] 
bpo-42043: Add support for zipfile.Path subclasses (#22716)

* bpo-42043: Add support for zipfile.Path inheritance as introduced in zipp 3.2.0.

* Add blurb.

5 years agobpo-41919: Avoid resource leak in test_io (GH-22973)
Hai Shi [Sun, 25 Oct 2020 18:38:33 +0000 (02:38 +0800)] 
bpo-41919: Avoid resource leak in test_io (GH-22973)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
5 years agobpo-41490: ``path`` and ``contents`` to aggressively close handles (#22915)
Jason R. Coombs [Sun, 25 Oct 2020 18:21:46 +0000 (14:21 -0400)] 
bpo-41490: ``path`` and ``contents`` to aggressively close handles (#22915)

* bpo-41490: ``path`` method to aggressively close handles

* Add blurb

* In ZipReader.contents, eagerly evaluate the contents to release references to the zipfile.

* Instead use _ensure_sequence to ensure any iterable from a reader is eagerly converted to a list if it's not already a sequence.

5 years agobpo-42144: Add a missing "goto error;" in the _ssl module (GH-22959)
Zackery Spytz [Sun, 25 Oct 2020 18:02:30 +0000 (12:02 -0600)] 
bpo-42144: Add a missing "goto error;" in the _ssl module (GH-22959)

5 years agobpo-39108: Document threading issues for random.gauss() (GH-22928)
Raymond Hettinger [Sun, 25 Oct 2020 14:59:01 +0000 (07:59 -0700)] 
bpo-39108: Document threading issues for random.gauss() (GH-22928)

5 years agoSplit-out a fourth section in the descriptor HowTo guide (GH-22965)
Raymond Hettinger [Sun, 25 Oct 2020 14:12:50 +0000 (07:12 -0700)] 
Split-out a fourth section in the descriptor HowTo guide (GH-22965)

5 years agoCorrectly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)
Pablo Galindo [Sun, 25 Oct 2020 06:08:17 +0000 (06:08 +0000)] 
Correctly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)

5 years agoSecond round of updates to the descriptor howto guide (GH-22946)
Raymond Hettinger [Sun, 25 Oct 2020 03:34:39 +0000 (20:34 -0700)] 
Second round of updates to the descriptor howto guide (GH-22946)

5 years agobpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942)
Mark Roseman [Sun, 25 Oct 2020 03:14:02 +0000 (20:14 -0700)] 
bpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942)

5 years agobpo-42127: Document effect of cached_property on key-sharing dictionaries (GH-22930)
Raymond Hettinger [Sun, 25 Oct 2020 01:17:17 +0000 (18:17 -0700)] 
bpo-42127:  Document effect of cached_property on key-sharing dictionaries (GH-22930)

5 years agobpo-33987: Use master ttk Frame for IDLE config dialog (GH-22943)
Mark Roseman [Sat, 24 Oct 2020 23:45:00 +0000 (16:45 -0700)] 
bpo-33987: Use master ttk Frame for IDLE config dialog (GH-22943)

5 years agobpo-33987: Use ttk Label on IDLE statusbar (GH-22941)
Mark Roseman [Sat, 24 Oct 2020 23:32:34 +0000 (16:32 -0700)] 
bpo-33987: Use ttk Label on IDLE statusbar (GH-22941)

5 years agobpo-35823: Allow setsid() after vfork() on Linux. (GH-22945)
Gregory P. Smith [Sat, 24 Oct 2020 19:07:35 +0000 (12:07 -0700)] 
bpo-35823: Allow setsid() after vfork() on Linux. (GH-22945)

It should just be a syscall updating a couple of fields in the kernel side
process info.  Confirming, in glibc is appears to be a shim for the setsid
syscall (based on not finding any code implementing anything special for it)
and in uclibc (*much* easier to read) it is clearly just a setsid syscall shim.

A breadcrumb _suggesting_ that it is not allowed on Darwin/macOS comes from
a commit in emacs: https://lists.gnu.org/archive/html/bug-gnu-emacs/2017-04/msg00297.html
but I don't have a way to verify if that is true or not.
As we are not supporting vfork on macOS today I just left a note in a comment.

5 years agobpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870)
Serhiy Storchaka [Sat, 24 Oct 2020 18:14:23 +0000 (21:14 +0300)] 
bpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870)

5 years agobpo-35823: subprocess: Fix handling of pthread_sigmask() errors (GH-22944)
Alexey Izbyshev [Sat, 24 Oct 2020 17:47:38 +0000 (20:47 +0300)] 
bpo-35823: subprocess: Fix handling of pthread_sigmask() errors (GH-22944)

Using POSIX_CALL() is incorrect since pthread_sigmask() returns
the error number instead of setting errno.

Also handle failure of the first call to pthread_sigmask()
in the parent process, and explain why we don't handle failure
of the second call in a comment.

5 years ago[doc] Fix link to abc.ABCMeta.register in Glossary (GH-22932)
Andre Delfino [Sat, 24 Oct 2020 14:29:17 +0000 (11:29 -0300)] 
[doc] Fix link to abc.ABCMeta.register in Glossary (GH-22932)

5 years agoAutomatically add skip news and skip issue label to dependabot PRs (GH-22927)
Mariatta [Sat, 24 Oct 2020 14:12:55 +0000 (07:12 -0700)] 
Automatically add skip news and skip issue label to dependabot PRs (GH-22927)

Closes https://github.com/python/bedevere/issues/287