Commit Graph

29097 Commits

Author SHA1 Message Date
tahia 8974a63f5e
bpo-18108: Adding dir_fd and follow_symlinks keyword args to shutil.chown (GH-15811)
* Adding dir_fd and follow_symlinks keyword args to shutil.chown
* Extending test_shutil.TestShutil.test_chown to include new kwargs
* Updating shutil.chown documentation

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
2024-04-22 18:23:36 +00:00
Erlend E. Aasland 550483b7e6
gh-117995: Don't raise DeprecationWarnings for indexed nameless params (#118001)
Filter out '?NNN' placeholders when looking for named params.

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-04-22 08:43:20 +02:00
Serhiy Storchaka 51ef89cd9a
gh-115961: Add name and mode attributes for compressed file-like objects (GH-116036)
* Add name and mode attributes for compressed and archived file-like objects
  in modules bz2, lzma, tarfile and zipfile.
* Change the value of the mode attribute of GzipFile from integer (1 or 2)
  to string ('rb' or 'wb').
* Change the value of the mode attribute of ZipExtFile from 'r' to 'rb'.
2024-04-21 11:46:39 +03:00
Andrew Cassidy 5fa5b7facb
gh-91629 Use conf.d configs and fish_add_path to set the PATH when installing for the Fish shell. (GH-91630)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-04-21 02:52:58 -04:00
Russell Keith-Magee df987331d8
gh-114099: Formalize Tier 3 status of iOS (GH-118020) 2024-04-20 23:04:08 -04:00
Barney Gale 15fbd53ba9
GH-112855: Speed up `pathlib.PurePath` pickling (#112856)
The second item in the tuple returned from `__reduce__()` is a tuple of arguments to supply to path constructor. Previously we returned the `parts` tuple here, which entailed joining, parsing and normalising the path object, and produced a compact pickle representation.

With this patch, we instead return a tuple of paths that were originally given to the path constructor. This makes pickling much faster (at the expense of compactness).

It's worth noting that, in the olden times, pathlib performed this parsing/normalization up-front in every case, and so using `parts` for pickling was almost free. Nowadays pathlib only parses/normalises paths when it's necessary or advantageous to do so (e.g. computing a path parent, or iterating over a directory, respectively).
2024-04-20 17:46:52 +01:00
Savannah Ostrowski d8f350309d
GH-115874: Fix segfault in FutureIter_dealloc (GH-117741) 2024-04-19 22:30:52 +00:00
Russell Keith-Magee ab99438900
gh-114099: Modify preprocessor symbol usage to support older macOS SDKs (GH-118073)
Co-authored-by: Joshua Root jmr@macports.org
2024-04-19 14:56:33 -04:00
Alex Waygood 1e3e7ce11e
gh-114053: Fix bad interaction of PEP-695, PEP-563 and ``get_type_hints`` (#118009)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-04-19 13:03:44 +00:00
lyc8503 15b3555e4a
gh-116931: Add fileobj parameter check for Tarfile.addfile (GH-117988)
Tarfile.addfile now throws an ValueError when the user passes
in a non-zero size tarinfo but does not provide a fileobj,
instead of writing an incomplete entry.
2024-04-19 11:41:51 +00:00
Tian Gao a09e472992
gh-117535: Change unknown filename of warnings from `sys` to `<sys>` (#118018) 2024-04-18 20:50:09 -07:00
Victor Stinner 340a02b590
gh-117987: Restore several functions removed in Python 3.13 alpha 1 (GH-117993)
Restore these functions removed in Python 3.13 alpha 1:

* Py_SetPythonHome()
* Py_SetProgramName()
* PySys_SetArgvEx()
* PySys_SetArgv()
2024-04-18 15:20:38 +02:00
lyc8503 0a0756c5ed
gh-116932: Remove redundant NEWS entry (#118040) 2024-04-18 13:22:18 +01:00
lyc8503 468b9aeb92
gh-116932: Add note on how to report python documentation theme bugs (GH-117989) 2024-04-18 10:45:25 +02:00
Nice Zombies b848b944bb
gh-117641: Improve the perfornance of posixpath.commonpath() (#117652) 2024-04-18 09:26:34 +02:00
Serhiy Storchaka deaecb88fa
gh-80361: Fix TypeError in email.Message.get_payload() (GH-117994)
It was raised when the charset is rfc2231 encoded, e.g.:

   Content-Type: text/plain; charset*=ansi-x3.4-1968''utf-8
2024-04-17 19:31:26 +03:00
Irit Katriel c179c0e6cb
gh-117680: make _PyInstructionSequence a PyObject and use it in tests (#117629) 2024-04-17 16:42:04 +01:00
CF Bolz-Tereick 5a0209fc23
GH-100242: bring functools.py partial implementation more in line with C code (GH-100244)
in partial.__new__, before checking for the existence of the attribute
'func', first check whether the argument is an instance of partial.
2024-04-17 15:34:46 +02:00
Victor Stinner 75eed5b373
gh-117929: Restore removed PyEval_InitThreads() function (#117931) 2024-04-17 15:01:28 +02:00
Mariusz Felisiak b9b3c455f0
gh-115009: Update macOS installer to use SQLite 3.45.3 (#117443) 2024-04-17 13:59:38 +02:00
Ivan Savin 1aa8bbe62f
bpo-40944: Fix IndexError when parse emails with truncated Message-ID, address, routes, etc (GH-20790)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-17 10:14:22 +00:00
Serhiy Storchaka aec1dac4ef
gh-117313: Fix re-folding email messages containing non-standard line separators (GH-117369)
Only treat '\n', '\r' and '\r\n' as line separators in re-folding the email
messages.  Preserve control characters '\v', '\f', '\x1c', '\x1d' and '\x1e'
and Unicode line separators '\x85', '\u2028' and '\u2029' as is.
2024-04-17 13:00:25 +03:00
Serhiy Storchaka 4e502a4997
gh-117394: Speed up os.path.ismount() on Posix (GH-117447)
It is now 2-3 times faster if the user has permissions.
2024-04-17 12:58:19 +03:00
Serhiy Storchaka 51132da0c4
gh-117503: Fix support of non-ASCII user names in posixpath.expanduser() (GH-117504)
They are now supported in bytes paths as well as in string paths.
2024-04-17 12:53:40 +03:00
Joshua Root 8515fd79fe
gh-117845: Detect libedit hook function signature in configure (#117870)
Older libedit versions (like Apple's) use a different type signature
for rl_startup_hook and rl_pre_input_hook. Add a configure check to
determine which signature is accepted by introducing the
Py_RL_STARTUP_HOOK_TAKES_ARGS macro in pyconfig.h.
2024-04-17 11:26:10 +02:00
Serhiy Storchaka f74e51229c
gh-86650: Fix IndexError when parse emails with invalid Message-ID (GH-117934)
In particularly, one-off addresses generated by Microsoft Outlook:
https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/one-off-addresses

Co-authored-by: fsc-eriker <72394365+fsc-eriker@users.noreply.github.com>
2024-04-17 10:44:41 +03:00
tsufeki 8cc9adbfdd
gh-75171: Fix parsing invalid email address headers starting or ending with a dot (GH-15600)
Co-authored-by: Tim Bell <timothybell@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-17 10:39:15 +03:00
Seth Michael Larson d70ee13e57
gh-112844: Fix xz CPE identifier (GH-117656) 2024-04-16 23:11:43 +01:00
Mariusz Felisiak de0dc68b82
gh-115009: Update Windows installer to use SQLite 3.45.3 (GH-117445) 2024-04-16 23:10:05 +01:00
Victor Stinner 919784737c
gh-117645: Increase WASI stack size from 512 KiB to 8 MiB (#117674)
Increase also the initial memory from 10 MiB to 20 MiB.

Reenable test_dynamic on WASI build.
2024-04-16 23:26:54 +02:00
Victor Stinner 3fe03ccea6
gh-117755: Fix mimalloc for huge allocation on s390x (#117809)
Fix mimalloc allocator for huge memory allocation (around
8,589,934,592 GiB) on s390x.

Abort allocation early in mimalloc if the number of slices doesn't
fit into uint32_t, to prevent a integer overflow (cast 64-bit
size_t to uint32_t).
2024-04-16 20:34:12 +00:00
Jeff Glass acf69e09c6
gh-115178: Add Counts of UOp Pairs to pystats (GH-115181) 2024-04-16 14:27:18 +01:00
Mark Shannon c053d52edd
GH-115776: Static object are immortal, so mark them as such. (GH-117673) 2024-04-16 12:51:41 +01:00
Alex Waygood cff0a2db00
gh-117691: Add an appropriate stacklevel for PEP-706 tarfile deprecation warnings (GH-117872) 2024-04-16 13:36:00 +02:00
Douglas Thor 1316692e8c
gh-102402: Fix floating point math issue by using `time.time_ns()` in `logging.LogRecord` (GH-102412) 2024-04-16 10:44:57 +01:00
Inada Naoki 6dc661bc9f
gh-77102: site: try utf-8 and fallback to locale encoding when reading .pth file (#117802) 2024-04-16 12:56:16 +09:00
Hugo van Kemenade 3375282bb8
Docs: add link roles with Sphinx extlinks (#117850)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-15 21:22:00 +03:00
Steve Dower 185999bb3a
gh-90329: Add _winapi.GetLongPathName and GetShortPathName and use in venv to reduce warnings (GH-117817) 2024-04-15 15:36:06 +01:00
Mark Shannon 784e076a10
GH-117750: When clearing object's dict, clear inline values but leave dict attached (GH-117808) 2024-04-15 14:45:05 +01:00
Nice Zombies 9ee94d1391
gh-117636: Remove redundant type check in `os.path.join()` (#117638) 2024-04-14 14:04:14 -07:00
Jason R. Coombs 9c93b7402b
gh-117348: restore import time performance of configparser (#117703)
Reduces import time by over 50% (10431µs vs 4350µs on Apple M3 Pro).
2024-04-14 11:10:09 +00:00
Barney Gale a74f117dab
GH-115060: Speed up `pathlib.Path.glob()` by omitting initial `stat()` (#117831)
Since 6258844c, paths that might not exist can be fed into pathlib's
globbing implementation, which will call `os.scandir()` / `os.lstat()` only
when strictly necessary. This allows us to drop an initial `self.is_dir()`
call, which saves a `stat()`.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-04-14 00:08:03 +01:00
Hugo van Kemenade 56ed979d04
gh-68583: webbrowser: replace `getopt` with `argparse`, add long options (#117047) 2024-04-13 08:56:56 -06:00
Michiel W. Beijen 022ba6d161
gh-102247: http: support rfc9110 status codes (GH-117611)
rfc9110 obsoletes the earlier rfc 7231. This document also includes some
status codes that were previously only used for WebDAV and assigns more
generic names to these status codes.

ref: https://www.rfc-editor.org/rfc/rfc9110.html#name-changes-from-rfc-7231

- http.HTTPStatus.CONTENT_TOO_LARGE (413, previously
  REQUEST_ENTITY_TOO_LARGE)
- http.HTTPStatus.URI_TOO_LONG (414, previously REQUEST_URI_TOO_LONG)
- http.HTTPStatus.RANGE_NOT_SATISFYABLE (416, previously
  REQUEST_RANGE_NOT_SATISFYABLE)
- http.HTTPStatus.UNPROCESSABLE_CONTENT (422, previously
  UNPROCESSABLE_ENTITY)

The new constants are added to http.HTTPStatus and the old constant names are
preserved for backwards compatibility.

References in documentation to the obsoleted rfc 7231 are updated
2024-04-13 07:33:20 -07:00
Barney Gale 30f0643e36
GH-117727: Speed up `pathlib.Path.iterdir()` by using `os.scandir()` (#117728)
Replace use of `os.listdir()` with `os.scandir()`. Forgo setting `_drv`,
`_root` and `_tail_cached`, as these usually aren't needed. Use
`os.DirEntry.path` to set `_str`.
2024-04-12 22:02:39 +00:00
Barney Gale 0eb52f5f26
GH-115060: Speed up `pathlib.Path.glob()` by not scanning literal parts (#117732)
Don't bother calling `os.scandir()` to scan for literal pattern segments,
like `foo` in `foo/*.py`. Instead, append the segment(s) as-is and call
through to the next selector with `exists=False`, which signals that the
path might not exist. Subsequent selectors will call `os.scandir()` or
`os.lstat()` to filter out missing paths as needed.
2024-04-12 22:19:21 +01:00
Erlend E. Aasland deb921f851
gh-117431: Adapt bytes and bytearray .find() and friends to Argument Clinic (#117502)
This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used. The following bytes and bytearray methods are adapted:

- count()
- find()
- index()
- rfind()
- rindex()

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2024-04-12 07:40:55 +00:00
Will Childs-Klein b8eaad3009
gh-117233: Detect support for several hashes at hashlib build time (GH-117234)
Detect libcrypto BLAKE2, Shake, SHA3, and Truncated-SHA512 support at hashlib build time

## BLAKE2

While OpenSSL supports both "b" and "s" variants of the BLAKE2 hash
function, other cryptographic libraries may lack support for one or both
of the variants. This commit modifies `hashlib`'s C code to detect
whether or not the linked libcrypto supports each BLAKE2 variant, and
elides references to each variant's NID accordingly. In cases where the
underlying libcrypto doesn't fully support BLAKE2, CPython's
`./configure` script can be given the following flag to use CPython's
interned BLAKE2 implementation: `--with-builtin-hashlib-hashes=blake2`.

## SHA3, Shake, & truncated SHA512.

Detect BLAKE2, SHA3, Shake, & truncated SHA512 support in the
OpenSSL-ish libcrypto library at build time.  This helps allow hashlib's
`_hashopenssl` to be used with libraries that do not to support every
algorithm that upstream OpenSSL does.  Such as AWS-LC & BoringSSL.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2024-04-11 16:49:41 +02:00
Bruce Merry 01a51f9494
gh-117722: Fix Stream.readuntil with non-bytes buffer objects (#117723)
gh-16429 introduced support for an iterable of separators in
Stream.readuntil. Since bytes-like types are themselves iterable, this
can introduce ambiguities in deciding whether the argument is an
iterator of separators or a singleton separator. In gh-16429, only 'bytes'
was considered a singleton, but this will break code that passes other
buffer object types.

Fix it by only supporting tuples rather than arbitrary iterables.

Closes gh-117722.
2024-04-11 07:41:55 -07:00
Erlend E. Aasland 044dc496e0
gh-117709: Add vectorcall support for str() with positional-only arguments (#117746)
Fall back to tp_call() for cases when arguments are passed by name.

Co-authored-by: Donghee Na <donghee.na@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-04-11 13:55:37 +00:00