Commit Graph

122397 Commits

Author SHA1 Message Date
Jason R. Coombs 5482a939ac
Re-order imports to align with zipp 3.18.2 (#119587) 2024-05-27 01:33:16 +00:00
Tian Gao 5d04cc50e5
gh-102864: Add switching frame test for pdb (#119564) 2024-05-26 17:05:23 +00:00
Alex Waygood 0220663e26
gh-119562: Remove unused private string constants from `ast.py` (#119576) 2024-05-26 13:31:02 +00:00
scoder 70b07aa415
gh-111997: Fix argument count for LINE event and clarify type of argument counts. (#119179) 2024-05-26 12:37:33 +00:00
Alex Waygood 008bc04dcb
gh-119562: Remove AST nodes deprecated since Python 3.8 (#119563) 2024-05-26 12:34:48 +00:00
Wulian233 b5b7dc98c9
Update README and layout.html from 3.13 to 3.14 (#119539)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-26 11:26:59 +00:00
Ned Batchelder d25954dff5
docs: fix a few typos identified by codespell (#119516) 2024-05-25 18:13:31 -07:00
Barney Gale e418fc3a6e
GH-82805: Fix handling of single-dot file extensions in pathlib (#118952)
pathlib now treats "`.`" as a valid file extension (suffix). This brings
it in line with `os.path.splitext()`.

In the (private) pathlib ABCs, we add a new `ParserBase.splitext()` method
that splits a path into a `(root, ext)` pair, like `os.path.splitext()`.
This method is called by `PurePathBase.stem`, `suffix`, etc. In a future
version of pathlib, we might make these base classes public, and so users
will be able to define their own `splitext()` method to control file
extension splitting.

In `pathlib.PurePath` we add optimised `stem`, `suffix` and `suffixes`
properties that don't use `splitext()`, which avoids computing the path
base name twice.
2024-05-25 21:01:36 +01:00
Eric Snow 0c5ebe13e9
gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)
The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def.  I've added a test to make sure we don't make that assumption again.
2024-05-25 19:30:48 +00:00
Alex Waygood 4b7eb321bc
gh-99180: Make `StackSummary.should_show_carets` private (#119554) 2024-05-25 17:08:32 +00:00
Pablo Galindo Salgado 6b6c1a904f
Add codeowners for PYREPL (#119550) 2024-05-25 16:21:07 +00:00
Pablo Galindo Salgado e3bac04c37
gh-119548: Add a 'clear' command to the REPL (#119549) 2024-05-25 16:15:54 +00:00
Hugo van Kemenade a531fd7fdb
FAQ: Add reference to Python version numbering scheme (#119225) 2024-05-25 08:13:17 -06:00
Serhiy Storchaka 08e65430aa
gh-111999: Fix the signature of str.format_map() (#119540) 2024-05-25 06:21:11 -07:00
Tim Peters de19694cfb
gh-119105: Differ.compare is too slow [for degenerate cases] (#119492)
``_fancy_replace()`` is no longer recursive. and a single call does a worst-case linear number of ratio() computations instead of quadratic. This renders toothless a universe of pathological cases. Some inputs may produce different output, but that's rare, and I didn't find a case where the final diff appeared to be of materially worse quality. To the contrary, by refusing to even consider synching on lines "far apart", there was more easy-to-digest locality in the output.
2024-05-24 22:08:21 -05:00
Jelle Zijlstra 84be5244de
gh-119180: Update the magic number (#119397)
PR #119321 added a comment about the magic number bump
but did not actually apply the new magic number.
2024-05-24 17:32:17 -07:00
Raymond Hettinger 49c3ade4f3
Misc improvement to the docs for itertools (gh-119529) 2024-05-24 16:58:24 -05:00
Barney Gale 81d6336230
GH-119054: Add "Querying file type and status" section to pathlib docs (#119055)
Add a dedicated subsection for `Path.stat()`-related methods, specifically
`stat()`, `lstat()`, `exists()`, `is_*()`, and `samefile()`.
2024-05-24 19:35:13 +00:00
Kirill Podoprigora 045e195c76
Regen ``Doc/requirements-oldest-sphinx.txt`` (#119520) 2024-05-24 13:30:32 -06:00
Nice Zombies 96b392df30
gh-118263: Add additional arguments to path_t (Argument Clinic type) in posixmodule (GH-118355) 2024-05-24 19:04:17 +01:00
Germán Méndez Bravo f0ed1863bd
gh-112075: Fix dict thread safety issues (#119288)
Fix dict thread safety issues
2024-05-24 10:39:06 -07:00
Alyssa Coghlan bf5b6467f8
GH-119496: accept UTF-8 BOM in .pth files (GH-119503)
`Out-File -Encoding utf8` and similar commands in Windows Powershell 5.1 emit
UTF-8 with a BOM marker, which the regular `utf-8` codec decodes incorrectly.

`utf-8-sig` accepts a BOM, but also works correctly without one.

This change also makes .pth files match the way Python source files are handled.

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2024-05-24 14:29:19 +00:00
Victor Stinner 92fab3356f
gh-69214: Fix fcntl.ioctl() request type (#119498)
Use an 'unsigned long' instead of an 'unsigned int' for the request
parameter of fcntl.ioctl() to support requests larger than UINT_MAX.
2024-05-24 14:31:40 +02:00
Brandt Bucher b48a3dbff4
GH-113464: Run the JIT interpreter before any other JIT CI (GH-119466) 2024-05-24 03:13:41 +00:00
Carlos Meza 0867bce457
gh-119317: findall instead of traverse for docutils nodes (#119319) 2024-05-24 05:04:12 +03:00
Petr Viktorin ffa24aab10
Clarify base64.a85encode docs: *wrapcols* doesn't count the newline (GH-119409) 2024-05-24 00:11:45 +02:00
Victor Stinner e94dbe4ed8
gh-119461: Fix ThreadedVSOCKSocketStreamTest (#119465)
Add socket.VMADDR_CID_LOCAL constant.

Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the host
address or the "any" address, use the local communication address
(loopback): VMADDR_CID_LOCAL.

On Linux 6.9, apparently, the /dev/vsock device is now available but
get_cid() returns VMADDR_CID_ANY (-1).
2024-05-23 23:26:09 +02:00
Brett Simmers be1dfccdf2
gh-118727: Don't drop the GIL in `drop_gil()` unless the current thread holds it (#118745)
`drop_gil()` assumes that its caller is attached, which means that the current
thread holds the GIL if and only if the GIL is enabled, and the enabled-state
of the GIL won't change. This isn't true, though, because `detach_thread()`
calls `_PyEval_ReleaseLock()` after detaching and
`_PyThreadState_DeleteCurrent()` calls it after removing the current thread
from consideration for stop-the-world requests (effectively detaching it).

Fix this by remembering whether or not a thread acquired the GIL when it last
attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()`
instead of `gil->enabled`.

This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've
reenabled it.
2024-05-23 16:59:35 -04:00
Eric Snow b30d30c747
gh-117398: Statically Allocate the Datetime C-API (GH-119472) 2024-05-23 21:15:52 +02:00
Łukasz Langa 6e012ced6c
gh-119469: Fix _pyrepl reference leaks (#119470) 2024-05-23 19:28:31 +02:00
Petr Viktorin a192547dfe
gh-117142: Slightly hacky fix for memory leak of StgInfo (GH-119424)
Add a funciton that inlines PyObject_GetTypeData and skips
type-checking, so it doesn't need access to the CType_Type object.
This will break if the memory layout changes, but should
be an acceptable solution to enable ctypes in subinterpreters in
Python 3.13.

Mark _ctypes as safe for multiple interpreters

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2024-05-23 16:01:37 +00:00
Mark Shannon 406ffb5293
GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220) 2024-05-23 11:06:10 +01:00
Irit Katriel c85e352673
gh-119431: fix refleak in test_monitoring (#119444) 2024-05-23 10:21:53 +01:00
Xie Yanbo e3f5a44553
Fix typos in what's new documentation (#119448) 2024-05-23 06:41:33 +00:00
Ayato Hayashi 43807fec8d
Tiny fix: Update link for HAC algorithm (gh-118546) 2024-05-23 02:11:11 +00:00
Tim Peters 07df93de73
gh-119105: difflib.py Differ.compare is too slow [for degenerate cases] (#119376)
Track all pairs achieving the best ratio in Differ(). This repairs the "very deep recursion and cubic time" bad cases in a way that preserves previous output.
2024-05-22 18:25:08 -05:00
Dino Viehland e3bf5381fd
gh-119434: Fix culmitive errors in wrapping as lines proceed (#119435)
Fix culmitive errors in wrapping as lines proceed
2024-05-22 15:03:32 -07:00
Victor Stinner 9b422fc6af
gh-119396: Optimize PyUnicode_FromFormat() UTF-8 decoder (#119398)
Add unicode_decode_utf8_writer() to write directly characters into a
_PyUnicodeWriter writer: avoid the creation of a temporary string.
Optimize PyUnicode_FromFormat() by using the new
unicode_decode_utf8_writer().

Rename unicode_fromformat_write_cstr() to
unicode_fromformat_write_utf8().

Microbenchmark on the code:

    return PyUnicode_FromFormat(
        "%s %s %s %s %s.",
        "format", "multiple", "utf8", "short", "strings");

Result: 620 ns +- 8 ns -> 382 ns +- 2 ns: 1.62x faster.
2024-05-22 21:05:26 +00:00
Lysandros Nikolaou 14b063cbf1
gh-111201: Use calc_complete_screen after bracketed paste in PyREPL (#119432) 2024-05-22 17:02:33 -04:00
neonene e12a6780bb
gh-117142: ctypes: Clean up c-analyzer .tsv files (GH-117544)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-05-22 20:30:41 +00:00
uıɐɾ ʞ ʇɐɯɐs 2fbea81d64
gh-70795: Rework RLock documentation (#103853)
Attempted to simultaneously reduce verbosity, while more descriptively
describing behavior.

Fix links (RLock acquire/release previously linking to Lock
acquire/release, seems like bad copy pasta).

Add a seealso for with-locks.

Switch section to use bullet points.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2024-05-22 16:15:11 -04:00
Michael Vincent c9073eb1a9
gh-117505: Run ensurepip in isolated env in Windows installer (GH-118257)
ensurepip forks a subprocess to run pip itself, but that subprocess only inherits a -I isolated mode flag (see _run_pip() in Lib/ensurepip/__init__.py), not the "-E -s" flags that the installer has been using. This means that parts of ensurepip don't actually run in an isolated environment and can make incorrect decisions based on packages installed in the user site-packages.
2024-05-22 18:59:47 +01:00
Josh {*()} Rosenberg baf347d916
gh-119247: Add macros to use PySequence_Fast safely in free-threaded build (#119315)
Add `Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST` and
`Py_END_CRITICAL_SECTION_SEQUENCE_FAST` macros and update `str.join` to use
them. Also add a regression test that would crash reliably without this
patch.
2024-05-22 17:45:34 +00:00
Dino Viehland 2b3fb767be
gh-117657: Fix missing atomic in dict_resize (#119312)
Fix missing atomic in dict_resize
2024-05-22 10:38:56 -07:00
Geoffrey Thomas ef172521a9
Remove almost all unpaired backticks in docstrings (#119231)
As reported in #117847 and #115366, an unpaired backtick in a docstring
tends to confuse e.g. Sphinx running on subclasses of standard library
objects, and the typographic style of using a backtick as an opening
quote is no longer in favor. Convert almost all uses of the form

    The variable `foo' should do xyz

to

    The variable 'foo' should do xyz

and also fix up miscellaneous other unpaired backticks (extraneous /
missing characters).

No functional change is intended here other than in human-readable
docstrings.
2024-05-22 12:35:18 -04:00
Eric Snow 81865002ae
gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331)
_PyArg_Parser holds static global data generated for modules by Argument Clinic.  The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global.  In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters.  However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.

This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes.  It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime.  The solution here is to temporarily switch to the main interpreter.  The alternative would be to always statically allocate the tuple.

This change also fixes a bug where only the most recent parser was added to the global linked list.
2024-05-22 09:57:52 -06:00
Pieter Eendebak d472b4f9fa
gh-119391: Amend comment description of PyMapping_Items, PyMapping_Values and PyMapping_Keys (#119392)
The behaviour was changed in 0ccc0f6c7.
2024-05-22 08:52:36 -04:00
Serhiy Storchaka 858b9e85fc
gh-118643: Fix AttributeError in the email module (GH-119099)
Fix regression introduced in gh-100884: AttributeError when re-fold a long
address list.

Also fix more cases of incorrect encoding of the address separator in the
address list missed in gh-100884.
2024-05-22 10:17:46 +00:00
Jacob Walls aee8f03abb
Fix version number in use_load_tests deprecation reference (GH-119151)
Deprecation took place in d78742a260 (3.5)
2024-05-22 12:43:56 +03:00
Xie Yanbo 904e256292
Fix typos in NEWS entries for 3.13 (GH-119374) 2024-05-22 12:31:37 +03:00