]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agogh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302)
Nikita Sobolev [Fri, 7 Jul 2023 20:42:40 +0000 (23:42 +0300)] 
gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302)

2 years agogh-104584: Replace ENTER_EXECUTOR with the original in trace projection (#106526)
Guido van Rossum [Fri, 7 Jul 2023 18:41:42 +0000 (11:41 -0700)] 
gh-104584: Replace ENTER_EXECUTOR with the original in trace projection (#106526)

2 years agoDelete dead ceval code. (gh-106486)
Benjamin Peterson [Fri, 7 Jul 2023 18:16:19 +0000 (13:16 -0500)] 
Delete dead ceval code. (gh-106486)

2 years agogh-104584: Allow unspecialized instructions in superblocks (#106497)
Guido van Rossum [Fri, 7 Jul 2023 18:03:27 +0000 (11:03 -0700)] 
gh-104584: Allow unspecialized instructions in superblocks (#106497)

This adds several of unspecialized opcodes to superblocks:

TO_BOOL, BINARY_SUBSCR, STORE_SUBSCR,
UNPACK_SEQUENCE, LOAD_GLOBAL, LOAD_ATTR,
COMPARE_OP, BINARY_OP.

While we may not want that eventually, for now this helps finding bugs.

There is a rudimentary test checking for UNPACK_SEQUENCE.

Once we're ready to undo this, that would be simple:
just replace the call to variable_used_unspecialized
with a call to variable_used (as shown in a comment).
Or add individual opcdes to FORBIDDEN_NAMES_IN_UOPS.

2 years agogh-104584: Move super-instruction special-casing to generator (#106500)
Guido van Rossum [Fri, 7 Jul 2023 17:42:10 +0000 (10:42 -0700)] 
gh-104584: Move super-instruction special-casing to generator (#106500)

Instead of special-casing specific instructions,
we add a few more special values to the 'size' field of expansions,
so in the future we can automatically handle
additional super-instructions in the generator.

2 years agogh-104683: clinic.py: refactor `Parameter` and `Function` as dataclasses (#106477)
Alex Waygood [Fri, 7 Jul 2023 13:10:07 +0000 (14:10 +0100)] 
gh-104683: clinic.py: refactor `Parameter` and `Function` as dataclasses (#106477)

2 years agogh-106503: asyncio._SelectorSocketTransport: fix cyclic reference on close(). (#106504)
Andrew Geng [Fri, 7 Jul 2023 11:41:54 +0000 (07:41 -0400)] 
gh-106503: asyncio._SelectorSocketTransport: fix cyclic reference on close(). (#106504)

2 years agoGH-106057: Handle recursion errors in inline class calls properly. (GH-106108)
Mark Shannon [Fri, 7 Jul 2023 10:09:26 +0000 (11:09 +0100)] 
GH-106057: Handle recursion errors in inline class calls properly. (GH-106108)

2 years ago gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)
Guido van Rossum [Thu, 6 Jul 2023 23:46:06 +0000 (16:46 -0700)] 
 gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)

With test.

2 years agogh-90876: Restore the ability to import multiprocessing when `sys.executable` is...
Gregory P. Smith [Thu, 6 Jul 2023 22:46:50 +0000 (15:46 -0700)] 
gh-90876: Restore the ability to import multiprocessing when `sys.executable` is `None` (#106464)

Prevent `multiprocessing.spawn` from failing to *import* in environments
where `sys.executable` is `None`.  This regressed in 3.11 with the addition
of support for path-like objects in multiprocessing.

Adds a test decorator to have tests only run when part of test_multiprocessing_spawn to `_test_multiprocessing.py` so we can start to avoid re-running the same not-global-state specific test in all 3 modes when there is no need.

2 years agogh-104584: Clean up and fix uops tests and fix crash (#106492)
Guido van Rossum [Thu, 6 Jul 2023 22:45:56 +0000 (15:45 -0700)] 
gh-104584: Clean up and fix uops tests and fix crash (#106492)

The uops test wasn't testing anything by default,
and was failing when run with -Xuops.

Made the two executor-related context managers global,
so TestUops can use them (notably `with temporary_optimizer(opt)`).

Made clear_executor() a little more thorough.

Fixed a crash upon finalizing a uop optimizer,
by adding a `tp_dealloc` handler.

2 years agocloses gh-106479: fix typo in __cplusplus macro (gh-106480)
Dustin Rodrigues [Thu, 6 Jul 2023 22:34:00 +0000 (18:34 -0400)] 
closes gh-106479: fix typo in __cplusplus macro (gh-106480)

2 years agogh-104683: clinic.py: refactor four simple classes as dataclasses (#106476)
Alex Waygood [Thu, 6 Jul 2023 21:17:12 +0000 (22:17 +0100)] 
gh-104683: clinic.py: refactor four simple classes as dataclasses (#106476)

2 years agogh-104584: Fix error handling from backedge optimization (#106484)
Guido van Rossum [Thu, 6 Jul 2023 18:39:53 +0000 (11:39 -0700)] 
gh-104584: Fix error handling from backedge optimization (#106484)

When `_PyOptimizer_BackEdge` returns `NULL`, we should restore `next_instr` (and `stack_pointer`). To accomplish this we should jump to `resume_with_error` instead of just `error`.

The problem this causes is subtle -- the only repro I have is in PR gh-106393, at commit d7df54b139bcc47f5ea094bfaa9824f79bc45adc. But the fix is real (as shown later in that PR).

While we're at it, also improve the debug output: the offsets at which traces are identified are now measured in bytes, and always show the start offset. This makes it easier to correlate executor calls with optimizer calls, and either with `dis` output.

<!-- gh-issue-number: gh-104584 -->
* Issue: gh-104584
<!-- /gh-issue-number -->

2 years agogh-106458: Mark `testthreadingmock.py` with `@requires_working_threading` (GH-106366)
Mario Corchero [Thu, 6 Jul 2023 17:54:45 +0000 (19:54 +0200)] 
gh-106458: Mark `testthreadingmock.py` with `@requires_working_threading` (GH-106366)

Mark `testthreadingmock.py` with `threading_helper.requires_working_threading`.

Also add longer delays to reduce the change of a race conditions on the tests that validate short timeouts.

2 years agoIntroduce a gate/check GHA job (#97533)
Sviatoslav Sydorenko [Thu, 6 Jul 2023 15:06:18 +0000 (17:06 +0200)] 
Introduce a gate/check GHA job (#97533)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-104683: clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout` ...
Alex Waygood [Thu, 6 Jul 2023 13:23:02 +0000 (14:23 +0100)] 
gh-104683: clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout` (#106478)

clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout`

2 years agogh-106238: Handle KeyboardInterrupt during logging._acquireLock() (GH-106239)
Ariel Eizenberg [Thu, 6 Jul 2023 07:02:22 +0000 (10:02 +0300)] 
gh-106238: Handle KeyboardInterrupt during logging._acquireLock() (GH-106239)

Co-authored-by: Ariel Eizenberg <ariel.eizenberg@pagaya.com>
2 years agoDoc: Add missing ref labels to exception groups/notes sections (#106465)
C.A.M. Gerlach [Thu, 6 Jul 2023 05:41:04 +0000 (00:41 -0500)] 
Doc: Add missing ref labels to exception groups/notes sections (#106465)

2 years agogh-105256: What's New note for comprehension over locals() (#106378)
Carl Meyer [Thu, 6 Jul 2023 00:12:21 +0000 (18:12 -0600)] 
gh-105256: What's New note for comprehension over locals() (#106378)

2 years agogh-105340: include hidden fast-locals in locals() (#105715)
Carl Meyer [Wed, 5 Jul 2023 23:05:02 +0000 (17:05 -0600)] 
gh-105340: include hidden fast-locals in locals() (#105715)

* gh-105340: include hidden fast-locals in locals()

2 years agogh-106292: restore checking __dict__ in cached_property.__get__ (#106380)
Carl Meyer [Wed, 5 Jul 2023 23:01:35 +0000 (17:01 -0600)] 
gh-106292: restore checking __dict__ in cached_property.__get__ (#106380)

* gh-106292: restore checking __dict__ in cached_property.__get__

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2 years agogh-96844: Improve error message of list.remove (gh-106455)
Dong-hee Na [Wed, 5 Jul 2023 22:19:49 +0000 (07:19 +0900)] 
gh-96844: Improve error message of list.remove (gh-106455)

2 years agoshlex docs: remove outdated note (#106463)
Jelle Zijlstra [Wed, 5 Jul 2023 20:38:53 +0000 (13:38 -0700)] 
shlex docs: remove outdated note (#106463)

As the versionchanged notice says, this note is no longer true on 3.12+.

2 years agogh-102542 Remove unused bytes object and bytes slicing (#106433)
JosephSBoyle [Wed, 5 Jul 2023 16:17:37 +0000 (17:17 +0100)] 
gh-102542 Remove unused bytes object and bytes slicing (#106433)

Remove unused bytes object and bytes slicing

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2 years agoClarify state of CancelledError in doc (#106453)
Kristján Valur Jónsson [Wed, 5 Jul 2023 15:07:02 +0000 (15:07 +0000)] 
Clarify state of CancelledError in doc (#106453)

This change makes it explicit that asyncio.CancelledError is not a subclass of Exception.

2 years agogh-64595: Fix regression in file write logic in Argument Clinic (#106449)
Erlend E. Aasland [Wed, 5 Jul 2023 11:23:22 +0000 (13:23 +0200)] 
gh-64595: Fix regression in file write logic in Argument Clinic (#106449)

Revert the two commits that introduced the regressions:

 - gh-104152
 - gh-104507

2 years agogh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (#106443)
Erlend E. Aasland [Wed, 5 Jul 2023 08:33:05 +0000 (10:33 +0200)] 
gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (#106443)

2 years agotp_flags docs: fix indentation (#106420)
Jelle Zijlstra [Wed, 5 Jul 2023 05:08:25 +0000 (22:08 -0700)] 
tp_flags docs: fix indentation (#106420)

2 years agogh-104050: Partially annotate Argument Clinic CLanguage class (#106437)
Erlend E. Aasland [Tue, 4 Jul 2023 23:07:57 +0000 (01:07 +0200)] 
gh-104050: Partially annotate Argument Clinic CLanguage class (#106437)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-106368: Add tests for formatting helpers in Argument Clinic (#106415)
Erlend E. Aasland [Tue, 4 Jul 2023 22:35:57 +0000 (00:35 +0200)] 
gh-106368: Add tests for formatting helpers in Argument Clinic (#106415)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-104050: Annotate Argument Clinic parameter permutation helpers (#106431)
Erlend E. Aasland [Tue, 4 Jul 2023 22:15:10 +0000 (00:15 +0200)] 
gh-104050: Annotate Argument Clinic parameter permutation helpers (#106431)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-104050: Annotate toplevel functions in clinic.py (#106435)
Erlend E. Aasland [Tue, 4 Jul 2023 22:13:30 +0000 (00:13 +0200)] 
gh-104050: Annotate toplevel functions in clinic.py (#106435)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h (#106434)
Guido van Rossum [Tue, 4 Jul 2023 21:42:12 +0000 (14:42 -0700)] 
gh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h (#106434)

Compilation of Python/specialize.c was broken on macOS for me by gh-106400.

2 years agoAdd some codeowners for `Tools/clinic/` (#106430)
Alex Waygood [Tue, 4 Jul 2023 19:45:32 +0000 (20:45 +0100)] 
Add some codeowners for `Tools/clinic/` (#106430)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2 years agogh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (#106423)
Nikita Sobolev [Tue, 4 Jul 2023 18:20:00 +0000 (21:20 +0300)] 
gh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (#106423)

2 years agogh-61215: Rename `wait_until_any_call` to `wait_until_any_call_with` (#106414)
Mario Corchero [Tue, 4 Jul 2023 17:34:43 +0000 (19:34 +0200)] 
gh-61215: Rename `wait_until_any_call` to `wait_until_any_call_with` (#106414)

mock: Rename `wait_until_any_call` to `wait_until_any_call_with`

Rename the method to be more explicit that it expects the args and
kwargs to wait for.

2 years agogh-106162: array: suppress warning in test_array (#106404)
Inada Naoki [Tue, 4 Jul 2023 17:02:49 +0000 (02:02 +0900)] 
gh-106162: array: suppress warning in test_array (#106404)

array: suppress warning in test_array

2 years agogh-106320: Remove _PyInterpreterState_HasFeature() (#106425)
Victor Stinner [Tue, 4 Jul 2023 16:55:45 +0000 (18:55 +0200)] 
gh-106320: Remove _PyInterpreterState_HasFeature() (#106425)

Remove the _PyInterpreterState_HasFeature() function from the C API:
move it to the internal C API (pycore_interp.h). No longer export
the function.

2 years agoGH-106360: Support very basic superblock introspection (#106422)
Mark Shannon [Tue, 4 Jul 2023 16:23:00 +0000 (17:23 +0100)] 
GH-106360: Support very basic superblock introspection (#106422)

* Add len() and indexing support to uop superblocks.

2 years agogh-106406: Fix _Py_IsInterpreterFinalizing() in _winapi.c (#106408)
Nikita Sobolev [Tue, 4 Jul 2023 14:19:20 +0000 (17:19 +0300)] 
gh-106406: Fix _Py_IsInterpreterFinalizing() in _winapi.c (#106408)

2 years agogh-106396: Special-case empty format spec to gen empty JoinedStr node (#106401)
Lysandros Nikolaou [Tue, 4 Jul 2023 12:19:08 +0000 (14:19 +0200)] 
gh-106396: Special-case empty format spec to gen empty JoinedStr node (#106401)

2 years agogh-106368: Add tests for permutation helpers in Argument Clinic (#106407)
Erlend E. Aasland [Tue, 4 Jul 2023 11:36:40 +0000 (13:36 +0200)] 
gh-106368: Add tests for permutation helpers in Argument Clinic (#106407)

Added new test class PermutationTests()

2 years agoGH-106008: Fix refleak when peepholing `None` comparisons (#106367)
Brandt Bucher [Tue, 4 Jul 2023 10:03:57 +0000 (03:03 -0700)] 
GH-106008: Fix refleak when peepholing `None` comparisons (#106367)

2 years agogh-106320: Remove private pylifecycle.h functions (#106400)
Victor Stinner [Tue, 4 Jul 2023 09:41:43 +0000 (11:41 +0200)] 
gh-106320: Remove private pylifecycle.h functions (#106400)

Remove private pylifecycle.h functions: move them to the internal C
API ( pycore_atexit.h, pycore_pylifecycle.h and pycore_signal.h). No
longer export most of these functions.

Move _testcapi.test_atexit() to _testinternalcapi.

2 years agogh-106320: Remove _PyUnicode_TransformDecimalAndSpaceToASCII() (#106398)
Victor Stinner [Tue, 4 Jul 2023 08:59:09 +0000 (10:59 +0200)] 
gh-106320: Remove _PyUnicode_TransformDecimalAndSpaceToASCII() (#106398)

Remove private _PyUnicode_TransformDecimalAndSpaceToASCII() and other
private _PyUnicode C API functions: move them to the internal C API
(pycore_unicodeobject.h). No longer most of these functions.

Replace _testcapi.unicode_transformdecimalandspacetoascii() with
_testinternal._PyUnicode_TransformDecimalAndSpaceToASCII().

2 years agogh-106320: Remove _PyBytesWriter C API (#106399)
Victor Stinner [Tue, 4 Jul 2023 08:27:23 +0000 (10:27 +0200)] 
gh-106320: Remove _PyBytesWriter C API (#106399)

Remove the _PyBytesWriter C API: move it to the internal C API
(pycore_bytesobject.h).

2 years agogh-106320: Remove private _PyUnicode codecs C API functions (#106385)
Victor Stinner [Tue, 4 Jul 2023 07:29:52 +0000 (09:29 +0200)] 
gh-106320: Remove private _PyUnicode codecs C API functions (#106385)

Remove private _PyUnicode codecs C API functions: move them to the
internal C API (pycore_unicodeobject.h). No longer export most of
these functions.

2 years agogh-106368: Increase Argument Clinic test coverage (#106389)
Erlend E. Aasland [Mon, 3 Jul 2023 23:58:27 +0000 (01:58 +0200)] 
gh-106368: Increase Argument Clinic test coverage (#106389)

Add:

- test_disallowed_gropuing__no_matching_bracket
- test_double_slash

2 years agogh-106320: Fix _PyImport_GetModuleAttr() declaration (#106386)
Victor Stinner [Mon, 3 Jul 2023 23:37:48 +0000 (01:37 +0200)] 
gh-106320: Fix _PyImport_GetModuleAttr() declaration (#106386)

Replace PyAPI_DATA() with PyAPI_FUNC().

2 years agogh-106368: Harden Argument Clinic parser tests (#106384)
Erlend E. Aasland [Mon, 3 Jul 2023 23:10:47 +0000 (01:10 +0200)] 
gh-106368: Harden Argument Clinic parser tests (#106384)

2 years agogh-106320: Remove private _PyImport C API functions (#106383)
Victor Stinner [Mon, 3 Jul 2023 23:02:07 +0000 (01:02 +0200)] 
gh-106320: Remove private _PyImport C API functions (#106383)

* Remove private _PyImport C API functions: move them to the internal
  C API (pycore_import.h).
* No longer export most of these private functions.
* _testcapi avoids private _PyImport_GetModuleAttrString().

2 years agogh-86085: Remove _PyCodec_Forget() declaration (#106377)
Victor Stinner [Mon, 3 Jul 2023 22:52:27 +0000 (00:52 +0200)] 
gh-86085: Remove _PyCodec_Forget() declaration (#106377)

The code was already removed by:
commit c9f696cb96d1c362d5cad871f61da520572d9b08.

2 years agogh-106320: Remove more private _PyUnicode C API functions (#106382)
Victor Stinner [Mon, 3 Jul 2023 22:35:46 +0000 (00:35 +0200)] 
gh-106320: Remove more private _PyUnicode C API functions (#106382)

Remove more private _PyUnicode C API functions:
move them to the internal C API (pycore_unicodeobject.h).

No longer export most pycore_unicodeobject.h functions.

2 years agogh-104050: Annotate more Argument Clinic DSLParser state methods (#106376)
Erlend E. Aasland [Mon, 3 Jul 2023 22:10:46 +0000 (00:10 +0200)] 
gh-104050: Annotate more Argument Clinic DSLParser state methods (#106376)

Annotate the following methods:

- state_parameter()
- state_parameter_docstring_start()

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-106368: Clean up Argument Clinic tests (#106373)
Erlend E. Aasland [Mon, 3 Jul 2023 21:57:20 +0000 (23:57 +0200)] 
gh-106368: Clean up Argument Clinic tests (#106373)

2 years agogh-104683: Modernise Argument Clinic parameter state machine (#106362)
Erlend E. Aasland [Mon, 3 Jul 2023 21:16:21 +0000 (23:16 +0200)] 
gh-104683: Modernise Argument Clinic parameter state machine (#106362)

Use enums and pattern matching to make the code more readable.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agoSmall speed-up for the convolve() recipe. (GH-106371)
Raymond Hettinger [Mon, 3 Jul 2023 20:38:38 +0000 (15:38 -0500)] 
Small speed-up for the convolve() recipe. (GH-106371)

2 years agoGH-106330: Fix matching of empty path in `pathlib.PurePath.match()` (GH-106331)
Barney Gale [Mon, 3 Jul 2023 20:29:44 +0000 (21:29 +0100)] 
GH-106330: Fix matching of empty path in `pathlib.PurePath.match()` (GH-106331)

We match paths using the `_lines` attribute, which is derived from the
path's string representation. The bug arises because an empty path's string
representation is `'.'` (not `''`), which is matched by the `'*'` wildcard.

2 years agoGH-104584: Fix ENTER_EXECUTOR (GH-106141)
Mark Shannon [Mon, 3 Jul 2023 20:28:27 +0000 (21:28 +0100)] 
GH-104584: Fix ENTER_EXECUTOR (GH-106141)

* Check eval-breaker in ENTER_EXECUTOR.

* Make sure that frame->prev_instr is set before entering executor.

2 years agogh-106368: Increase Argument Clinic test coverage (#106369)
Erlend E. Aasland [Mon, 3 Jul 2023 20:16:50 +0000 (22:16 +0200)] 
gh-106368: Increase Argument Clinic test coverage (#106369)

Add tests for 'self' and 'defining_class' converter requirements.

2 years agogh-106078: Move `context template` to decimal module global state (#106346)
Charlie Zhao [Mon, 3 Jul 2023 20:10:01 +0000 (04:10 +0800)] 
gh-106078: Move `context template` to decimal module global state (#106346)

2 years agogh-106290: Fix edge cases around uops (#106319)
Guido van Rossum [Mon, 3 Jul 2023 20:05:11 +0000 (13:05 -0700)] 
gh-106290: Fix edge cases around uops (#106319)

- Tweak uops debugging output
- Fix the bug from gh-106290
- Rename `SET_IP` to `SAVE_IP` (per https://github.com/faster-cpython/ideas/issues/558)
- Add a `SAVE_IP` uop at the start of the trace (ditto)
- Allow `unbound_local_error`; this gives us uops for `LOAD_FAST_CHECK`, `LOAD_CLOSURE`, and `DELETE_FAST`
- Longer traces
- Support `STORE_FAST_LOAD_FAST`, `STORE_FAST_STORE_FAST`
- Add deps on pycore_uops.h to Makefile(.pre.in)

2 years agogh-91053: make func watcher tests resilient to other func watchers (#106286)
Carl Meyer [Mon, 3 Jul 2023 14:25:22 +0000 (08:25 -0600)] 
gh-91053: make func watcher tests resilient to other func watchers (#106286)

2 years agogh-104050: Add more type hints to Argument Clinic DSLParser() (#106354)
Erlend E. Aasland [Mon, 3 Jul 2023 14:03:31 +0000 (16:03 +0200)] 
gh-104050: Add more type hints to Argument Clinic DSLParser() (#106354)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-106359: Fix corner case bugs in Argument Clinic converter parser (#106361)
Erlend E. Aasland [Mon, 3 Jul 2023 13:14:59 +0000 (15:14 +0200)] 
gh-106359: Fix corner case bugs in Argument Clinic converter parser (#106361)

DSLParser.parse_converter() could return unusable kwdicts in some rare cases

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-104146: Remove unused attr 'parameter_indent' from clinic.DLParser (#106358)
Erlend E. Aasland [Mon, 3 Jul 2023 11:00:35 +0000 (13:00 +0200)] 
gh-104146: Remove unused attr 'parameter_indent' from clinic.DLParser (#106358)

2 years agogh-106320: Remove private _PyErr C API functions (#106356)
Victor Stinner [Mon, 3 Jul 2023 10:48:50 +0000 (12:48 +0200)] 
gh-106320: Remove private _PyErr C API functions (#106356)

Remove private _PyErr C API functions: move them to the internal
C API (pycore_pyerrors.h).

2 years agogh-104050: Annotate Argument Clinic DSLParser attributes (#106357)
Erlend E. Aasland [Mon, 3 Jul 2023 10:06:54 +0000 (12:06 +0200)] 
gh-104050: Annotate Argument Clinic DSLParser attributes (#106357)

2 years agogh-106320: Create pycore_modsupport.h header file (#106355)
Victor Stinner [Mon, 3 Jul 2023 09:39:11 +0000 (11:39 +0200)] 
gh-106320: Create pycore_modsupport.h header file (#106355)

Remove the following functions from the C API, move them to the internal C
API: add a new pycore_modsupport.h internal header file:

* PyModule_CreateInitialized()
* _PyArg_NoKwnames()
* _Py_VaBuildStack()

No longer export these functions.

2 years agogh-106320: Move _PyUnicodeWriter to the internal C API (#106342)
Victor Stinner [Mon, 3 Jul 2023 08:23:43 +0000 (10:23 +0200)] 
gh-106320: Move _PyUnicodeWriter to the internal C API (#106342)

Move also _PyUnicode_FormatAdvancedWriter().

CJK codecs and multibytecodec.c now define the Py_BUILD_CORE_MODULE
macro.

2 years agogh-61215: New mock to wait for multi-threaded events to happen (#16094)
Mario Corchero [Mon, 3 Jul 2023 06:56:54 +0000 (07:56 +0100)] 
gh-61215: New mock to wait for multi-threaded events to happen (#16094)

mock: Add `ThreadingMock` class

Add a new class that allows to wait for a call to happen by using
`Event` objects. This mock class can be used to test and validate
expectations of multithreading code.

It uses two attributes for events to distinguish calls with any argument
and calls with specific arguments.

The calls with specific arguments need a lock to prevent two calls in
parallel from creating the same event twice.

The timeout is configured at class and constructor level to allow users
to set a timeout, we considered passing it as an argument to the
function but it could collide with a function parameter. Alternatively
we also considered passing it as positional only but from an API
caller perspective it was unclear what the first number meant on the
function call, think `mock.wait_until_called(1, "arg1", "arg2")`, where
1 is the timeout.

Lastly we also considered adding the new attributes to magic mock
directly rather than having a custom mock class for multi threading
scenarios, but we preferred to have specialised class that can be
composed if necessary. Additionally, having added it to `MagicMock`
directly would have resulted in `AsyncMock` having this logic, which
would not work as expected, since when if user "waits" on a
coroutine does not have the same meaning as waiting on a standard
call.

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
2 years agoDocument PYTHONSAFEPATH along side -P (#106122)
Jeremy Paige [Mon, 3 Jul 2023 05:44:37 +0000 (22:44 -0700)] 
Document PYTHONSAFEPATH along side -P (#106122)

2 years agoReplace the esoteric term 'datum' when describing dict comprehensions (#106119)
Ned Batchelder [Mon, 3 Jul 2023 03:22:40 +0000 (20:22 -0700)] 
Replace the esoteric term 'datum' when describing dict comprehensions (#106119)

2 years agogh-104050: Add more type hints to Argument Clinic DSLParser() (#106343)
Erlend E. Aasland [Sun, 2 Jul 2023 23:42:38 +0000 (01:42 +0200)] 
gh-104050: Add more type hints to Argument Clinic DSLParser() (#106343)

Annotate the following method signatures:

- state_dsl_start()
- state_parameter_docstring_start()
- state_parameters_start()

Inverting ignore_line() logic, add type hints (including type guard) to
it, and rename to valid_line().

2 years agogh-106320: _testcapi avoids private _PyUnicode_EqualToASCIIString() (#106341)
Victor Stinner [Sun, 2 Jul 2023 21:56:58 +0000 (23:56 +0200)] 
gh-106320: _testcapi avoids private _PyUnicode_EqualToASCIIString() (#106341)

Replace private _PyUnicode_EqualToASCIIString() with public
PyUnicode_CompareWithASCIIString().

2 years agogh-106320: Add pycore_complexobject.h header file (#106339)
Victor Stinner [Sun, 2 Jul 2023 21:19:59 +0000 (23:19 +0200)] 
gh-106320: Add pycore_complexobject.h header file (#106339)

Add internal pycore_complexobject.h header file.

Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter()
function to this new header file.

2 years agogh-106078: Move DecimalException to _decimal state (#106301)
Charlie Zhao [Sun, 2 Jul 2023 16:50:40 +0000 (00:50 +0800)] 
gh-106078: Move DecimalException to _decimal state (#106301)

2 years agogh-106320: Use _PyInterpreterState_GET() (#106336)
Victor Stinner [Sun, 2 Jul 2023 16:37:37 +0000 (18:37 +0200)] 
gh-106320: Use _PyInterpreterState_GET() (#106336)

Replace PyInterpreterState_Get() with inlined
_PyInterpreterState_GET().

2 years agogh-106320: Remove private _PyInterpreterState functions (#106335)
Victor Stinner [Sun, 2 Jul 2023 16:11:45 +0000 (18:11 +0200)] 
gh-106320: Remove private _PyInterpreterState functions (#106335)

Remove private _PyThreadState and _PyInterpreterState C API
functions: move them to the internal C API (pycore_pystate.h and
pycore_interp.h). Don't export most of these functions anymore, but
still export functions used by tests.

Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C
API, but keep it in the stable API.

2 years agogh-104922: Doc: add note about PY_SSIZE_T_CLEAN (#106314)
Inada Naoki [Sun, 2 Jul 2023 15:54:35 +0000 (00:54 +0900)] 
gh-104922: Doc: add note about PY_SSIZE_T_CLEAN (#106314)

Add note about PY_SSIZE_T_CLEAN in extending and embedding document.

2 years agogh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (#106329)
Nikita Sobolev [Sun, 2 Jul 2023 14:15:28 +0000 (17:15 +0300)] 
gh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (#106329)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-104922: remove PY_SSIZE_T_CLEAN (#106315)
Inada Naoki [Sun, 2 Jul 2023 06:07:46 +0000 (15:07 +0900)] 
gh-104922: remove PY_SSIZE_T_CLEAN (#106315)

2 years agogh-106320: Remove private _PyInterpreterState functions (#106325)
Victor Stinner [Sun, 2 Jul 2023 01:39:38 +0000 (03:39 +0200)] 
gh-106320: Remove private _PyInterpreterState functions (#106325)

Remove private _PyThreadState and _PyInterpreterState C API
functions: move them to the internal C API (pycore_pystate.h and
pycore_interp.h). Don't export most of these functions anymore, but
still export functions used by tests.

Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C
API, but keep it in the stable API.

2 years agogh-106320: Remove private _PyTraceMalloc C API functions (#106324)
Victor Stinner [Sun, 2 Jul 2023 00:49:18 +0000 (02:49 +0200)] 
gh-106320: Remove private _PyTraceMalloc C API functions (#106324)

* Remove private _PyTraceMalloc C API functions: move them to the
  internal C API.
* Don't export most of these functions anymore, but still export
  _PyTraceMalloc_GetTraceback() used by tests.
* Rename Include/tracemalloc.h to Include/cpython/tracemalloc.h

2 years agogh-106320: Remove _PyInterpreterState_Get() alias (#106321)
Victor Stinner [Sat, 1 Jul 2023 23:44:07 +0000 (01:44 +0200)] 
gh-106320: Remove _PyInterpreterState_Get() alias (#106321)

Replace calls to the (removed) slow _PyInterpreterState_Get() with
fast inlined _PyInterpreterState_GET() function.

2 years agogh-102541: Fix Helper.help("mod") for non-existent mod (#105934)
Kirill Podoprigora [Sat, 1 Jul 2023 22:46:06 +0000 (01:46 +0300)] 
gh-102541: Fix Helper.help("mod") for non-existent mod (#105934)

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2 years agogh-106316: Remove pytime.h header file (#106317)
Victor Stinner [Sat, 1 Jul 2023 22:27:18 +0000 (00:27 +0200)] 
gh-106316: Remove pytime.h header file (#106317)

Remove the "cpython/pytime.h" header file: it only contained private
functions. Move functions to the internal pycore_time.h header file.

Move tests from _testcapi to _testinternalcapi. Rename also test
methods to have the same name than tested C functions.

No longer export these functions:

* _PyTime_Add()
* _PyTime_As100Nanoseconds()
* _PyTime_FromMicrosecondsClamp()
* _PyTime_FromTimespec()
* _PyTime_FromTimeval()
* _PyTime_GetPerfCounterWithInfo()
* _PyTime_MulDiv()

2 years agoFix duplicate word typos in comments (#106225)
Md Sadman Chowdhury [Sat, 1 Jul 2023 19:47:14 +0000 (01:47 +0600)] 
Fix duplicate word typos in comments (#106225)

2 years agoGH-89812: Improve test for `pathlib.Path.stat()` (GH-106064)
Barney Gale [Sat, 1 Jul 2023 12:33:29 +0000 (13:33 +0100)] 
GH-89812: Improve test for `pathlib.Path.stat()` (GH-106064)

Make assertions about the `st_mode`, `st_ino` and `st_dev` attributes of
the stat results from two files and a directory, rather than checking if
`chmod()` affects `st_mode` (which is already tested elsewhere).

2 years agoGH-89812: Miscellaneous pathlib test improvements (GH-106063)
Barney Gale [Sat, 1 Jul 2023 12:29:02 +0000 (13:29 +0100)] 
GH-89812: Miscellaneous pathlib test improvements (GH-106063)

- Split out dedicated test for unbuffered `open()`
- Split out dedicated test for `is_mount()` at the filesystem root
- Avoid `os.stat()` when checking that empty paths point to '.'
- Remove unnecessary `rmtree()` call
- Remove unused `assertSame()` method

2 years agoGH-89812: Test that `pathlib.Path.is_junction()` returns false (GH-106062)
Barney Gale [Sat, 1 Jul 2023 11:58:30 +0000 (12:58 +0100)] 
GH-89812: Test that `pathlib.Path.is_junction()` returns false (GH-106062)

Slightly expand the test coverage of `is_junction()`. The existing test
only checks that `os.path.isjunction()` is called under-the-hood.

2 years agoGH-89812: Make symlink support configurable in pathlib tests. (GH-106060)
Barney Gale [Sat, 1 Jul 2023 11:24:34 +0000 (12:24 +0100)] 
GH-89812: Make symlink support configurable in pathlib tests. (GH-106060)

Adjust the pathlib tests to add a new `PathTest.can_symlink` class
attribute, which allows us to enable or disable symlink support in tests.
A (near-)future commit will add an `AbstractPath` class; its tests will
hard-code the value to `True` or `False` depending on a stub subclass's
capabilities.

2 years agogh-106149: move unconditional jump direction resolution from optimizer to assembler...
Irit Katriel [Sat, 1 Jul 2023 10:28:07 +0000 (11:28 +0100)] 
gh-106149: move unconditional jump direction resolution from optimizer to assembler (#106291)

2 years agobuild(deps): bump mheap/github-action-required-labels from 4 to 5 (#106306)
dependabot[bot] [Sat, 1 Jul 2023 10:23:57 +0000 (13:23 +0300)] 
build(deps): bump mheap/github-action-required-labels from 4 to 5 (#106306)

Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 4 to 5.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](https://github.com/mheap/github-action-required-labels/compare/v4...v5)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agobuild(deps-dev): bump mypy from 1.3.0 to 1.4.1 in /Tools/clinic (#106305)
dependabot[bot] [Sat, 1 Jul 2023 09:54:32 +0000 (09:54 +0000)] 
build(deps-dev): bump mypy from 1.3.0 to 1.4.1 in /Tools/clinic (#106305)

Bumps [mypy](https://github.com/python/mypy) from 1.3.0 to 1.4.1.
- [Commits](https://github.com/python/mypy/compare/v1.3.0...v1.4.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agogh-106232: Make timeit doc command lines compatible with Windows. (#106296)
Terry Jan Reedy [Sat, 1 Jul 2023 02:34:31 +0000 (22:34 -0400)] 
gh-106232: Make timeit doc command lines compatible with Windows. (#106296)

Command Prompt (CMD Shell) and older versions of PowerShell
require double quotes and single quotes inside the string.
This form also works on linux and macOS.

2 years agogh-105486: Change the `repr` of `ParamSpec` list of args in `GenericAlias` (#105488)
Nikita Sobolev [Sat, 1 Jul 2023 00:04:50 +0000 (03:04 +0300)] 
gh-105486: Change the `repr` of `ParamSpec` list of args in `GenericAlias` (#105488)

2 years agoGH-89812: Simplify creation of symlinks in pathlib tests. (GH-106061)
Barney Gale [Fri, 30 Jun 2023 23:46:44 +0000 (00:46 +0100)] 
GH-89812: Simplify creation of symlinks in pathlib tests. (GH-106061)

Remove `PathTest.dirlink()` function. Symlinks in `PathTest.setUp()` are
created using `os.symlink()` directly; symlinks in test functions use
`Path.symlink_to()` in order to make the tests applicable to a
(near-)future `AbstractPath` class.

2 years agogh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (#106224)
Nikita Sobolev [Fri, 30 Jun 2023 23:45:08 +0000 (02:45 +0300)] 
gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (#106224)