The site module gets the __main__ module to get _pyrepl.__main__.
(cherry picked from commit de8f530841)
Co-authored-by: Victor Stinner <vstinner@python.org>
The supported mode values are 'r', 'w', and 'b', or a combination of those.
(cherry picked from commit 62a29be5bb)
Co-authored-by: Daniel Williams <dann0a@gmail.com>
(cherry picked from commit c4722cd057)
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-119053: Implement the fast path for list.__getitem__ (gh-119112)
(cherry picked from commit ab4263a82a)
Co-authored-by: Donghee Na <donghee.na@python.org>
gh-119102: Fix REPL for dumb terminal (GH-119269)
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide
if _pyrepl.write_history_file() can be used.
(cherry picked from commit 73f4a58d36)
Co-authored-by: Victor Stinner <vstinner@python.org>
* 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)
(cherry picked from commit e870c852c0)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
gh-118912: Remove description of issue fixed in 3.5 from autospeccing guide (GH-119232)
* Remove description of issue fixed in 3.5 from autospeccing guide
* Make autospeccing note text more succint and lint whitespace
* Add linting changes (missed in last commit)
---------
(cherry picked from commit 7e57640c7e)
Co-authored-by: Shauna <shaunagm@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
gh-119050: Add XML support to libregrtest refleak checker (GH-119148)
regrtest test runner: Add XML support to the refleak checker
(-R option).
* run_unittest() now stores XML elements as string, rather than
objects, in support.junit_xml_list.
* runtest_refleak() now saves/restores XML strings before/after
checking for reference leaks. Save XML into a temporary file.
(cherry picked from commit 9257731f5d)
Co-authored-by: Victor Stinner <vstinner@python.org>
Use correct markup in unittest.mock.reset_mock documentation (GH-119207)
(cherry picked from commit 6b80a5b20f)
Co-authored-by: Tialo <65392801+Tialo@users.noreply.github.com>
* Fix for email.generator.Generator with whitespace between encoded words.
email.generator.Generator currently does not handle whitespace between
encoded words correctly when the encoded words span multiple lines. The
current generator will create an encoded word for each line. If the end
of the line happens to correspond with the end real word in the
plaintext, the generator will place an unencoded space at the start of
the subsequent lines to represent the whitespace between the plaintext
words.
A compliant decoder will strip all the whitespace from between two
encoded words which leads to missing spaces in the round-tripped
output.
The fix for this is to make sure that whitespace between two encoded
words ends up inside of one or the other of the encoded words. This
fix places the space inside of the second encoded word.
A second problem happens with continuation lines. A continuation line that
starts with whitespace and is followed by a non-encoded word is fine because
the newline between such continuation lines is defined as condensing to
a single space character. When the continuation line starts with whitespace
followed by an encoded word, however, the RFCs specify that the word is run
together with the encoded word on the previous line. This is because normal
words are filded on syntactic breaks by encoded words are not.
The solution to this is to add the whitespace to the start of the encoded word
on the continuation line.
Test cases are from GH-92081
* Rename a variable so it's not confused with the final variable.
(cherry picked from commit a6fdb31b67)
Co-authored-by: Toshio Kuratomi <a.badger@gmail.com>
DOCS: Suggest always calling exec with a globals argument and no locals argument (GH-119235)
Many users think they want a locals argument for various reasons but they do not
understand that it makes code be treated as a class definition. They do not want
their code treated as a class definition and get surprised. The reason not
to pass locals specifically is that the following code raises a `NameError`:
```py
exec("""
def f():
print("hi")
f()
def g():
f()
g()
""", {}, {})
```
The reason not to leave out globals is as follows:
```py
def t():
exec("""
def f():
print("hi")
f()
def g():
f()
g()
""")
```
(cherry picked from commit 7e1a130b8f)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Fix typo in `_pyrepl.pager`: `tempfilepager` should be `tempfile_pager`
The name with no underscore doesn't exist.
(cherry picked from commit 05e1dce76d)
Co-authored-by: Thanos <111999343+Sachaa-Thanasius@users.noreply.github.com>
gh-119121: Fix and test `async.staggered.staggered_race` (GH-119173)
(cherry picked from commit 16b46ebd2b)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
(cherry picked from commit 3c28510b98)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-118447: Fix FreeBSD test failures. (GH-119170)
Apparently only macOS requires read permission to call `readlink()` on a
symlink.
(cherry picked from commit 4b76671728)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Nobody has been using a Sun machine for a long time. When I saw
this sentence in a lightning talk just now, I thought it was talking
about sending Python code on a spacecraft.
(cherry picked from commit 697465ff88)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gh-119050: Add type hints to libregrtest/results.py (GH-119144)
Sort also 'omitted' in TestResults.display_result().
(cherry picked from commit 30b4e9f9c4)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-119132: Update sys.version to identify free-threaded or not. (gh-119134)
(cherry picked from commit c141d43937)
Co-authored-by: Donghee Na <donghee.na@python.org>
docs: make mimalloc license text literal (GH-119046)
(cherry picked from commit 691429702f)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
gh-119132: Log sys._is_gil_enabled() in test.pythoninfo (GH-119140)
(cherry picked from commit 74072a3ffc)
Co-authored-by: Victor Stinner <vstinner@python.org>
The source line was not displayed if the warnings module had not yet
been imported.
(cherry picked from commit 100c7ab00a)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Use literal syntax in origin property (GH-119029)
(cherry picked from commit 66b73e9724)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>