133042 Commits

Author SHA1 Message Date
Pablo Galindo Salgado
09117bc317
gh-153569: return token spans and unify decoded source storage (#156482)
Represent token boundaries as logical source offsets with explicit start
and end locations, and adapt pegen and _tokenize to consume them.

Use SourceText to own decoded input across all reader modes. Streaming
readers discard consumed windows while preserving logical offsets and
reusing the allocation. Prepared and interactive input retain their source.

Force source relocation on growth in debug builds and add coverage for
formatted-string growth, interactive input, storage reuse, and offset
limits. Scanner positions remain pointers, rebased when storage moves.
2026-09-06 21:15:44 +01:00
Bénédikt Tran
878b5e256a
gh-155835: fix digest_size data race on BLAKE-2 objects (#155839) 2026-09-06 18:49:09 +02:00
Bénédikt Tran
90ac5398e4
gh-155835: fix digest_size and block_size data races on SHA-3 objects (#155838) 2026-09-06 16:47:11 +02:00
Bénédikt Tran
20d278623d
gh-155843: properly initialize HMAC objects to prevent crashes after allocation failures (#155845) 2026-09-06 16:30:57 +02:00
Timofei Ivankov
83dbe6ae9f
gh-156512: Fix asyncio calling connection_lost() twice from resume_writing() (#156657) 2026-09-06 16:03:49 +05:30
Aarni Koskela
b707ce6196
gh-156310: Make the iter() sequence fallback iterator safe in free-threaded build (#156311)
Co-authored-by: Neil Schemenauer <nas@arctrix.com>
2026-09-06 16:00:51 +05:30
Serhiy Storchaka
57594aae5e
gh-154511: Consolidate IDLE's mouse wheel handling in util (GH-156974)
Move wheel_event there from idlelib.tree and add x11_buttons(widget) and
bind_wheel(widget, func), used by the editor, the tree and test_sidebar.
wheel_event now reads the direction from the event, not the platform.

Move its test from test_tree, and test the fix_ functions of util too.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 09:15:08 +03:00
James Morris
7cd63cddad
no-issue: Add separate docstring for frozendict (gh-156986) 2026-09-06 10:12:41 +09:00
Owen Carey
7a918411a3
gh-127296: Document that argparse count action starts from a non-zero default (#156908)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-09-05 17:00:22 +00:00
Timofei Ivankov
e208bf0dda
gh-156988: Fix asyncio call graph breaking at sync generators (#156991) 2026-09-05 16:48:38 +00:00
Irit Katriel
14a93f4d91
gh-156091: Fix crash compiling deeply nested inlined comprehensions (#156957) 2026-09-05 16:01:05 +00:00
tonghuaroot (童话)
ba4a0790aa
gh-156400: Close the socket or pipe when transport creation fails in asyncio datagram/pipe endpoints (#156401) 2026-09-05 15:46:11 +00:00
Ivy Xu
e620377918
gh-156970: Set Mock.return_value's docstring (#156971)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-09-05 15:07:19 +01:00
Victor Stinner
5141621d44
gh-129813: Fix typo in byteswriter_resize() (#156938)
The intent is to test "resize and overallocate", even if in practice
"resize & overallocate" is the same (both variables are either 0 or
1). Use "&&" to better describe the intent of the test.
2026-09-05 13:22:55 +02:00
Thomas Grainger
0ea2971c6e
gh-127057: reschedule proactor datagram read loop after ConnectionResetError (#156726) 2026-09-05 10:52:14 +00:00
Irit Katriel
e56f86fb6c
gh-143493: fix cleanup on errors in codegen_comprehension (#156374) 2026-09-04 17:15:44 +00:00
Vyron Vasileiadis
3a7a22b5b0
gh-156187: Fix the warning stacklevel inside a nested set operand (GH-156188) 2026-09-04 16:57:07 +00:00
Loïc Simon
1a2e3a034d
gh-140870: Add PyREPL's module attributes import completion feature to What's New 3.15 (#156782)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-09-04 15:58:12 +01:00
Stan Ulbrych
1860130962
gh-156583: Remove unnecessary test_sundry (#156642) 2026-09-04 15:44:09 +01:00
Tomasz Kazimierczak
bc977f450b
gh-118150: difflib: expose autojunk flag from SequenceMatcher to public methods and functions (GH-153959) 2026-09-04 14:20:30 +00:00
Serhiy Storchaka
aaae15c35b
gh-155907: Fix error handling in the marshal C API (GH-155909)
Functions reading marshalled data from a FILE* now raise OSError for I/O
errors and KeyboardInterrupt for interrupted reading, instead of EOFError.

PyMarshal_WriteObjectToFile() and PyMarshal_WriteLongToFile() now detect
I/O errors and interrupted writing instead of ignoring them.
PyMarshal_WriteObjectToFile() now also sets the error indicator if the
value cannot be marshalled.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 16:44:57 +03:00
Petr Viktorin
7d71b3eae3
gh-97850: Add load_module() removal to 3.15 What's New (GH-156418) 2026-09-04 15:21:01 +02:00
Petr Viktorin
2632610ec1
gh-142349: Clarify that sys.lazy_modules may contain extra items (GH-155547)
As an author of a debugging/introspection tool, I need an
honest description of what's in `lazy_modules` and what
kind of post-processing I'm expected to do.
2026-09-04 15:19:47 +02:00
Serhiy Storchaka
59a691361c
gh-156894: Fix the position of syntax errors which cover a range (GH-156901)
The callers of _PyTokenizer_syntaxerror_known_range() pass columns in bytes,
but SyntaxError.offset and end_offset are columns in characters.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 14:14:13 +03:00
Terry Jan Reedy
e50d23389b
gh-156896: Stop scrubbing tkinker submodules upon idlelib.run import (#156915)
Instead, invoke the scrubbing within run.main, which is called after
the import when starting the IDLE user process.

To manually test that scrub_tkinter_submodules
is called when proper, start (or restart) Shell, enter
`import tkinter; dir(tkinter), and check that that font,
messagebox, ttk, and the dialog modules are missing.

It is obvious from the code that the function is not otherwise
called.  To test anyway, continue with `import tkinter.ttk;
import idlelib.run; tkinter.ttk` and check for proper output.
2026-09-04 07:10:07 -04:00
Petr Viktorin
112560ee34
gh-155561: Use multi-phase init for Modules/_testlimitedcapi.c (GH-156052)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-04 11:32:15 +02:00
Serhiy Storchaka
5f7d709612
gh-156886: Fix spurious ZeroDivisionError for complex powers (GH-156887)
cos() and sin() of an infinite phase set errno to EDOM, which
complex_pow() reported as a zero base.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 08:10:28 +00:00
Stan Ulbrych
7b4364de25
Add an AGENTS.md pointing to our policy (#156838)
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Lukasz Langa <ambv@meta.com>
Co-authored-by: Muse Code (Meta Muse Spark)
2026-09-03 15:20:52 -07:00
John
0625799652
gh-136061: Simplify idlelib.editor.EditorWindow.load_extension methodname processing (GH-134874) 2026-09-03 21:09:46 +00:00
A5rocks
cb54488523
gh-156439: Gate socket.if_{nametoindex, indextoname} on respective OS capability (#156708)
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2026-09-03 20:49:40 +01:00
An Long
c8ea8676d9
gh-94242: Clarify comments for _MAX_WINDOWS_WORKERS in concurrent.futures.process (#135537) 2026-09-03 19:10:24 +02:00
Serhiy Storchaka
1414d2ac6f
gh-89735: Document requirements for the *headers* argument (GH-155640)
Both handlers look up the header name in lowercase, and the basic
one needs get_all(), so a plain dict does not work.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:48:32 +03:00
Victor Stinner
4dd225e940
gh-144446: Fix _PyFrame_GetFrameObject() for test_cppext (C++) (#156893)
Do an explicit cast to fix the C++ compiler warning:

  In file included from Include/internal/pycore_object.h:13,
                   from Include/internal/pycore_cell.h:5,
                   from extension.cpp:29:
  Include/internal/pycore_interpframe.h: In function 'PyFrameObject*
  _PyFrame_GetFrameObject(_PyInterpreterFrame*)':
  Include/internal/pycore_pyatomic_ft_wrappers.h:33:32: error:
  invalid conversion from 'void*' to 'PyFrameObject*' {aka '_frame*'}
  [-fpermissive]
     33 |     _Py_atomic_load_ptr_acquire(&value)
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
        |                                |
        |                                void*
  Include/internal/pycore_interpframe.h:348:26: note: in expansion of
  macro 'FT_ATOMIC_LOAD_PTR_ACQUIRE'
    348 |     PyFrameObject *res = FT_ATOMIC_LOAD_PTR_ACQUIRE(frame->frame_obj);
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
2026-09-03 16:17:07 +02:00
cui fliter
e13ecaeca2
gh-155141: Improve stack-use estimation for keyword calls (#155785) 2026-09-03 13:06:35 +00:00
Serhiy Storchaka
50ed1ec6ca
gh-128805: Clarify the deprecation notice of xml.etree.cElementTree (GH-156779)
It was read as deprecating xml.etree.ElementTree itself, because the page
does not mention cElementTree anywhere else.
2026-09-03 12:29:47 +03:00
Serhiy Storchaka
050fd7dd32
gh-126273: Add missing docstrings in the C implementation of xml.etree (GH-156783)
Copy the docstrings of the Element, TreeBuilder and XMLParser classes and
their methods from the Python implementation.  Element, TreeBuilder and
XMLParser now also have the text signature.
2026-09-03 12:26:28 +03:00
Serhiy Storchaka
d56f7e245d
gh-117999: Fix small integer powers of complex numbers (GH-124243)
* Fix the sign of zero components in the result. E.g. complex(1,-0.0)**2
  now evaluates to complex(1,-0.0) instead of complex(1,-0.0).
* Fix negative small integer powers of infinite complex numbers. E.g.
  complex(inf)**-1 now evaluates to complex(0,-0.0) instead of
  complex(nan,nan).
* Powers of infinite numbers no longer raise OverflowError. E.g.
  complex(inf)**1 now evaluates to complex(inf) and complex(inf)**0.5
  now evaluates to complex(inf,nan).
2026-09-03 11:42:56 +03:00
Thomas Grainger
1059e8072e
gh-82406: Add 3.10.6 change notes for inspect.is*function (GH-94987)
Document when these functions started checking code flags for "duck-typed" function-like objects.
2026-09-03 10:23:25 +02:00
Petr Viktorin
1d28836e43
Reword atexit docs (#156086)
For the `atexit` module:

- Move common info from `register` to the module level (a lot of this
  was duplicated -- less maintainable and harder to read)
- Use *interpreter shutdown* consistently, introducing it as a more
  general term for the old docs' *program termination*.
- Use the term *exit handler* consistently
- Move warning for a mitigated footgun to a change entry
- Add a new warning about keeping things usable

Similarly clarify docs for the `atexit` attribute in `weakref`.
2026-09-03 10:20:52 +02:00
Serhiy Storchaka
161054cbfe
gh-156347: Fix wrong statements in the curses documentation (GH-156354)
window.encoding does not encode the string arguments on a build with
wide-character support: the curses library converts the characters itself.

In the HOWTO: getch() returns -1, not curses.ERR, when there is no input,
and half-delay mode does the same as no-delay mode.  getkey() returns the
key name only for a special key.  leaveok() is not a synonym for curs_set().
getstr() returns a bytes object, interprets the erase and kill characters,
and limits bytes.  The ACS_* constants are not all larger than 255.

Also document get_wch() before getch(), mention complexchar and complexstr,
and read whole characters in the examples.
2026-09-03 10:18:08 +03:00
Serhiy Storchaka
5056ac552a
gh-156797: Escape the namespace URI in xml.sax.saxutils.XMLGenerator (GH-156799)
The namespace declarations were the only attribute values written without
quoteattr(), so a URI containing "&", "<" or a quote character produced a
document which cannot be parsed.
2026-09-03 00:10:23 +03:00
Serhiy Storchaka
d16a691111
gh-156821: Fix inaccuracies in the xml.parsers.expat documentation (GH-156822)
Corrected, in the documentation and in the docstrings:

* GetInputContext() returns bytes, and its result extends to the end of the
  buffered input;
* Parse() accepts a bytes-like object as well as a string, and ignores the
  encoding declaration for a string;
* ParseFile() only supports binary files;
* XML_ERROR_XML_DECL was described as XML_ERROR_NO_ELEMENTS;
* UnparsedEntityDeclHandler is not restricted to Expat 1.2;
* GetSpecifiedAttributeCount() needs ordered_attributes.

Documented the intern parameter and attribute, namespace_prefixes,
SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and EXPAT_VERSION,
version_info and features.

Removed obsolete notes about Expat 1.2 and 1.95.0, and :noindex: from the
content model constants, which are not documented elsewhere; completed the
list of attribute types in AttlistDeclHandler.
2026-09-02 21:57:57 +03:00
Kumar Aditya
db92901405
gh-144446: Fix thread safety of gi_frame, cr_frame and ag_frame in free-threading (#156037) 2026-09-02 23:26:04 +05:30
Serhiy Storchaka
09ff4d443f
gh-156765: Fix inaccuracies in the ElementTree documentation (GH-156766)
Corrected:

* the parser argument of iterparse() is an instance of XMLParser or its
  subclass, not a subclass;
* feed() accepts a string as well as encoded data;
* keys() and items() do not return a list in the Python implementation, and
  the attributes are no longer returned in an arbitrary order.

Removed the claims that the element tag, the attribute names and values, the
text of a comment and the data of TreeBuilder.data() can be bytes.  It is a
Python 2 leftover.  Documented instead what they can be.
2026-09-02 17:18:32 +00:00
Serhiy Storchaka
c2658214da
gh-156839: Fix inaccuracies in the xml.dom.pulldom documentation (GH-156840)
Corrected:

* the node types for the PROCESSING_INSTRUCTION and COMMENT events;
* the return value of getEvent() at the end of the document;
* the type of the argument of parseString();
* references to the xml.dom interfaces, written as xml.dom.minidom.

Documented:

* the event constants, which were referenced but never described;
* PullDOM, SAX2DOM and the documentFactory argument;
* the arguments of DOMEventStream, its reset() and clear() methods.

Added docstrings to the module, the classes and their public methods, and
removed the commented out paragraph about pulldom in the xml.dom
documentation, which was never rendered and refers to a site which no longer
exists.
2026-09-02 19:50:58 +03:00
Serhiy Storchaka
6f7941e0aa
gh-156829: Fix inaccuracies in the xml.sax documentation (GH-156830)
Corrected:

* the name of the errorHandler argument of parse() and parseString();
* the default value of the parser_list argument of make_parser();
* the description of the source of parse();
* the types of the declaration-handler and dom-node properties;
* the way in which names are interned;
* the description of IncrementalParser.

Documented:

* default_parser_list and SAXReaderNotAvailable;
* property_encoding and property_interning_dict;
* IncrementalParser.prepareParser();
* XMLFilterBase.getParent() and setParent();
* which features and properties the parser based on Expat does not support.

Added missing docstrings to parse(), parseString(), AttributesImpl and
XMLGenerator.
2026-09-02 19:49:18 +03:00
Victor Stinner
d7f107a767
gh-155742: Use PyBytesWriter in xml.etree (#155749)
Replace soft deprecated PyBytes_FromStringAndSize() with
PyBytesWriter.
2026-09-02 17:57:31 +02:00
Sergey B Kirpichev
2271fbb369
gh-153740: Refine test for _Float16: check support from libm (#156815) 2026-09-02 17:21:22 +02:00
Petr Viktorin
7d701ebb4c
gh-141984: Move generator iterator reference out of syntax docs (GH-154884)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-09-02 16:09:32 +02:00
Petr Viktorin
3c7e975001
gh-156414: Document tomllib's limits & "extensions" (GH-156415)
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2026-09-02 15:59:57 +02:00