Commit Graph

51651 Commits

Author SHA1 Message Date
Eric Snow 8a4c1f3ff1
gh-76785: Show the Traceback for Uncaught Subinterpreter Exceptions (gh-113034)
When an exception is uncaught in Interpreter.exec_sync(), it helps to show that exception's error display if uncaught in the calling interpreter.  We do so here by generating a TracebackException in the subinterpreter and passing it between interpreters using pickle.
2023-12-13 00:00:54 +00:00
Guido van Rossum 7316dfb0eb
gh-112320: Implement on-trace confidence tracking for branches (#112321)
We track the confidence as a scaled int.
2023-12-12 21:43:08 +00:00
Eric Snow 9898e61041
gh-76785: Add Interpreter.prepare_main() (gh-113021)
This is one of the last pieces to get test.support.interpreters in sync with PEP 734.
2023-12-12 18:06:06 +00:00
Eric Snow a49b427b02
gh-76785: More Fixes for test.support.interpreters (gh-113012)
This brings the module (along with the associated extension modules) mostly in sync with PEP 734.  There are only a few small things to wrap up.
2023-12-12 17:43:30 +00:00
Eric Snow cde1417175
gh-76785: Fix test_threading on Non-Subinterpreter Builds (gh-113014)
gh-112982 broke test_threading on one of the s390 buildbots (Fedora Clang Installed).  Apparently ImportError is raised (rather than ModuleNotFoundError) for the name part of "from" imports.  This fixes that by catching ImportError in test_threading.py.
2023-12-12 16:54:39 +00:00
Serhiy Storchaka fe9991bb67
gh-112999: Replace the outdated "deprecated" directives with "versionchanged" (GH-113000) 2023-12-12 18:31:04 +02:00
Eric Snow 86a77f4e1a
gh-76785: Fixes for test.support.interpreters (gh-112982)
This involves a number of changes for PEP 734.
2023-12-12 08:24:31 -07:00
Terry Jan Reedy e0fb7004ed
gh-112953: Rename idlelib/NEWS.txt to News3.txt and update (#112988) 2023-12-12 01:00:51 -05:00
wim glenn 616622cab7
gh-112983: Add the known magic value of 3495 for Python 3.11 bytecode (#112985)
Add the known magic value of 3495 for Python 3.11 bytecode
2023-12-11 18:47:12 -07:00
Sam Gross fdee7b7b3e
gh-112532: Require mimalloc in `--disable-gil` builds (gh-112883) 2023-12-12 09:04:48 +09:00
achhina a01022af23
GH-83162: Rename re.error for better clarity. (#101677)
Renamed re.error for clarity, and kept re.error for backward compatibility.
Updated idlelib files at TJR's request.
---------

Co-authored-by: Matthias Bussonnier <mbussonnier@ucmerced.edu>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-12-11 15:45:08 -05:00
Nikita Sobolev 0738b9a338
gh-108303: Move `double_const` to `test_import` where it belongs (#112108) 2023-12-11 19:29:43 +01:00
James Morris d7b5f10231
gh-112507: Detect Cygwin and MSYS with `uname` instead of `$OSTYPE` (GH-112508)
Detect Cygwin and MSYS with `uname` instead of `$OSTYPE`

`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
2023-12-11 17:27:15 +00:00
Sidney Markowitz 27a5fd8cb8
gh-94606: Fix error when message with Unicode surrogate not surrogateescaped string (GH-94641)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-11 18:21:18 +02:00
Ronald Oussoren 3251ba8f1a
gh-112898: warn about unsaved files when quitting IDLE on macOS (#112939)
* gh-112898: warn about unsaved files when quitting IDLE on macOS

Implement the TK function ``::tk::mac::Quit`` on macOS to
ensure that IDLE asks about saving unsaved files when
quitting IDLE. 

Co-authored-by: Christopher Chavez chrischavez@gmx.us
2023-12-11 15:22:36 +01:00
Anthony Sottile 97cd45bfdb
Fix SyntaxWarning in test_syntax.py (GH-112944) 2023-12-11 11:48:52 +00:00
Pablo Galindo Salgado a135a6d2c6
gh-112943: Correctly compute end offsets for multiline tokens in the tokenize module (#112949) 2023-12-11 11:44:22 +00:00
Nikita Sobolev 9d02d3451a
gh-110686: Test pattern matching with `runtime_checkable` protocols (#110687) 2023-12-10 07:21:20 -08:00
Ronald Oussoren dd2ebdf89f
gh-109980: Fix test_tarfile_vs_tar on macOS (#112905)
On recentish macOS versions the system tar
command includes system metadata (ACLs, extended attributes
and resource forks) in the tar archive, which
shutil.make_archive will not do. This can cause
spurious test failures.
2023-12-10 12:38:49 +01:00
Terry Jan Reedy ca1bde8943
IDLE: Tweak iomenu.IOBinding.maybesave (#112914)
Add docstring, use f-string, simplify code.
2023-12-09 21:29:40 -05:00
Barney Gale 23df46a1dd
GH-112906: Fix performance regression in pathlib path initialisation (#112907)
This was caused by 76929fdeeb, specifically its use of `super()` and its
packing/unpacking `*args`.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-10 00:06:27 +00:00
Barney Gale a98e7a8112
GH-110109: Move pathlib ABCs to new `pathlib._abc` module. (#112881)
Move `_PurePathBase` and `_PathBase` to a new `pathlib._abc` module, and
drop the underscores from the class names.

Tests are mostly left alone in this commit, but they'll be similarly split
in a subsequent commit.

The `pathlib._abc` module will be published as an independent PyPI package
(similar to how `zipfile._path` is published as `zipp`), to be refined
and stabilised prior to its possible addition to the standard library.
2023-12-09 16:07:40 +01:00
Irit Katriel c98c40227e
gh-112720: Move instruction formatting from the dis.Instruction class to a new class dis.InstructionFormatter. Add the ArgResolver class. (#112722) 2023-12-09 10:03:02 +00:00
Gregory P. Smith 10e9bb13b8
gh-112334: Regression test that vfork is used when expected. (#112734)
Regression test that vfork is used when expected by subprocess.

This is written integration test style, it uses strace if it is present and appears to work to find out what system call actually gets used in different scenarios.

Test coverage is added for the default behavior and that of each of the specific arguments that must disable the use of vfork.  obviously not an entire test matrix, but it covers the most important aspects.

If there are ever issues with this test being flaky or failing on new platforms, rather than try and adapt it for all possible platforms, feel free to narrow the range it gets tested on when appropriate. That is not likely to reduce coverage.
2023-12-09 00:18:35 +00:00
Raymond Hettinger f3bff4ee9d
gh-112540: Support zero inputs in geometric_mean() (gh-112880) 2023-12-08 12:05:56 -06:00
Barney Gale 76929fdeeb
GH-110109: Add `pathlib._PurePathBase` (#110670)
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly.

This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.
2023-12-08 17:39:04 +00:00
Barney Gale 28b2b7407c
GH-112675: Move path joining tests into `test_posixpath` and `test_ntpath` (#112676)
In `test_pathlib`, the `check_drive_root_parts` test methods evaluated
both joining and parsing/normalisation of paths. This dates from a time
when pathlib implemented both functions itself, but nowadays path joining
is done with `posixpath.join()` and `ntpath.join()`.

This commit moves the joining-related test cases into `test_posixpath` and
`test_ntpath`.
2023-12-07 21:45:40 +00:00
Ronald Oussoren bf0beae6a0
gh-110017: Disable test_signal.test_stress_modifying_handlers on macOS (#112834)
Test test_stress_modifying_handlers in test_signal can crash
the interpreter due to a bug in macOS. Filed as FB13453490
with Apple.
2023-12-07 19:41:27 +01:00
AN Long a955fd68d6
gh-112278: Disable WMI queries on Windows after they time out (GH-112658) 2023-12-07 17:26:29 +00:00
Serhiy Storchaka b2923a61a1
gh-79325: Fix recursion error in TemporaryDirectory cleanup on Windows (GH-112762) 2023-12-07 17:21:36 +00:00
Serhiy Storchaka ba18893555
gh-87319: Simplify TemporaryDirectory cleanup using os.path.isjunction() (GH-112791) 2023-12-07 18:32:10 +02:00
Søren Løvborg 81c16cd94e
gh-91133: tempfile.TemporaryDirectory: fix symlink bug in cleanup (GH-99930)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-07 18:04:06 +02:00
Łukasz Langa 9f67042f28
gh-110190: Temporarily skip new test introduced in gh-112604 on PPC64LE (#112818) 2023-12-07 14:29:15 +01:00
andrewluotechnologies 9c3458e058
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504) 2023-12-07 13:56:01 +01:00
Tian Gao 3d712a9f4c
gh-102980: Redirect output of pdb's `interact` command, add tests and improve docs (#111194) 2023-12-07 11:19:33 +00:00
Kushal Das 4ba15de191
gh-74616: Raise ValueError in case of null character in input prompt (GH-1738)
If the input prompt to the builtin input function on terminal has any null
character, then raise ValueError instead of silently truncating it.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-07 10:22:52 +00:00
Ronald Oussoren 953ee622b3
gh-109981: Fix support.fd_count() on macOS 14 (#112797)
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors.

"Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-12-07 10:30:15 +01:00
Pablo Galindo Salgado 16448cab44
gh-112730: Use color to highlight error locations (gh-112732)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-12-06 23:29:54 +01:00
Serhiy Storchaka cc7e45cc57
gh-75666: Tkinter: "unbind(sequence, funcid)" now only unbinds "funcid" (GH-111322)
Previously, "widget.unbind(sequence, funcid)" destroyed the current binding
for "sequence", leaving "sequence" unbound, and deleted the "funcid"
command.

Now it removes only "funcid" from the binding for "sequence", keeping
other commands, and deletes the "funcid" command.
It leaves "sequence" unbound only if "funcid" was the last bound command.

Co-authored-by: GiovanniL <13402461+GiovaLomba@users.noreply.github.com>
2023-12-06 16:42:15 +02:00
Victor Stinner 828451dfde
gh-111545: Add Py_HashPointer() function (#112096)
* Implement _Py_HashPointerRaw() as a static inline function.
* Add Py_HashPointer() tests to test_capi.test_hash.
* Keep _Py_HashPointer() function as an alias to Py_HashPointer().
2023-12-06 15:09:22 +01:00
Victor Stinner f8852634ed
gh-108223: Refer to PEP 703 as Free Threading (#112780) 2023-12-06 12:55:58 +01:00
Miro Hrončok d384813ff1
gh-112769: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (GH-112771)
zlib-ng defines the version as "1.3.0.zlib-ng".
2023-12-05 21:39:28 +02:00
Zackery Spytz 11d88a178b
bpo-35332: Handle os.close() errors in shutil.rmtree() (GH-23766)
* Ignore os.close() errors when ignore_errors is True.
* Pass os.close() errors to the error handler if specified.
* os.close no longer retried after error.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 19:09:39 +02:00
Ethan Furman de6bca9564
gh-112328: [Enum] Make some private attributes public. (GH-112514)
* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-12-05 08:27:36 -08:00
Serhiy Storchaka 563ccded6e
gh-94692: Only catch OSError in shutil.rmtree() (#112756)
Previously a symlink attack resistant version of shutil.rmtree() could ignore
or pass to the error handler arbitrary exception when invalid arguments
were provided.
2023-12-05 16:40:49 +01:00
Diego Russo bc68f4a4ab
gh-110190: Fix ctypes structs with array on Arm (#112604)
Set MAX_STRUCT_SIZE to 32 in stgdict.c when on Arm platforms.
This because on Arm platforms structs with at most 4 elements of any
floating point type values can be passed through registers. If the type
is double the maximum size of the struct is 32 bytes.
On x86-64 Linux, it's maximum 16 bytes hence we need to differentiate.
2023-12-05 16:07:50 +01:00
Ken Jin 8cdfee1bb9
bpo-43153: Don't mask `PermissionError` with `NotADirectoryError` during tempdirectory cleanup (GH-29940)
Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 15:30:59 +02:00
Jeffrey Kintscher 268415bbb3
gh-81441: shutil.rmtree() FileNotFoundError race condition (GH-14064)
Ignore missing files and directories while enumerating
directory entries in shutil.rmtree().

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 09:33:51 +00:00
pan324 81ee026091
gh-82300: Add track parameter to multiprocessing.shared_memory (#110778)
Add a track parameter to shared memory to allow resource tracking via the side-launched resource tracker process to be disabled on platforms that use it (POSIX).

This allows people who do not want automated cleanup at process exit because they are using the shared memory with processes not participating in Python's resource tracking to use the shared_memory API.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-12-05 00:11:44 -08:00
Constantin Hong aa5bee30ab
gh-102130: Support tab completion in cmd for Libedit. (GH-107748)
---

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-12-05 08:24:56 +01:00
Russell Keith-Magee dc824c5dc1
gh-112736: Refactor del-safe symbol handling in subprocess (#112738)
Refactor delete-safe symbol handling in subprocess.

Only module globals are force-cleared during interpreter finalization, using a class reference instead of individually listing the constants everywhere is simpler.
2023-12-04 20:23:17 -08:00
Barney Gale 304a1b3f3a
GH-112727: Speed up `pathlib.Path.absolute()` (#112728)
Use `_from_parsed_parts()` to create a pre-joined/pre-parsed path, rather
than passing multiple arguments to `with_segments()`

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-04 23:21:39 +00:00
Gregory P. Smith 9fe7655c6c
gh-112334: Restore subprocess's use of `vfork()` & fix `extra_groups=[]` behavior (#112617)
Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;
also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:

Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where it
would no longer use the fast-path ``vfork()`` system call when it could have
due to a logic bug, instead falling back to the safe but slower ``fork()``.

Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``
was passed to :mod:`subprocess.Popen` or related APIs, the underlying
``setgroups(0, NULL)`` system call to clear the groups list would not be made
in the child process prior to ``exec()``.

The security issue was identified via code inspection in the process of
fixing the first bug.  Thanks to @vain for the detailed report and
analysis in the initial bug on Github.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-04 15:08:19 -08:00
Victor Stinner c5fa8a54db
gh-112535: Add test on _Py_ThreadId() (#112709)
Add also test.support.Py_GIL_DISABLED constant.
2023-12-04 22:40:06 +00:00
Kamil Turek a1551b48ee
gh-103363: Add follow_symlinks argument to `pathlib.Path.owner()` and `group()` (#107962) 2023-12-04 19:42:01 +00:00
Alex Waygood 2ed20d3bd8
gh-74690: Avoid a costly type check where possible in `_ProtocolMeta.__subclasscheck__` (#112717) 2023-12-04 19:35:46 +00:00
Thomas Bininda 1e4680ce52
gh-112516: Update bundled pip version to 23.3.1 (gh-112517) 2023-12-04 18:27:57 +01:00
Serhiy Storchaka e08b70fab1
gh-108927: Fix removing testing modules from sys.modules (GH-108952)
It breaks import machinery if the test module has submodules used in
other tests.
2023-12-04 15:43:27 +00:00
Alex Waygood c718ab92a5
gh-74690: Optimise `isinstance()` and `issubclass()` calls against runtime-checkable protocols by avoiding costly `super()` calls (#112708) 2023-12-04 15:41:41 +00:00
Serhiy Storchaka 6ca9d3e017
gh-109786: Fix leaks and crash when re-enter itertools.pairwise.__next__() (GH-109788) 2023-12-04 11:47:55 +00:00
Serhiy Storchaka c74e9fb189
gh-110275: Named tuple's __replace__() now raises TypeError for invalid arguments (GH-110299) 2023-12-04 13:30:32 +02:00
Serhiy Storchaka dee7beeb4f
bpo-34392: Add sys. _is_interned() (GH-8755) 2023-12-04 11:09:06 +02:00
chilaxan 0e732d0997
gh-112625: Protect bytearray from being freed by misbehaving iterator inside bytearray.join (GH-112626) 2023-12-04 08:15:43 +00:00
Terry Jan Reedy e5b0db0315
gh-66819: More IDLE htest updates(4) (#112686)
Mostly double spacing before 'if __name__...'.
2023-12-04 06:36:40 +00:00
Terry Jan Reedy 5a1b5316af
gh-66819: More IDLE htest updates(3) (#112683)
Revise spec-callable pairs from percolator to end.
2023-12-03 23:45:56 -05:00
Barney Gale 09505c5c26
GH-106747: Improve `Path.glob()` expectations in pathlib tests (#112365)
Add trailing slashes to expected `Path.glob()` results wherever a pattern
has a trailing slash. This matches what `glob.glob()` produces.

Due to another bug (GH-65238) pathlib strips all trailing slashes, so this
change is academic for now.
2023-12-03 20:35:10 +00:00
Irit Katriel 97857ac058
gh-112645: remove deprecation warning for use of onerror in shutil.rmtree (#112659) 2023-12-03 14:02:37 +00:00
Irit Katriel 162d3d428a
gh-112620: Fix dis error on show_cache with labels (#112621) 2023-12-03 12:12:49 +00:00
Shantanu 29e6c7b68a
gh-112578: Fix RuntimeWarning when running zipfile (GH-112579) 2023-12-03 13:09:29 +02:00
Alex Waygood fc9e24b01f
gh-112316: improve docs for `inspect.signature` and `inspect.Signature` (#112631) 2023-12-03 01:37:34 -08:00
Terry Jan Reedy 3855b45874
gh-66819: More IDLE htest updates(2) (#112642)
Examine and update spec -- callable pairs.
Revise run method.
2023-12-03 09:28:37 +00:00
Nikita Sobolev a9574c68f0
gh-112139: Add `inspect.Signature.format` and use it in `pydoc` (#112143)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-12-02 15:39:43 -08:00
Nikita Sobolev a35a305098
gh-112618: Make `Annotated` cache typed (#112619)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-02 16:10:19 +00:00
William Wen 939fc6d6ea
gh-106922: Support multi-line error locations in traceback (attempt 2) (#112097) 2023-12-01 22:18:16 +00:00
Zackery Spytz 0daf555c6f
bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503)
* Fix a crash when pass UINT_MAX.
* Fix an integer overflow on 64-bit non-Windows platforms.
2023-12-01 15:16:49 +00:00
Alex Waygood 70a38ffb3d
gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (#112586)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-12-01 14:54:33 +00:00
Tian Gao c2982380f8
gh-112510: Add `readline.backend` for the backend readline uses (GH-112511)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
2023-12-01 14:05:55 +00:00
Victor Stinner f8ff80f635
gh-109413: regrtest: add WorkerRunTests class (#112588) 2023-12-01 13:46:50 +00:00
Zackery Spytz 058444308a
gh-82565: Add tests for pickle and unpickle with bad files (GH-16606) 2023-12-01 13:36:37 +00:00
Irit Katriel bfb576ee23
gh-111058: Change coro.cr_frame/gen.gi_frame to be None for a closed coroutine/generator. (#112428) 2023-12-01 12:57:31 +00:00
Rémi Lapeyre a65a3d4806
bpo-39912: Raise appropriate exceptions in filterwarnings() and simplefilter() (GH-18878) 2023-12-01 11:17:47 +00:00
Yang Hau 707c37e373
Fix typos in variable names, function names, and comments (GH-101868) 2023-12-01 09:37:40 +00:00
Terry Jan Reedy e44f1940bd
gh-66819: More IDLE htest updates (#112574)
Revise htest.py docstring and move 2 specs to alphabetical position.
2023-12-01 07:02:31 +00:00
Alex Waygood 674c288b1c
gh-109413: Run mypy on `libregrtest` in CI (#112558)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-11-30 23:00:14 +00:00
Brett Cannon 6d5e0dc0e3
Clarify a comment for `test.support.Py_C_RECURSION_LIMIT` to point out where a value came from but that it doesn't need to stay in sync (#112224) 2023-11-30 13:38:10 -08:00
Serhiy Storchaka 2223899adc
gh-104231: Add more tests for str(), repr(), ascii(), and bytes() (GH-112551) 2023-11-30 17:22:04 +02:00
Irit Katriel 07ebd46f9e
gh-112519: Make it possible to specify instruction flags for pseudo instructions in bytecodes.c (#112520) 2023-11-30 11:03:30 +00:00
Donghee Na 7eeea13403
gh-112205: Support @getter annotation from AC (gh-112396) 2023-11-30 19:40:53 +09:00
Terry Jan Reedy 81261fa67f
IDLE: fix config_key htest (#112545)
Change 'Dialog' to 'Window' in two places to match the name of the config_key class being tested.
2023-11-30 07:08:44 +00:00
Jelle Zijlstra d4a6229afe
gh-104003: Implement PEP 702 (#104004)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-29 09:38:29 -08:00
Jelle Zijlstra 4038869423
gh-112509: Fix keys being present in both required_keys and optional_keys in TypedDict (#112512)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-29 09:36:48 -08:00
Serhiy Storchaka e0449b9a7f
Add more C API tests (GH-112522)
Add tests for PyObject_Str(), PyObject_Repr(), PyObject_ASCII() and
PyObject_Bytes().
2023-11-29 17:37:05 +02:00
Ethan Furman f9e6ce0395
[Enum] update class creation for RuntimeError changes (GH-111815) 2023-11-28 20:40:12 -08:00
Grant Ramsay e413daf5f6
gh-112454: Disable TLS-PSK if OpenSSL was built without PSK support (#112491)
If OpenSSL was built without PSK support, the python TLS-PSK
methods will raise "NotImplementedError" if called.

Add a constant "ssl.HAS_PSK" to check if TLS-PSK is supported
2023-11-28 16:15:39 -08:00
James Morris a194938f33
gh-112431: Unconditionally call `hash -r` (GH-112432)
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`#!/bin/sh`-compatible shells like dash.
2023-11-28 14:54:59 +05:30
Sergey B Kirpichev f14d741daa
gh-109802: Increase test coverage for complexobject.c (GH-112452) 2023-11-28 10:18:33 +02:00
Irit Katriel 2c68011780
gh-112332: Deprecate TracebackException.exc_type, add exc_type_str. (#112333) 2023-11-28 08:03:25 +00:00
Tian Gao 2df26d8348
gh-112105: Make completer delims work on libedit (gh-112106) 2023-11-28 06:23:23 +00:00
Alex Waygood cf2054059c
gh-112414: Add additional unit tests for calling `repr()` on a namespace package (#112475)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-11-28 00:09:59 +00:00
Tian Gao b90a5cf11c
gh-99367: Do not mangle sys.path[0] in pdb if safe_path is set (#111762)
Co-authored-by: Christian Walther <cwalther@users.noreply.github.com>
2023-11-27 23:11:40 +00:00
apaz 8f71b349de
gh-112217: Add check to call result for `do_raise()` where cause is a type. (#112216) 2023-11-27 21:13:27 +00:00
Serhiy Storchaka 4dcfd02bed
gh-68166: Add support of "vsapi" in ttk.Style.element_create() (GH-111393) 2023-11-27 20:57:33 +02:00
Pablo Galindo Salgado 45d648597b
gh-112387: Fix error positions for decoded strings with backwards tokenize errors (#112409)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2023-11-27 18:37:48 +00:00
Pablo Galindo Salgado 2c8b191742
gh-112388: Fix an error that was causing the parser to try to overwrite tokenizer errors (#112410)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2023-11-27 18:36:11 +00:00
Jacob Walls 99a73c3465
gh-76912: Raise OSError from any failure in getpass.getuser() (#29739)
* bpo-32731: Raise OSError from any failure in getpass.getuser()
Previously, if the username was not set in certain environment variables, ImportError escaped on Windows systems, and it was possible for KeyError to escape on other systems if getpwuid() failed.
2023-11-27 10:05:55 -08:00
Serhiy Storchaka 4eea1e8236
gh-112438: Fix support of format units with the "e" prefix in nested tuples in PyArg_Parse (gh-112439) 2023-11-27 18:32:55 +01:00
Zackery Spytz 812360fddd
gh-84443: SSLSocket.recv_into() now support buffer protocol with itemsize != 1 (GH-20310)
It is also no longer use __len__().

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-27 19:15:39 +02:00
Alex Waygood 22e411e1d1
gh-111874: Call `__set_name__` on objects that define the method inside a `typing.NamedTuple` class dictionary as part of the creation of that class (#111876)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-27 16:34:44 +00:00
Nikita Sobolev 7ac49e74c3
gh-111147: Fix `test_set_of_sets_reprs` in `test_pprint` (GH-111148)
Make it stable and not depending on implementation details.
2023-11-27 12:01:26 +02:00
Alex Waygood 0622839cfe
gh-112414: Fix `AttributeError` when calling `repr()` on a namespace package imported with a custom loader (#112425) 2023-11-27 08:19:29 +00:00
Grant Ramsay e954ac7205
gh-63284: Add support for TLS-PSK (pre-shared key) to the ssl module (#103181)
Add support for TLS-PSK (pre-shared key) to the ssl module.

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-11-27 04:01:44 +00:00
Irit Katriel fb202af447
gh-99606: Make code generated for an empty f-string identical to that of a normal empty string (#112407) 2023-11-26 17:13:57 +00:00
Alex Waygood 418d585feb
gh-112405: Optimise `pathlib.Path.relative_to` (#112406) 2023-11-26 15:56:03 +00:00
Mark Dickinson 9fe60340d7
gh-112358: Fix Python 3.12 regression with subclassing struct.Struct. (#112424)
Revert commit c8c0afc713 (PR #94532),
which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`.
This caused issues with code in the wild that subclasses `struct.Struct`.
2023-11-26 14:29:52 +00:00
Barney Gale bbb4367b55
GH-77621: Delay some imports from pathlib (#112244)
Import `contextlib`, `glob` and `re` only as required.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-25 17:41:05 +00:00
Irit Katriel fbb9027a03
gh-94722: fix DocTest.__eq__ for case of no line number on one side (#112385) 2023-11-25 17:23:43 +00:00
Barney Gale 19a1fc1b3d
GH-112361: Speed up pathlib by removing some temporary objects. (#112362)
Construct only one new list object (using `list.copy()`) when creating a
new path object with a modified tail. This slightly speeds up
`with_name()` and `with_suffix()`
2023-11-25 17:19:38 +00:00
Irit Katriel 9eb3b35dd7
gh-112355: fix calculation of jump target of ENTER_EXECUTOR in dis (#112377) 2023-11-24 18:13:25 +00:00
Randolf Scholz e9d1360c9a
gh-112345: `typing.Protocol`: Let failed subclasscheck show non-method members (#112344)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-24 09:46:08 +00:00
Tian Gao dc0adb44d8
Add extra tests for `random.binomialvariate` (gh-112325) 2023-11-23 12:31:03 -06:00
Irit Katriel 89ddea4886
gh-112137: change dis output to show no-lineno as -- instead of None (#112335) 2023-11-23 14:34:27 +00:00
Eric Snow 9e56eedd01
gh-76785: Return an "excinfo" Object From Interpreter.run() (gh-111573) 2023-11-23 00:55:00 +00:00
Nikita Sobolev 14e539f097
gh-111809: Fix `test_deep_repr` from `test_userdict` on WASI (GH-112229) 2023-11-22 14:55:25 -08:00
Irit Katriel 10e1a0c916
gh-112137: change dis output to display labels instead of offsets (#112138) 2023-11-22 22:36:55 +00:00
Eric Snow 790db85c77
gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)
The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
2023-11-22 15:03:33 -07:00
Eric Snow 5c3a129ecf
gh-76785: Clean up the Failure-Related _xxsubinterpreters Tests (gh-112322) 2023-11-22 14:48:45 -07:00
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