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.
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>
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.
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>
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.
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>
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.
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>
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>
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
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.
* 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).
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`.
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.
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.
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.
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.
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.
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.
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>