]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
3 years agogh-92203: Add closure support to exec(). (#92204)
larryhastings [Fri, 6 May 2022 17:09:35 +0000 (10:09 -0700)] 
gh-92203: Add closure support to exec(). (#92204)

Add a closure keyword-only parameter to exec(). It can only be specified when exec-ing a code object that uses free variables. When specified, it must be a tuple, with exactly the number of cell variables referenced by the code object. closure has a default value of None, and it must be None if the code object doesn't refer to any free variables.

3 years agogh-90978: test_ssl of test_asyncio uses LONG_TIMEOUT (#92402)
Victor Stinner [Fri, 6 May 2022 14:18:56 +0000 (16:18 +0200)] 
gh-90978: test_ssl of test_asyncio uses LONG_TIMEOUT (#92402)

On slow buildbot workers, some test_ssl tests fail randomly because
of short timeout (30 seconds). Use support.LONG_TIMEOUT instead which
is longer and also adjusted (by regrtest --timeout option) on
buildbot workers known to be slow.

3 years agogh-90997: Show cached inline values in `dis` output (#92360)
Brandt Bucher [Fri, 6 May 2022 14:18:09 +0000 (07:18 -0700)] 
gh-90997: Show cached inline values in `dis` output  (#92360)

3 years agogh-92368: Fix missing possessive apostrophe (#92397)
gophra [Fri, 6 May 2022 13:39:16 +0000 (21:39 +0800)] 
gh-92368: Fix missing possessive apostrophe (#92397)

* Fix missing possessive apostrophe

3 years agogh-91321: Fix _PyObject_EXTRA_INIT for C++ (#92396)
Victor Stinner [Fri, 6 May 2022 12:40:08 +0000 (14:40 +0200)] 
gh-91321: Fix _PyObject_EXTRA_INIT for C++ (#92396)

In C++, the _PyObject_EXTRA_INIT macro now uses nullptr, rather than
0, to initialize the _ob_next and _ob_prev members of the PyObject
structure.

Fix test_cppext failure when Python is built with
./configure --with-trace-refs.

3 years agoFix What's New: use :gh: instead of :issue: (#92395)
Serhiy Storchaka [Fri, 6 May 2022 12:32:10 +0000 (15:32 +0300)] 
Fix What's New: use :gh: instead of :issue: (#92395)

3 years agogh-91827: Add method info_pathlevel() in tkinter (GH-91829)
Serhiy Storchaka [Fri, 6 May 2022 10:50:38 +0000 (13:50 +0300)] 
gh-91827: Add method info_pathlevel() in tkinter (GH-91829)

3 years agoAdd source for character mappings (#92014)
slateny [Fri, 6 May 2022 10:28:09 +0000 (03:28 -0700)] 
Add source for character mappings (#92014)

3 years agogh-92332: Docs-only deprecation of `typing.Text` (GH-92351)
Alex Waygood [Fri, 6 May 2022 10:15:18 +0000 (11:15 +0100)] 
gh-92332: Docs-only deprecation of `typing.Text` (GH-92351)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
3 years agogh-84461: Skip network require tests on Emscripten (GH-92383)
Christian Heimes [Fri, 6 May 2022 10:08:36 +0000 (12:08 +0200)] 
gh-84461: Skip network require tests on Emscripten (GH-92383)

3 years agoEnum docs: Remove unnecessary apostrophes (#92382)
Alex Waygood [Fri, 6 May 2022 09:53:00 +0000 (10:53 +0100)] 
Enum docs: Remove unnecessary apostrophes (#92382)

Replace "it's" with "its".

3 years agoDocument the lifetime of `PyUnicode_AsUTF8String` (#92325)
Matt Wozniski [Fri, 6 May 2022 09:37:08 +0000 (05:37 -0400)] 
Document the lifetime of `PyUnicode_AsUTF8String` (#92325)

The current wording implied this, but didn't state it explicitly.

3 years agoGH-89519: Deprecate classmethod descriptor chaining (#92379)
Raymond Hettinger [Fri, 6 May 2022 07:57:53 +0000 (02:57 -0500)] 
GH-89519: Deprecate classmethod descriptor chaining (#92379)

3 years agoDon't apply 'stale' label to issues (#91501)
Hugo van Kemenade [Fri, 6 May 2022 07:18:22 +0000 (10:18 +0300)] 
Don't apply 'stale' label to issues (#91501)

3 years agogh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)
Ethan Furman [Fri, 6 May 2022 07:16:22 +0000 (00:16 -0700)] 
gh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)

- add member() and nonmember() functions
- add deprecation warning for internal classes in enums not
  becoming members in 3.13

Co-authored-by: edwardcwang
3 years agogh-90622: Prevent max_tasks_per_child use with a fork mp_context. (#91587)
Gregory P. Smith [Fri, 6 May 2022 07:04:53 +0000 (00:04 -0700)] 
gh-90622: Prevent max_tasks_per_child use with a fork mp_context. (#91587)

Prevent `max_tasks_per_child` use with a "fork" mp_context to avoid deadlocks.

Also defaults to "spawn" when no mp_context is supplied for safe convenience.

3 years agogh-87901: Add encoding to os.popen (GH-92374)
Inada Naoki [Fri, 6 May 2022 05:48:36 +0000 (14:48 +0900)] 
gh-87901: Add encoding to os.popen (GH-92374)

3 years agobpo-46907: Update macOS installer to SQLite 3.38.4. (GH-32148)
Mariusz Felisiak [Fri, 6 May 2022 04:59:32 +0000 (06:59 +0200)] 
bpo-46907: Update macOS installer to SQLite 3.38.4. (GH-32148)

3 years agoNEWS: Reorder items by section (GH-92373)
Inada Naoki [Fri, 6 May 2022 04:58:58 +0000 (13:58 +0900)] 
NEWS: Reorder items by section (GH-92373)

They caused duplicated sections.

3 years agoIssues/88027: A potential double free in list_sort_impl (#92367)
Tim Peters [Fri, 6 May 2022 04:14:09 +0000 (23:14 -0500)] 
Issues/88027: A potential double free in list_sort_impl (#92367)

merge_freemem(): set keys to NULL do it's harmless to call this again.

3 years agogh-92112: Fix crash triggered by an evil custom `mro()` (#92113)
Alexey Izbyshev [Fri, 6 May 2022 04:01:15 +0000 (07:01 +0300)] 
gh-92112: Fix crash triggered by an evil custom `mro()` (#92113)

3 years agogh-92356: Fix regression in ctypes function call overhead (#92357)
Michael Droettboom [Fri, 6 May 2022 03:59:45 +0000 (23:59 -0400)] 
gh-92356: Fix regression in ctypes function call overhead (#92357)

38f331d introduced a delayed initialization routine to set up
ctypes formattable (`_ctypes_init_fielddesc`), but inadvertently
removed setting the `initialization` flag to 1 to avoid initting
each time.

3 years agoupdate argparse's doc of append action. (#92344)
Hai Shi [Fri, 6 May 2022 03:32:35 +0000 (11:32 +0800)] 
update argparse's doc of append action. (#92344)

3 years agogh-88279: Deprecate PySys_SetArgvEx() (#92363)
Victor Stinner [Fri, 6 May 2022 03:24:29 +0000 (05:24 +0200)] 
gh-88279: Deprecate PySys_SetArgvEx() (#92363)

Deprecate the following C functions:

* PySys_SetArgv()
* PySys_SetArgvEx()
* PySys_SetPath()

3 years agogh-57684: Document safe path in What's New in Python 3.11 (#92362)
Victor Stinner [Fri, 6 May 2022 02:53:00 +0000 (04:53 +0200)] 
gh-57684: Document safe path in What's New in Python 3.11 (#92362)

Mention also -P and PYTHONSAFEPATH in the Security Considerations
page.

3 years agogh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)
Victor Stinner [Fri, 6 May 2022 01:41:24 +0000 (03:41 +0200)] 
gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)

Fix tests failing with the PYTHONSAFEPATH=1 env var.

Enhance also -P help in Python usage (python --help).

3 years agogh-80010: Expand fromisoformat to include most of ISO-8601 (#92177)
Paul Ganssle [Fri, 6 May 2022 00:31:24 +0000 (18:31 -0600)] 
gh-80010: Expand fromisoformat to include most of ISO-8601 (#92177)

This expands `fromisoformat` to cover most of the common uses of ISO 8601. We may expand the scope more in the future.

3 years agogh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
Victor Stinner [Thu, 5 May 2022 23:34:11 +0000 (01:34 +0200)] 
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)

Add the -P command line option and the PYTHONSAFEPATH environment
variable to not prepend a potentially unsafe path to sys.path.

* Add sys.flags.safe_path flag.
* Add PyConfig.safe_path member.
* Programs/_bootstrap_python.c uses config.safe_path=0.
* Update subprocess._optim_args_from_interpreter_flags() to handle
  the -P command line option.
* Modules/getpath.py sets safe_path to 1 if a "._pth" file is
  present.

3 years agogh-82616: Add process_group support to subprocess.Popen (#23930)
Gregory P. Smith [Thu, 5 May 2022 23:22:32 +0000 (16:22 -0700)] 
gh-82616: Add process_group support to subprocess.Popen (#23930)

One more thing that can help prevent people from using `preexec_fn`.

Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
3 years agogh-70363: Emscripten cannot fstat renamed spool file (GH-92354)
Christian Heimes [Thu, 5 May 2022 23:10:37 +0000 (01:10 +0200)] 
gh-70363: Emscripten cannot fstat renamed spool file (GH-92354)

3 years agogh-91996: Add an HTTPMethod StrEnum to http (GH-91997)
cibofo [Thu, 5 May 2022 22:39:02 +0000 (01:39 +0300)] 
gh-91996: Add an HTTPMethod StrEnum to http (GH-91997)

* Add HTTPMethod enum to http

Create a StrEnum for the 9 common HTTP methods.

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
3 years agogh-92135: test_cppext requires subprocess (GH-92349)
Christian Heimes [Thu, 5 May 2022 22:08:43 +0000 (00:08 +0200)] 
gh-92135: test_cppext requires subprocess (GH-92349)

3 years agogh-64783: Don't check value of SIG_DFL and SIG_IGN (#92350)
Christian Heimes [Thu, 5 May 2022 22:07:53 +0000 (00:07 +0200)] 
gh-64783: Don't check value of SIG_DFL and SIG_IGN (#92350)

3 years agogh-92345: Import rlcompleter before sys.path is extended (#92346)
Christian Heimes [Thu, 5 May 2022 19:24:16 +0000 (21:24 +0200)] 
gh-92345: Import rlcompleter before sys.path is extended (#92346)

``pymain_run_python()`` now imports ``readline`` and ``rlcompleter``
before sys.path is extended to include the current working directory of
an interactive interpreter. Non-interactive interpreters are not
affected.

Also move imports of ``re`` and ``keyword`` module to top level so they
are materialized early, too. The ``keyword`` module is trivial and the
``re`` is already imported via ``inspect`` -> ``linecache``.

3 years agogh-87390: Fix starred tuple equality and pickling (GH-92337)
Serhiy Storchaka [Thu, 5 May 2022 17:16:06 +0000 (20:16 +0300)] 
gh-87390: Fix starred tuple equality and pickling (GH-92337)

3 years agominor hashlib doc example cleanup. (#92340)
Gregory P. Smith [Thu, 5 May 2022 16:48:17 +0000 (09:48 -0700)] 
minor hashlib doc example cleanup. (#92340)

Closes #85465

3 years agogh-92301: subprocess: Prefer close_range() to procfs-based fd closing (#92303)
Alexey Izbyshev [Thu, 5 May 2022 16:46:19 +0000 (19:46 +0300)] 
gh-92301: subprocess: Prefer close_range() to procfs-based fd closing (#92303)

#92301: subprocess: Prefer `close_range()` to procfs-based fd closing.

`close_range()` is much faster for large number of file descriptors, e.g.
4 times faster for 1000 descriptors in a Linux 5.16-based environment.

We prefer close_range() only if it's known to be async-signal-safe.

3 years agogh-92118: Add test for traceback when exception is modified by (Async)ExitStack.__exi...
Irit Katriel [Thu, 5 May 2022 16:39:33 +0000 (12:39 -0400)] 
gh-92118: Add test for traceback when exception is modified by (Async)ExitStack.__exit__ (GH-92339)

3 years agobpo-41818: Add os.login_tty() for *nix. (#29658)
Soumendra Ganguly [Thu, 5 May 2022 16:04:44 +0000 (11:04 -0500)] 
bpo-41818: Add os.login_tty() for *nix. (#29658)

* Add `os.login_tty(fd)` for Unix.

Reviewed-by: Christian Heimes <christian@python.org>
Signed-off-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
3 years agobpo-43827: Make arguments to abc.ABCMeta.__new__ pos-only (#25385)
Vlad Hoi [Thu, 5 May 2022 13:40:01 +0000 (16:40 +0300)] 
bpo-43827: Make arguments to abc.ABCMeta.__new__ pos-only (#25385)

To avoid conflicts with `__init__subclass__`.

3 years agobpo-43857: Improve the AttributeError message when deleting a missing attribute ...
Géry Ogam [Thu, 5 May 2022 13:37:26 +0000 (15:37 +0200)] 
bpo-43857: Improve the AttributeError message when deleting a missing attribute (#25424)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agogh-92047: Py_GetVersion multi-digit minor version (GH-92047) (#92048)
Robert Howlett [Thu, 5 May 2022 09:33:35 +0000 (10:33 +0100)] 
gh-92047: Py_GetVersion multi-digit minor version (GH-92047) (#92048)

3 years agogh-89653: PEP 670: Convert PyCFunction macros to functions (#92302)
Victor Stinner [Thu, 5 May 2022 09:31:59 +0000 (11:31 +0200)] 
gh-89653: PEP 670: Convert PyCFunction macros to functions (#92302)

Convert the following macros to static inline functions:

* PyCFunction_GET_CLASS()
* PyCFunction_GET_FLAGS()
* PyCFunction_GET_FUNCTION()
* PyCFunction_GET_SELF()

Limited C API version 3.11 no longer casts arguments.

3 years agoClean-up and simplify median_grouped(). Vastly improve its docstring. (#92324)
Raymond Hettinger [Thu, 5 May 2022 08:01:07 +0000 (03:01 -0500)] 
Clean-up and simplify median_grouped().  Vastly improve its docstring. (#92324)

3 years agoAllow translating argument error messages (#17169)
DjMorgul [Thu, 5 May 2022 05:32:49 +0000 (07:32 +0200)] 
Allow translating argument error messages (#17169)

3 years agobpo-46764: Fix wrapping bound method with @classmethod (#31367)
Michael J. Sullivan [Thu, 5 May 2022 04:00:21 +0000 (21:00 -0700)] 
bpo-46764: Fix wrapping bound method with @classmethod (#31367)

3 years agogh-92223: Remove pre-Python 3.7 alternative in asyncio docs (#92224)
Sebastian Rittau [Thu, 5 May 2022 00:14:07 +0000 (02:14 +0200)] 
gh-92223: Remove pre-Python 3.7 alternative in asyncio docs (#92224)

3 years agogh-92118: fix traceback of exceptions propagated from inside a contextlib.contextmana...
Irit Katriel [Wed, 4 May 2022 18:40:47 +0000 (14:40 -0400)] 
gh-92118: fix traceback of exceptions propagated from inside a contextlib.contextmanager (GH-92202)

3 years agoGH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH...
Mark Shannon [Wed, 4 May 2022 15:31:21 +0000 (09:31 -0600)] 
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245)

3 years agogh-92107: Add tests that subscription works on arbitrary named tuple types (GH-92304)
Serhiy Storchaka [Wed, 4 May 2022 14:06:50 +0000 (17:06 +0300)] 
gh-92107: Add tests that subscription works on arbitrary named tuple types (GH-92304)

3 years agogh-92210: Move socket.__init__ to argument clinic (#92237)
Joshua Herman [Wed, 4 May 2022 13:38:01 +0000 (07:38 -0600)] 
gh-92210: Move socket.__init__ to argument clinic (#92237)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agogh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)
Erlend Egeberg Aasland [Wed, 4 May 2022 13:16:01 +0000 (07:16 -0600)] 
gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)

* Map SQLITE_MISUSE to sqlite3.InterfaceError

SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens,
is _not_ a user error; it is an sqlite3 extension module error.

* Raise better errors when binding parameters fail.

Instead of always raising InterfaceError, guessing what went wrong,
raise accurate exceptions with more accurate error messages.

3 years agoUse static inline function Py_EnterRecursiveCall() (#91988)
Victor Stinner [Wed, 4 May 2022 11:30:23 +0000 (13:30 +0200)] 
Use static inline function Py_EnterRecursiveCall() (#91988)

Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

* Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
* Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
* pycore_ceval.h: Rename Py_EnterRecursiveCall() to
  _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
  _Py_LeaveRecursiveCall()

3 years agogh-92036: Fix gc_fini_untrack() (#92037)
Victor Stinner [Wed, 4 May 2022 09:59:01 +0000 (11:59 +0200)] 
gh-92036: Fix gc_fini_untrack() (#92037)

Fix a crash in subinterpreters related to the garbage collector. When
a subinterpreter is deleted, untrack all objects tracked by its GC.
To prevent a crash in deallocator functions expecting objects to be
tracked by the GC, leak a strong reference to these objects on
purpose, so they are never deleted and their deallocator functions
are not called.

3 years agoFix renamed "total" variable (#92287)
Raymond Hettinger [Wed, 4 May 2022 04:22:04 +0000 (23:22 -0500)] 
Fix renamed "total" variable (#92287)

* Fix renamed "total" variable
* Keep nan/inf handling consistent between versions

3 years agoFix typo in Sorting howto (#92280)
Carl Meyer [Wed, 4 May 2022 03:38:29 +0000 (21:38 -0600)] 
Fix typo in Sorting howto (#92280)

The phrase is usually "odds and ends," not "odd and ends."

3 years agogh-67248: cmd: Sort miscellaneous help topics (#92254)
Sam Denton [Wed, 4 May 2022 03:36:52 +0000 (22:36 -0500)] 
gh-67248: cmd: Sort miscellaneous help topics (#92254)

Closes #67248

3 years agoCompute from_sample() in a single pass over the data (#92284)
Raymond Hettinger [Wed, 4 May 2022 02:22:26 +0000 (21:22 -0500)] 
Compute from_sample() in a single pass over the data (#92284)

3 years agogh-78214: marshal: Stabilize FLAG_REF usage (GH-8226)
Inada Naoki [Wed, 4 May 2022 01:01:15 +0000 (10:01 +0900)] 
gh-78214: marshal: Stabilize FLAG_REF usage (GH-8226)

Use FLAG_REF always for interned strings.

Refcounts of interned string is very unstable.
When compiling same source, refcounts of interned string in the output may be 1 or >1.
It makes FLAG_REF usage unstable.

To help reproducible build, use FLAG_REF for interned string even if refcnt(obj)==1.

3 years agobpo-47029: Fix BrokenPipeError in multiprocessing.Queue at garbage collection and...
Géry Ogam [Tue, 3 May 2022 23:49:57 +0000 (01:49 +0200)] 
bpo-47029: Fix BrokenPipeError in multiprocessing.Queue at garbage collection and explicit close (#31913)

3 years agogh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)
Erlend Egeberg Aasland [Tue, 3 May 2022 23:03:06 +0000 (17:03 -0600)] 
gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)

Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoAdd more stats for freelist use and allocations. (GH-92211)
Mark Shannon [Tue, 3 May 2022 22:40:24 +0000 (16:40 -0600)] 
Add more stats for freelist use and allocations. (GH-92211)

3 years agoGH-91173: disable frozen modules in debug builds (#92023)
Kumar Aditya [Tue, 3 May 2022 22:20:13 +0000 (03:50 +0530)] 
GH-91173: disable frozen modules in debug builds (#92023)

3 years agogh-91928: Add `datetime.UTC` alias for `datetime.timezone.utc` (GH-91973)
Kabir Kwatra [Tue, 3 May 2022 22:14:25 +0000 (15:14 -0700)] 
gh-91928: Add `datetime.UTC` alias for `datetime.timezone.utc` (GH-91973)

### fixes #91928

`UTC` is now module attribute aliased to `datetime.timezone.utc`.
You can now do the following:
```python
from datetime import UTC
```

3 years agogh-87304: Improve comments in language reference for imports (#92164)
Robert Yang [Tue, 3 May 2022 22:08:05 +0000 (16:08 -0600)] 
gh-87304: Improve comments in language reference for imports (#92164)

3 years agogh-92206: Improve scoping of sqlite3 statement helper (#92260)
Erlend Egeberg Aasland [Tue, 3 May 2022 22:07:11 +0000 (16:07 -0600)] 
gh-92206: Improve scoping of sqlite3 statement helper (#92260)

3 years agoImprove the typing docs (#92264)
Jelle Zijlstra [Tue, 3 May 2022 21:49:21 +0000 (15:49 -0600)] 
Improve the typing docs (#92264)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
3 years agogh-81057: Fix indent. (gh-92267)
Eric Snow [Tue, 3 May 2022 21:44:52 +0000 (15:44 -0600)] 
gh-81057: Fix indent. (gh-92267)

3 years agobpo-45639: Add webp and avif image formats to mimetypes (#29259)
kixorz [Tue, 3 May 2022 21:17:57 +0000 (16:17 -0500)] 
bpo-45639: Add webp and avif image formats to mimetypes (#29259)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agogh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)
Zac Hatfield-Dodds [Tue, 3 May 2022 20:52:30 +0000 (14:52 -0600)] 
gh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)

Fixes #92062.

3 years agogh-91321: Fix PyModuleDef_HEAD_INIT on C++ (#92259)
Victor Stinner [Tue, 3 May 2022 20:40:20 +0000 (22:40 +0200)] 
gh-91321: Fix PyModuleDef_HEAD_INIT on C++ (#92259)

The PyModuleDef_HEAD_INIT macro now uses _Py_NULL to fix C++ compiler
warnings when using it in C++.

3 years agogh-89289: Fix compiler warning in _sqlite/connection.c (#92258)
Erlend Egeberg Aasland [Tue, 3 May 2022 20:21:56 +0000 (14:21 -0600)] 
gh-89289: Fix compiler warning in _sqlite/connection.c (#92258)

3 years agogh-92206: Improve scoping of sqlite3 bind param functions (#92250)
Erlend Egeberg Aasland [Tue, 3 May 2022 20:00:39 +0000 (14:00 -0600)] 
gh-92206: Improve scoping of sqlite3 bind param functions (#92250)

3 years agogh-91320: Use _PyCFunction_CAST() (#92251)
Victor Stinner [Tue, 3 May 2022 19:42:14 +0000 (21:42 +0200)] 
gh-91320: Use _PyCFunction_CAST() (#92251)

Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).

Change generated by the command:

sed -i -e \
  's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \
  $(find -name "*.c")

3 years agogh-91321: Add _Py_NULL macro (#92253)
Victor Stinner [Tue, 3 May 2022 19:38:37 +0000 (21:38 +0200)] 
gh-91321: Add _Py_NULL macro (#92253)

Fix C++ compiler warnings: "zero as null pointer constant"
(clang -Wzero-as-null-pointer-constant).

* Add the _Py_NULL macro used by static inline functions to use
  nullptr in C++.
* Replace NULL with nullptr in _testcppext.cpp.

3 years agogh-81057: Get the c-analyzer tool working again. (gh-92246)
Eric Snow [Tue, 3 May 2022 19:18:27 +0000 (13:18 -0600)] 
gh-81057: Get the c-analyzer tool working again. (gh-92246)

3 years agogh-90172: add test for functools.singledispatch on Union types with None type (#92174)
Thaddeus1499 [Tue, 3 May 2022 19:17:43 +0000 (15:17 -0400)] 
gh-90172: add test for functools.singledispatch on Union types with None type (#92174)

Signed-off-by: prwatson <prwatson@redhat.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agogh-91320: Fix more old-style cast warnings in C++ (#92247)
Victor Stinner [Tue, 3 May 2022 18:47:29 +0000 (20:47 +0200)] 
gh-91320: Fix more old-style cast warnings in C++ (#92247)

Use _Py_CAST(), _Py_STATIC_CAST() and _PyASCIIObject_CAST() in
static inline functions to fix C++ compiler warnings:
"use of old-style cast" (clang -Wold-style-cast).

test_cppext now builds the C++ test extension with -Wold-style-cast.

3 years agogh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Victor Stinner [Tue, 3 May 2022 18:25:41 +0000 (20:25 +0200)] 
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)

Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).

3 years agogh-89289: Harden sqlite3.Connection init (#92214)
Erlend Egeberg Aasland [Tue, 3 May 2022 18:18:11 +0000 (12:18 -0600)] 
gh-89289: Harden sqlite3.Connection init (#92214)

- Make sure SQLite resources are freed if database open fails
- Remove unneeded branches if init is aborted

3 years agogh-89653: PEP 670: Convert PyBytes macros to functions (#91990)
Victor Stinner [Tue, 3 May 2022 18:14:58 +0000 (20:14 +0200)] 
gh-89653: PEP 670: Convert PyBytes macros to functions (#91990)

Convert the following macros to static inline functions:

* PyByteArray_AS_STRING()
* PyByteArray_GET_SIZE()
* PyBytes_AS_STRING()
* PyBytes_GET_SIZE()

Limited C API version 3.11 no longer casts arguments.

Add _PyBytes_CAST() and _PyByteArray_CAST() macros.

3 years agogh-92206: Improve scoping of sqlite3 reset statement helper (#92241)
Erlend Egeberg Aasland [Tue, 3 May 2022 17:48:24 +0000 (11:48 -0600)] 
gh-92206: Improve scoping of sqlite3 reset statement helper (#92241)

3 years agobpo-46696: Add socket.SO_INCOMING_CPU constant (#31237)
David CARLIER [Tue, 3 May 2022 17:33:11 +0000 (18:33 +0100)] 
bpo-46696: Add socket.SO_INCOMING_CPU constant (#31237)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agobpo-29890: Test IPv*Interface construction with tuple argument (#30862)
Humbled Drugman [Tue, 3 May 2022 17:21:24 +0000 (18:21 +0100)] 
bpo-29890: Test IPv*Interface construction with tuple argument (#30862)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoGH-91752: Skip test_freeze_simple_script when zlib is not available (#91758)
Abhigyan Bose [Tue, 3 May 2022 17:19:54 +0000 (22:49 +0530)] 
GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758)

Fixes GH-91752.

3 years agogh-88753: Make BooleanOptionalAction's addition of default to help more similar to...
Toshio Kuratomi [Tue, 3 May 2022 16:38:18 +0000 (09:38 -0700)] 
gh-88753: Make BooleanOptionalAction's addition of default to help more similar to other actions (#27808)

Help for other actions omit the default value if default is SUPPRESS or
already contains the special format string '%(default)'.  Add those
special cases to BooleanOptionalAction's help formatting too.

Fixes https://bugs.python.org/issue44587 so that default=SUPPRESS is not
emitted.

Fixes https://bugs.python.org/issue38956 as this code will detect
whether '%(default)s' has already been specified in the help string.

Signed-off-by: Micky Yun Chan (michiboo): <chanmickyyun@gmail.com>
Co-authored-by: Micky Yun Chan <michan@redhat.com>
3 years agogh-89452: Prefer gdbm-compat over ndbm (#92208)
Łukasz Langa [Tue, 3 May 2022 16:27:38 +0000 (18:27 +0200)] 
gh-89452: Prefer gdbm-compat over ndbm (#92208)

This makes macOS gdbm provided by Homebrew not segfault through correct
selection of the linked library (-lgdbm_compat) *AND* the correct ndbm-style
header (gdbm-ndbm.h instead of the invalid ndbm.h).

3 years agobpo-46604: fix function name in ssl module docstring (#31064)
Kossi GLOKPOR [Tue, 3 May 2022 15:56:24 +0000 (15:56 +0000)] 
bpo-46604: fix function name in ssl module docstring (#31064)

The function fetch_server_certificate is replaced by get_server_certificate in the module. I reflected the change in the module docstrings.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agogh-92031: Deoptimize Static Code at Finalization (GH-92039)
Dennis Sweeney [Tue, 3 May 2022 14:59:12 +0000 (10:59 -0400)] 
gh-92031: Deoptimize Static Code at Finalization (GH-92039)

3 years agogh-90887: posix module: Add more flags for fcopy_file (#31300)
David CARLIER [Tue, 3 May 2022 14:53:51 +0000 (15:53 +0100)] 
gh-90887: posix module: Add more flags for fcopy_file (#31300)

Closes #90887

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoGH-91355: micro-optimize Connection.send_bytes() method (gh-32247)
Ma Lin [Tue, 3 May 2022 14:41:45 +0000 (22:41 +0800)] 
GH-91355: micro-optimize Connection.send_bytes() method (gh-32247)

3 years agoLink to GitHub instead of BPO for CPython bug tracker (GH-92221)
slateny [Tue, 3 May 2022 14:40:36 +0000 (07:40 -0700)] 
Link to GitHub instead of BPO for CPython bug tracker (GH-92221)

3 years agogh-92135: Rename _Py_reinterpret_cast() to _Py_CAST() (#92230)
Victor Stinner [Tue, 3 May 2022 14:37:06 +0000 (16:37 +0200)] 
gh-92135: Rename _Py_reinterpret_cast() to _Py_CAST() (#92230)

Rename also _Py_static_cast() to _Py_STATIC_CAST().

3 years agobpo-44863: Allow generic typing.TypedDict (#27663)
Samodya Abey [Tue, 3 May 2022 13:21:42 +0000 (18:51 +0530)] 
bpo-44863: Allow generic typing.TypedDict (#27663)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
3 years agogh-92154: Expose PyCode_GetCode in the C API (GH-92168)
Ken Jin [Tue, 3 May 2022 13:13:13 +0000 (20:13 +0700)] 
gh-92154: Expose PyCode_GetCode in the C API (GH-92168)

3 years agogh-92206: Improve scoping of sqlite3 register cursor helper (#92212)
Erlend Egeberg Aasland [Tue, 3 May 2022 12:33:24 +0000 (06:33 -0600)] 
gh-92206: Improve scoping of sqlite3 register cursor helper (#92212)

3 years agoDependabot: only bump actions for major versions (#92186)
Hugo van Kemenade [Tue, 3 May 2022 12:33:03 +0000 (15:33 +0300)] 
Dependabot: only bump actions for major versions (#92186)

3 years agogh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560)
Carey Metcalfe [Tue, 3 May 2022 12:18:18 +0000 (08:18 -0400)] 
gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560)

Since the underlying file-like objects (either `io.BytesIO`,
or a true file object) all implement the `io.IOBase`
interface, the `SpooledTemporaryFile` should as well.

Additionally, since the underlying file object will either be an
instance of an `io.BufferedIOBase` (for binary mode) or an
`io.TextIOBase` (for text mode), methods for these classes were also
implemented.

In every case, the required methods and properties are simply delegated
to the underlying file object.

Co-authored-by: Gary Fernie <Gary.Fernie@skyscanner.net>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
3 years agobpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface...
Thomas Cellerier [Tue, 3 May 2022 12:12:58 +0000 (14:12 +0200)] 
bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (#30642)

`IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of
(address description, netmask) as the address parameter.
When the tuple-based address is used errors are not propagated
correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments:

In [7]: ipaddress.ip_network(("192.168.100.0", "fooo"))
        ...
TypeError: not all arguments converted during string formatting

Compared to:

In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo"))
        ...
NetmaskValueError: 'foo' is not a valid netmask

Use an f-string to make sure the error is always properly formatted.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoThe stdev calculation is more accurate computing its own mean (#92220)
Raymond Hettinger [Tue, 3 May 2022 08:41:46 +0000 (03:41 -0500)] 
The stdev calculation is more accurate computing its own mean (#92220)