Commit Graph

122410 Commits

Author SHA1 Message Date
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
Mathijs Mortimer 5adf78f546
Clarify that dklen is expected in bytes for the hashlib functions (GH-106624) 2024-05-22 11:51:25 +03:00
Alyssa Coghlan 31d61a75c9
DOCS: fix error in exec namespace note (gh-119378)
When updating the new exec note added in gh-119235 as part of the
PEP 667 general docs PR, I suggested a workaround that isn't valid.

The first half of the note is still reasonable, so just omit the invalid text.
2024-05-22 06:38:06 +00:00
Aya Elsayed 5091c4400c
gh-118911: Trailing whitespace in a block shouldn't prevent the user from terminating the code block (#119355)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 07:56:35 +02:00
Pablo Galindo Salgado e6572e8f98
gh-111201: Speed up paste mode in the REPL (#119341)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 07:28:32 +02:00
Arnon Yaari cd516cd1f5
gh-111201: auto-indentation in _pyrepl (#119348)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 06:21:14 +02:00
Jelle Zijlstra e9875ecb5d
gh-119180: PEP 649: Add __annotate__ attributes (#119209) 2024-05-22 04:38:12 +02:00
Eugene Triguba 73ab83b27f
gh-119357: Increase test coverage for keymap in _pyrepl (#119358)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 04:36:01 +02:00
Lysandros Nikolaou c886bece3b
gh-111201: Add append to screen method to avoid recalculation (#119274)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 04:35:44 +02:00
Batuhan Taskaya d065edfb66
gh-60191: Implement ast.compare (#19211)
* bpo-15987: Implement ast.compare

Add a compare() function that compares two ASTs for structural equality. There are two set of attributes on AST node objects, fields and attributes. The fields are always compared, since they represent the actual structure of the code. The attributes can be optionally be included in the comparison. Attributes capture things like line numbers of column offsets, so comparing them involves test whether the layout of the program text is the same. Since whitespace seems inessential for comparing ASTs, the default is to compare fields but not attributes.

ASTs are just Python objects that can be modified in arbitrary ways. The API for ASTs is under-specified in the presence of user modifications to objects. The comparison respects modifications to fields and attributes, and to _fields and _attributes attributes. A user could create obviously malformed objects, and the code will probably fail with an AttributeError when that happens. (For example, adding "spam" to _fields but not adding a "spam" attribute to the object.) 

Co-authored-by: Jeremy Hylton <jeremy@alum.mit.edu>
2024-05-22 01:39:26 +00:00
Landon Wood 0e3c8cda1f
gh-110383: Align dict.get(), .fromkeys(), and .setdefault() docs with docstrings (#119330) 2024-05-22 01:15:40 +00:00
Jelle Zijlstra 98e855fcc1
gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)
The PEP 649 implementation will require a way to load NotImplementedError
from the bytecode. @markshannon suggested implementing this by converting
LOAD_ASSERTION_ERROR into a more general mechanism for loading constants.

This PR adds this new opcode. I will work on the rest of the implementation
of the PEP separately.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-05-22 00:46:39 +00:00
Koudai Aono 506b1a3ff6
gh-119205: Fix autocompletion bug in new repl (#119229)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-21 23:22:21 +00:00
Pablo Galindo Salgado a3e4fec873
gh-118893: Evaluate all statements in the new REPL separately (#119318)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-21 23:16:56 +00:00
Brett Simmers 9fa206aaec
Docs: Add central references to free-threading-related options (#119017) 2024-05-21 17:49:23 -04:00
Irit Katriel 6e9863d7a3
gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (#119216) 2024-05-21 20:42:51 +00:00
Nice Zombies b64182550f
gh-118507 : Refactor `nt._path_is*` to improve applicability for other cases (GH-118755) 2024-05-21 21:36:36 +01:00
Victor Stinner de8f530841
gh-119102: Fix REPL for dumb terminal (#119332)
The site module gets the __main__ module to get _pyrepl.__main__.
2024-05-21 20:33:52 +00:00
Lysandros Nikolaou 561ff1fa71
gh-111201: Remove readline dependency from the PyREPL (#119262) 2024-05-21 22:30:45 +02:00
Josh Cannon e3ed574f6a
gh-90562: Mention slots pitfall in dataclass docs (#107391)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-21 19:37:32 +00:00
Serhiy Storchaka 10b1bd926a
gh-119189: Add yet more tests for mixed Fraction arithmetic (GH-119298) 2024-05-21 22:28:05 +03:00
Xie Yanbo b7f45a9332
Fix typos in documentation (#119295) 2024-05-21 18:35:05 +00:00
Victor Stinner f6da790122
gh-111389: Add PyHASH_MULTIPLIER constant (#119214) 2024-05-21 19:51:51 +02:00
Arnon Yaari 87939bd579
gh-117657: Fix itertools.count thread safety (#119268)
Fix itertools.count in free-threading mode
2024-05-21 10:16:34 -07:00
Irit Katriel 77ff28bb67
gh-109176: replace _PyFrame_OpAlreadyRan by an assertion that the frame is complete. (#119234) 2024-05-21 17:08:51 +00:00
Eugene Triguba f49df4f486
gh-119306: Break up _pyrepl tests (#119307) 2024-05-21 18:44:09 +02:00
Yan Yanchii e03dde5a24
gh-113978: Ignore warnings on text completion inside REPL (#113979) 2024-05-21 18:28:21 +02:00
Blaise Pabon 9db2fd7eda
GH-110383: Improve Tutorial for Input Ouput (#119230)
Co-authored-by: edson duarte <eduarte.uatach@gmail.com>
2024-05-21 16:25:37 +00:00
Daniel Williams 62a29be5bb
gh-110383: Document `socket.makefile()` accepts combined modes (#119150)
The supported mode values are 'r', 'w', and 'b', or a combination of those.
2024-05-21 16:23:50 +00:00
Alastair Stanley 0398d93392
gh-119035: Add Ctrl+← and Ctrl+→ word-skipping keybindings to new repl (#119248)
add word-skipping ctrl keybindings to new repl
2024-05-21 18:17:41 +02:00
Savannah Ostrowski c4722cd057
GH-119292: Add job to JIT CI to build and test with --disable-gil (GH-119293)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-21 11:00:52 -04:00
Donghee Na ab4263a82a
gh-119053: Implement the fast path for list.__getitem__ (gh-119112) 2024-05-21 09:49:18 -04:00
Victor Stinner 73f4a58d36
gh-119102: Fix REPL for dumb terminal (#119269)
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide
if _pyrepl.write_history_file() can be used.
2024-05-21 13:53:20 +01:00
Nikita Sobolev b365332906
Use `fail-fast: false` in `mypy.yml` (#119297)
See docs about this setting: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
2024-05-21 07:52:43 -04:00
Alyssa Coghlan e870c852c0
gh-74929: PEP 667 general docs update (gh-119201)
* expand on What's New entry for PEP 667 (including porting notes)
* define 'optimized scope' as a glossary term
* cover comprehensions and generator expressions in locals() docs
* review all mentions of "locals" in documentation (updating if needed)
* review all mentions of "f_locals" in documentation (updating if needed)
2024-05-21 03:32:15 +00:00
Wulian233 538ed5e481
gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry (#119175)
------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-05-20 23:32:00 -04:00
Melanie Arbor 172690227e
gh-102136: Add -m to options that work with -i (GH-119271)
* GH-102136: Add -m to options that work with -i

* Linting
2024-05-20 19:38:33 -04:00
Alex Waygood 423bbcbbc4
gh-108267 Fix another dataclasses docs typo (#119277) 2024-05-20 22:34:57 +00:00