Commit Graph

26108 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
Michael Droettboom adcb6a6055
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.
2022-05-05 20:59:45 -07:00
Victor Stinner 299692afd8
gh-88279: Deprecate PySys_SetArgvEx() (#92363)
Deprecate the following C functions:

* PySys_SetArgv()
* PySys_SetArgvEx()
* PySys_SetPath()
2022-05-06 05:24:29 +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
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 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
Alexey Izbyshev 58573ffba0
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.
2022-05-05 09:46:19 -07:00
Soumendra Ganguly ae553b3561
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>
2022-05-05 09:04:44 -07: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
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
Joshua Herman 000a072318
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>
2022-05-04 07:38:01 -06: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
Victor Stinner 14243369b5
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.
2022-05-04 11:59:01 +02:00
Sam Denton 465fdc02a3
gh-67248: cmd: Sort miscellaneous help topics (#92254)
Closes #67248
2022-05-03 21:36:52 -06:00
Inada Naoki 6dcfd6c5e3
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.
2022-05-04 10:01:15 +09: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
David CARLIER d5dfcd4489
bpo-46696: Add socket.SO_INCOMING_CPU constant (#31237)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 11:33:11 -06: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
Łukasz Langa 6c25bf07e8
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).
2022-05-03 18:27:38 +02:00
Dennis Sweeney b156578bd6
gh-92031: Deoptimize Static Code at Finalization (GH-92039) 2022-05-03 08:59:12 -06:00
David CARLIER 04dc4b06a3
gh-90887: posix module: Add more flags for fcopy_file (#31300)
Closes #90887

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 08:53:51 -06: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
Ken Jin 6c7249f265
gh-92154: Expose PyCode_GetCode in the C API (GH-92168) 2022-05-03 21:13:13 +08: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
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
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
kbeldan 4bed9c47bd
gh-92032: Add soft keywords to rlcompleter (#92029)
Let the interpreter autocomplete soft-keywords, ATM the PEP-634 'match'
/ 'case' / '_' (wildcard pattern).

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-02 16:36:29 -06:00
Géry Ogam 2d30adee72
bpo-46285: Add command-line option -p/--protocol to module http.server (#30999)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-02 16:28:45 -06:00
Nikita Sobolev cb6c6648be
bpo-46547: remove leaking vars into `pydoc.Helper` namespace (#30957)
Fixes #90705
2022-05-02 16:25:52 -06:00
themylogin 9c204b148f
bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (#31408)
Do not store `ProcessPoolExecutor` work item exception traceback that prevents
exception frame locals from being garbage collected.
2022-05-02 14:24:39 -06:00
larryhastings c96da83a8e
Fix the closure argument to PyEval_EvalCodeEx. (GH-92175) 2022-05-02 14:08:22 -06:00
Jelle Zijlstra ff88f7e007
gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059) 2022-05-02 13:21:59 -06:00
Mark Dickinson 0ed91a26fe
gh-90213: Speed up right shifts of negative integers (GH-30277) 2022-05-02 11:19:03 -06:00
Sam Ezeh 4b297a9ffd
gh-91783: Document security considerations for shutil.unpack_archive (#91844) 2022-05-02 11:15:04 -06:00