Commit Graph

51425 Commits

Author SHA1 Message Date
Thomas Wouters 118522b972 Merge branch 'main' of https://github.com/python/cpython 2023-11-22 22:27:46 +01:00
Mark Shannon 1619f4350e
GH-111485: Sort cases in the case generator output (GH-112315) 2023-11-22 15:19:50 +00:00
Thomas Wouters 9c4347ef8b Python 3.13.0a2 2023-11-22 12:20:24 +01:00
Donghee Na 4fa376b005
gh-111863: Rename term Py_NOGIL to Py_GIL_DISABLED in sysconfig (gh-112307) 2023-11-22 10:32:43 +09:00
Junya Okabe 9d70831cb7
gh-110745: add a newline argument to pathlib.Path.read_text (#110880)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-11-21 22:32:38 +00:00
James Turk e1540ae74d
gh-112252: Fix error on unset $OSNAME in venv/activate (GH-112253) 2023-11-21 20:48:53 +05:30
Liu, An-Chi 44aa603d59
gh-57879: Increase test coverage for pstats.py (gh-111447) 2023-11-21 22:32:09 +09:00
Guido van Rossum 1995955173
gh-106529: Make FOR_ITER a viable uop (#112134)
This uses the new mechanism whereby certain uops
are replaced by others during translation,
using the `_PyUop_Replacements` table.
We further special-case the `_FOR_ITER_TIER_TWO` uop
to update the deoptimization target to point
just past the corresponding `END_FOR` opcode.

Two tiny code cleanups are also part of this PR.
2023-11-20 10:08:53 -08:00
Pablo Galindo Salgado d59feb5dbe
gh-112243: Don't include comments in f-string debug expressions (#112284) 2023-11-20 15:18:24 +00:00
Hugo van Kemenade 3b3ec0d77f
gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)
Rename Py_NOGIL to Py_GIL_DISABLED
2023-11-20 15:52:00 +02:00
Crowthebird 1c8f912ebd
bpo-45759: Better error messages for non-matching 'elif'/'else' statements (#29513) 2023-11-20 13:27:53 +00:00
Michael ce1096f974
gh-73561: Omit interface scope from IPv6 when used as Host header (#93324)
Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
2023-11-19 22:37:13 +00:00
Nikita Sobolev f8129146ef
gh-112266: Remove `(if defined)` part from `__dict__` and `__weakref__` docstrings (#112268) 2023-11-19 18:30:07 +00:00
Terry Jan Reedy 14fd86a59d
IDLE: Fix test_debugger bug and buildbot failures (#112258)
Missing "requires('gui')" causes Tk() to fail when no gui.
This caused CI Hypothesis test to fail, but I did not understand
the its error message. Then buildbots failed.

IdbTest failed on draft Bdb replacement because so different.
Simplified version works on old and new.
2023-11-19 06:39:26 +00:00
Anthony Shaw adedcfa06b
gh-79871: IDLE - Fix and test debugger module (#11451)
Add docstrings to the debugger module. Fix two bugs: initialize Idb.botframe (should be in Bdb); In Idb.in_rpc_code, check whether prev_frame is None before trying to use it. Make other code changes.

Expand test_debugger coverage from 19% to 66%.
---------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-11-18 23:20:38 -05:00
DPR 18c6929469
gh-112186: Improve test case `test_loop_is_closed_resource_warnings` (#112187) 2023-11-19 03:21:34 +00:00
Donghee Na e52cc80f7f
gh-112213: Add @critical_section target directive to Argument Clinic (gh-112232)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-19 08:05:49 +09:00
Barney Gale 607b5e30c6
GH-110109: Test pure functionality of `pathlib.Path` user subclasses (#112242)
Add `PurePathTest` as a superclass of `PathTest`, and therefore also
`PathSubclassTest`. This adds coverage of pure functionality in user
subclasses of `pathlib.Path`.

Remove `PosixPathAsPureTest` and `WindowsPathAsPureTest`, as they
now duplicate `PosixPathTest` and `WindowsPathTest`.

This makes the MROs of test unit classes match the MROs of pathlib
classes.
2023-11-18 17:06:10 +00:00
Barney Gale 9c7c8bacc1
GH-110109: Fix misplaced tests for `pathlib.WindowsPath.owner()` and `group()` (#112239)
Move test methods from `WindowsPathAsPureTest` to `WindowsPathTest` unit.
The former test unit is intended to exercise only pure path functionality.
2023-11-18 15:42:07 +00:00
Nikita Sobolev 43b1c33204
gh-111810: Fix `test_repr_deep` from `test_userlist` on WASI (#112197)
Co-authored-by: Brett Cannon <brett@python.org>
2023-11-17 16:08:23 -08:00
Brett Cannon f489ace9e7
GH-111808: Make the default value for `test.support.infinite_recursion()` conditional on compiler optimizations (GH-112223)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-11-17 15:52:11 -08:00
Nikita Sobolev 949b2cc6ea
gh-112194: Convert more examples to doctests in `typing.py` (#112195)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-17 17:56:31 +00:00
Barney Gale 9fb0f2dfee
GH-110109: Speed up `pathlib._PathBase.resolve()` (#110412)
- Add fast path to `_split_stack()`
- Skip unnecessarily resolution of the current directory when a relative
  path is given to `resolve()`
- Remove stat and target caches, which slow down most `resolve()` calls in
  practice.
- Slightly refactor code for clarity.
2023-11-17 16:58:17 +00:00
Barney Gale 2dbb2e035b
GH-110109: Churn `pathlib.PurePath` methods (#112012)
Re-arrange `pathlib.PurePath` methods in source code. No other changes.

The `PurePath` implementations of certain special methods, such as
`__eq__()` and `__hash__()`, are not usually applicable to user subclasses
of `_PathBase`. To facilitate their removal, another patch will split the
`PurePath` class into `_PurePathBase` and `PurePath`, with the latter
providing these special methods.

This patch prepares the ground for splitting `PurePath`. It's similar to
e8d77b0, which preceded splitting `Path`. By churning the methods here,
subsequent patches will be easier to review and less likely to break
things.
2023-11-17 07:32:50 -08:00
Nikita Sobolev f92ea63f6f
gh-111799: Fix `testRecursiveRepr` from `test_fileio` on WASI (GH-112181) 2023-11-16 15:12:27 -08:00
Nikita Sobolev 974847be44
gh-111800: Fix `test_recursive_repr` from `test_io` under WASI to not recurse so deeply (GH-112150) 2023-11-16 11:47:38 -08:00
Victor Stinner f66afa395a
gh-111881: Import lazily zipfile in support.script_helper (#112172)
It allows running the test suite when the zlib extension is missing.
2023-11-16 18:57:22 +01:00
Nikita Sobolev 7680da4583
gh-112155: Run `typing.py` doctests as part of `test_typing` (#112156) 2023-11-16 15:40:09 +00:00
Qua27 12c7e9d573
GH-112152: Fix typo in `typing.override` docstring (#112158) 2023-11-16 15:16:04 +00:00
Victor Stinner bd89bca9e2
gh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode (#112124)
* Run again test_ast_recursion_limit() on WASI platform.
* Add _testinternalcapi.get_c_recursion_remaining().
* Fix test_ast and test_sys_settrace: test_ast_recursion_limit() and
  test_trace_unpack_long_sequence() now adjust the maximum recursion
  depth depending on the the remaining C recursion.
2023-11-16 13:52:33 +00:00
Kushal Das 7218bac8c8
gh-111811: Fix test_recursive_repr for WASI (#112130) 2023-11-15 23:28:58 +01:00
Nikita Sobolev 422c0f0301
gh-108303: Delete `imp_dummy` test file (#112110) 2023-11-15 13:26:49 +01:00
Victor Stinner 55f3cce821
gh-111545: Test PyHash_GetFuncDef() function (#112098)
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
2023-11-15 03:41:29 +01:00
DPR e0f5127975
gh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (#111983)
Issue a ResourceWarning instead.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-11-15 01:17:51 +00:00
Serhiy Storchaka 9302f05f9a
gh-111942: Fix SystemError in the TextIOWrapper constructor (#112061)
In non-debug more the check for the "errors" argument is skipped,
and then PyUnicode_AsUTF8() can fail, but its result was not checked.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-11-14 20:02:28 +00:00
Serhiy Storchaka ee06fffd38
gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976)
* Fix crash when encoding is not string or None.
* Fix crash when both line_buffering and write_through raise exception
  when converted ti int.
* Add a number of tests for constructor and reconfigure() method
  with invalid arguments.
2023-11-14 17:37:56 +02:00
Mark Shannon a519b87958
GH-111848: Convert remaining jumps to deopts into tier 2 code. (GH-112045) 2023-11-14 15:30:33 +00:00
Victor Stinner 4f04172c92
gh-111262: Add PyDict_Pop() function (#112028)
_PyDict_Pop_KnownHash(): remove the default value and the return type
becomes an int.

Co-authored-by: Stefan Behnel <stefan_ml@behnel.de>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-11-14 12:51:00 +00:00
Tian Gao f44d6ff6e0
gh-110944: Make pdb completion work for alias and convenience vars (GH-110945) 2023-11-14 13:22:25 +01:00
Sam Gross 324531df90
gh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)
The `@critical_section` directive instructs Argument Clinic to generate calls
to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the
bound function. In `--disable-gil` builds, these calls will lock and unlock
the `self` object. They are no-ops in the default build.

This is used in one place (`_io._Buffered.close`) as a demonstration.
Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
2023-11-14 10:47:46 +00:00
Terry Jan Reedy b28bb130bb
gh-112007: Re-organize help utility intro message (#112017)
Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-11-13 14:24:03 -05:00
Barney Gale cf67ebfb31
GH-72904: Add `glob.translate()` function (#106703)
Add `glob.translate()` function that converts a pathname with shell wildcards to a regular expression. The regular expression is used by pathlib to implement `match()` and `glob()`.

This function differs from `fnmatch.translate()` in that wildcards do not match path separators by default, and that a `*` pattern segment matches precisely one path segment. When *recursive* is set to true, `**` pattern segments match any number of path segments, and `**` cannot appear outside its own segment.

In pathlib, this change speeds up directory walking (because `_make_child_relpath()` does less work), makes path objects smaller (they don't need a `_lines` slot), and removes the need for some gnarly code.

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-11-13 17:15:56 +00:00
Victor Stinner babb787047
gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)
* Split list_extend() into two sub-functions: list_extend_fast() and
  list_extend_iter().
* list_inplace_concat() no longer has to call Py_DECREF() on the
  list_extend() result, since list_extend() now returns an int.
2023-11-13 16:14:56 +00:00
Tian Gao 1c7ed7e9eb
gh-110944: Move pty helper to test.support and add basic pdb completion test (GH-111826) 2023-11-13 11:23:06 +01:00
Sergey B Kirpichev c61de456db
gh-102837: more tests for the math module (GH-111930)
Add tests to improve coverage:

* fsum: L1369, L1379, L1383, L1412
* trunc: L2081
* log: L2267
* dist: L2577, L2579
* hypot: L2632
* sumprod: L2744, L2754, L2774, L2778, L2781, L2785, L2831, L2835, L2838
* pow: L2982
* prod: L3294, L3308, L3318-3330

// line numbers wrt to 9dc4fb8204
2023-11-13 10:57:57 +01:00
Serhiy Storchaka 1d75ef6b61
gh-111999: Add signatures and improve docstrings for builtins (GH-112000) 2023-11-13 09:13:49 +02:00
Barney Gale d7cef7bc7e
GH-111429: Speed up `pathlib.PurePath.[is_]relative_to()` (#111431) 2023-11-12 22:59:17 +00:00
Irit Katriel b2af50cb02
gh-111969: refactor to make it easier to construct a dis.Instruction object (#111970) 2023-11-12 14:06:02 +00:00
Serhiy Storchaka 40752c1c1e
gh-112001: Fix test_builtins_have_signatures in test_inspect (GH-112002) 2023-11-12 13:35:31 +02:00
Stephen Gildea 38035fed9b
gh-90890: New methods to access mailbox.Maildir message info and flags (#103905)
New methods to access mailbox.Maildir message info and flags:
get_info, set_info, get_flags, set_flags, add_flag, remove_flag.

These methods speed up accessing a message's info and/or flags and are
useful when it is not necessary to access the message's contents,
as when iterating over a Maildir to find messages with specific flags.

---------

* Add more str type checking
* modernize to f-strings instead of %

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-11-11 17:41:33 +00:00