Commit Graph

48538 Commits

Author SHA1 Message Date
Alexey Izbyshev 85354ed78c
gh-92112: Fix crash triggered by an evil custom `mro()` (#92113) 2022-05-05 21:01:15 -07:00
Victor Stinner 329afe78c3
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).
2022-05-06 03:41:24 +02:00
Paul Ganssle 1303f8c927
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.
2022-05-05 18:31:24 -06:00
Victor Stinner ada8b6d1b1
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.
2022-05-06 01:34:11 +02:00
Gregory P. Smith f6dd14c653
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>
2022-05-05 16:22:32 -07:00
Christian Heimes 49fda0cc51
gh-70363: Emscripten cannot fstat renamed spool file (GH-92354) 2022-05-06 01:10:37 +02:00
cibofo 9a0a7b4868
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>
2022-05-05 15:39:02 -07:00
Christian Heimes bb35d6504a
gh-92135: test_cppext requires subprocess (GH-92349) 2022-05-06 00:08:43 +02:00
Christian Heimes c0012df0f6
gh-64783: Don't check value of SIG_DFL and SIG_IGN (#92350) 2022-05-06 00:07:53 +02:00
Christian Heimes 8122e8d501
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``.
2022-05-05 21:24:16 +02:00
Serhiy Storchaka 1ed8d035f1
gh-87390: Fix starred tuple equality and pickling (GH-92337) 2022-05-05 20:16:06 +03:00
Irit Katriel e65e587f93
gh-92118: Add test for traceback when exception is modified by (Async)ExitStack.__exit__ (GH-92339) 2022-05-05 17:39:33 +01:00
Vlad Hoi 42fee931d0
bpo-43827: Make arguments to abc.ABCMeta.__new__ pos-only (#25385)
To avoid conflicts with `__init__subclass__`.
2022-05-05 06:40:01 -07:00
Géry Ogam a95138b2c5
bpo-43857: Improve the AttributeError message when deleting a missing attribute (#25424)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-05 06:37:26 -07:00
Raymond Hettinger 5212cbc261
Clean-up and simplify median_grouped(). Vastly improve its docstring. (#92324) 2022-05-05 03:01:07 -05:00
DjMorgul b885b8f4be
Allow translating argument error messages (#17169) 2022-05-05 00:32:49 -05:00
Michael J. Sullivan a918589578
bpo-46764: Fix wrapping bound method with @classmethod (#31367) 2022-05-04 23:00:21 -05:00
Irit Katriel e61330b44f
gh-92118: fix traceback of exceptions propagated from inside a contextlib.contextmanager (GH-92202) 2022-05-04 19:40:47 +01:00
Mark Shannon f8a2fab212
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
Serhiy Storchaka 9d20e1af40
gh-92107: Add tests that subscription works on arbitrary named tuple types (GH-92304) 2022-05-04 17:06:50 +03:00
Erlend Egeberg Aasland 090819ec5f
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.
2022-05-04 07:16:01 -06:00
Raymond Hettinger d20bb33f78
Fix renamed "total" variable (#92287)
* Fix renamed "total" variable
* Keep nan/inf handling consistent between versions
2022-05-03 23:22:04 -05:00
Sam Denton 465fdc02a3
gh-67248: cmd: Sort miscellaneous help topics (#92254)
Closes #67248
2022-05-03 21:36:52 -06:00
Raymond Hettinger 9badc86fb7
Compute from_sample() in a single pass over the data (#92284) 2022-05-03 21:22:26 -05:00
Géry Ogam dfb1b9da8a
bpo-47029: Fix BrokenPipeError in multiprocessing.Queue at garbage collection and explicit close (#31913) 2022-05-03 17:49:57 -06:00
Erlend Egeberg Aasland f629dcfe83
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>
2022-05-03 17:03:06 -06:00
Kumar Aditya e8d7661ff2
GH-91173: disable frozen modules in debug builds (#92023) 2022-05-03 15:20:13 -07:00
Kabir Kwatra 48c6165c28
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
```
2022-05-03 15:14:25 -07:00
kixorz 6dee69577a
bpo-45639: Add webp and avif image formats to mimetypes (#29259)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 15:17:57 -06:00
Zac Hatfield-Dodds 65f88a6ef7
gh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)
Fixes #92062.
2022-05-03 13:52:30 -07:00
Victor Stinner 551d02b3e6
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.
2022-05-03 21:38:37 +02:00
Thaddeus1499 f03d3dd9af
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>
2022-05-03 13:17:43 -06:00
Victor Stinner ff3e9cdf33
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.
2022-05-03 20:47:29 +02:00
Victor Stinner b270b82f11
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
2022-05-03 20:25:41 +02:00
Humbled Drugman b295a92c50
bpo-29890: Test IPv*Interface construction with tuple argument (#30862)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 11:21:24 -06:00
Abhigyan Bose 77e7a04cd2
GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758)
Fixes GH-91752.
2022-05-03 10:19:54 -07:00
Toshio Kuratomi 20490d5018
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>
2022-05-03 18:38:18 +02:00
Kossi GLOKPOR feca9bbd1f
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>
2022-05-03 09:56:24 -06:00
Dennis Sweeney b156578bd6
gh-92031: Deoptimize Static Code at Finalization (GH-92039) 2022-05-03 08:59:12 -06:00
Ma Lin 1699128c48
GH-91355: micro-optimize Connection.send_bytes() method (gh-32247) 2022-05-03 23:41:45 +09:00
Samodya Abey f6f36cc269
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>
2022-05-03 07:21:42 -06:00
Carey Metcalfe 78e70be331
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>
2022-05-03 21:18:18 +09:00
Thomas Cellerier 52dc9c3066
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>
2022-05-03 06:12:58 -06:00
Raymond Hettinger ec8d3adb99
The stdev calculation is more accurate computing its own mean (#92220) 2022-05-03 03:41:46 -05:00
Hugo van Kemenade 9b027d4cea
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) 2022-05-03 10:17:54 +03:00
Ruben Vorderman a73fc73ff7
bpo-46267: Test compresslevel in gzip.compress (#30416)
Fixes #90425
2022-05-02 23:11:06 -06:00
Itai Steinherz 39e6b8ae6a
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) 2022-05-03 00:19:13 +01:00
Shantanu ebb8b512e9
gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656)
This mirrors logic in typing.get_args. The trickiness comes from how we
flatten args in collections.abc.Callable, see
https://bugs.python.org/issue42195
2022-05-02 17:08:28 -06:00
Ethan Smith aff8c4f488
gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930) 2022-05-02 15:51:34 -07:00
Serhiy Storchaka b04e02c57f
bpo-43923: Add support for generic typing.NamedTuple (#92027) 2022-05-02 16:41:23 -06:00