gh-136057: Allow step and next to step over for loops (GH-136160)
(cherry picked from commit 8be3b2f479)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This fixes an assertion error when the new computed start is not an integer.
(cherry picked from commit 10bec7c1eb)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
gh-140938: Raise ValueError for infinite inputs to stdev/pstdev (GH-141531)
Raise ValueError for infinite inputs to stdev/pstdev
(cherry picked from commit f0a8bc737a)
---
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-137969: Fix double evaluation of `ForwardRef`s which rely on globals (GH-140974)
(cherry picked from commit 209eaff68c)
Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
Split existing tests on smaller methods and move them to separate class.
Rename variable "content" to "it".
Use BytesIO instead of StringIO.
Add few more tests.
(cherry picked from commit 2fbd396666)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-140260: fix data race in `_struct` module initialization with subinterpreters (GH-140909)
(cherry picked from commit 63548b3699)
Co-authored-by: Shamil <ashm.tech@proton.me>
Fix error in assertion which causes failure if pos is equal to PY_SSIZE_T_MAX.
Fix undefined behavior in read() and readinto() if pos is larger that the size
of the underlying buffer.
(cherry picked from commit 7d54374f9c)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
gh-138621: Increase test coverage for csv.DictReader and csv.Sniffer (GH-138622)
* Increase test coverage for csv.DictReader and csv.Sniffer
Previously there were no tests for the DictReader fieldnames
setter, the case where a StopIteration was encountered when trying
to determine the fieldnames from the content or the case where
Sniffer could not find a delimiter.
* Revert whitespace change to comment
* Add a test that csv.Sniffer.has_header checks up to 20 rows
* Replace name and age with letter and offset
* Address review comment
---------
(cherry picked from commit 0e88be6f55)
Co-authored-by: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gh-140193: Forward port test_exec_set_nomemory_hang from 3.13 (GH-140187)
* chore: test_exec_set_nomemory_hang from 3.13
* fix: apply comments
* Update Lib/test/test_exceptions.py
* Update Lib/test/test_exceptions.py
* fix: windows too long name 60 times is enough
---------
(cherry picked from commit 0f09bda643)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
gh-141174: Improve `annotationlib._Stringifier` test coverage (GH-141220)
* Test `_Stringifier.__convert_to_ast()` for containers
* Test partial evaluation of `ForwardRef`s in `_Stringifier`
(cherry picked from commit 55ea132313)
Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
gh-141174: Improve `ForwardRef` test coverage (GH-141175)
* Test unsupported format in ForwardRef.evaluate()
* Test dict cell closure with multiple variables
* Test all options in ForwardRef repr
* Test ForwardRef being a final class
(cherry picked from commit 19b573025e)
Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
gh-141174: Improve `annotationlib.call_annotate_function()` test coverage (GH-141176)
* Test passing unsupported Format values to call_annotate_function()
* Test call_evaluate_function with fake globals that raise errors
* Fix typo and comparison in test_fake_global_evaluation
(cherry picked from commit 1110e8f6a4)
Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
gh-141174: Improve `annotationlib.get_annotations()` test coverage (GH-141286)
* Test `get_annotations(format=Format.VALUE)` for stringized annotations on custom objects
* Test `get_annotations(format=Format.VALUE)` for stringized annotations on wrapped partial functions
* Update test_stringized_annotations_with_star_unpack() to actually test stringized annotations
* Test __annotate__ returning a non-dict
* Test passing globals and locals to stringized `get_annotations()`
(cherry picked from commit 06b62282c7)
Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
gh-140530: fix a reference leak in an error path for `raise exc from cause` (GH-140908)
Fix a reference leak in `raise E from T` when `T` is an exception
subtype for which `T.__new__` does not return an exception instance.
(cherry picked from commit 0c77e7c23b)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-100218: correctly set `errno` when `socket.if_{nametoindex,indextoname}` raise `OSError` (GH-140905)
Previously, socket.if_nametoindex() and socket.if_indextoname() could raise
an `OSError` with a `None` errno. Now, the errno from libc is propagated.
(cherry picked from commit 3ce2d57b2f)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Document that ensure_ascii=True forces escaping not only non-ASCII, but also
non-printable characters (the only affected ASCII character is U+007F).
* Ensure that the help output for the json module does not exceed 80
columns (except one long line in an example and generated lines).
* Add more tests.
(cherry picked from commit 7e90bac3cc)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-139246: zero-width word paste can be wrong in default repl (GH-139254)
(cherry picked from commit 4e6dba0ef7)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
Co-authored-by: grayjk <grayjk@gmail.com>
gh-140734: fix off-by-one error when comparing to `_SUN_PATH_MAX` (GH-140903)
The limit includes a NULL terminator.
(cherry picked from commit 9a19900673)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Minor fixes to `idle.rst` and regenerate `help.html` (GH-140037)
(cherry picked from commit 4e6e208be9)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Update selected RFC 2822 references to RFC 5322
RFC 2822 was obsoleted by RFC 5322 in 2008. This updates references
to use the current standard in documentation, docstrings, and comments.
It preserves RFC 2822 references in legacy API components to maintain their
historical context.
RFC 822 → RFC 2822 → RFC 5322 progression is explained where relevant.
In some places specific sections of RFC are referenced where it seems helpful.
Scout rule was applied in some places and RFC mentions format was
normalized in doc strings and comments.
(cherry picked from commit ce1bb85d28)
gh-140348: Fix using | on unusual objects plus Unions (GH-140383)
(cherry picked from commit 7a9437d986)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gh-135307: Fix email error when policy max_line_length is set to 0 or None (GH-135367)
(cherry picked from commit 6d45cd8dbb)
RDM: Like the change made in a earlier PR to the folder, we can/must use 'maxlen' as a stand in for 'unlimited' when computing line lengths when max_line_length is 0 or None; otherwise the computation results in a traceback.
Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>