Commit Graph

51338 Commits

Author SHA1 Message Date
sc07kvm 677d4bc15e
Remove unnecessary while in SocketIO.readinto (GH-111057)
It is unnecessary after removing "continue" in 6e6c59b (bpo-42357).
2023-10-20 00:26:30 +03:00
Eric Snow d23a2f9887
gh-76785: Make interpreters.*Channel Objects Shareable (gh-110607)
This restores their shareability, which was disabled by gh-110318 due to ref leaks.
2023-10-19 08:52:02 -06:00
Eric Snow 6741d5af32
gh-76785: Add *Channel.is_closed (gh-110606) 2023-10-19 08:51:21 -06:00
Nikita Sobolev e9b5399bee
gh-111031: Check more files in `test_tokenize` (#111032) 2023-10-19 09:29:45 +01:00
Terry Jan Reedy 642eb8df95
gh-111050: IDLE - Simplify configdialog.HighPage.theme_elements (#111053)
Replace tuple value with internal name, removing numbers.
Remove sorting of already ordered dislay names.
Remove '[0]' indexing into now-gone tuple.
2023-10-19 00:03:24 -04:00
Nikita Sobolev 94495d0387
Fix a misspelling of Interpeter -> Interpreter (GH-111040) 2023-10-18 15:09:45 -07:00
Tian Gao e6eb8cafca
GH-102895 Add an option local_exit in code.interact to block exit() from terminating the whole process (GH-102896) 2023-10-18 11:36:43 -07:00
Shantanu 3156d193b8
gh-100445: Improve error message for unterminated strings with escapes (#100446) 2023-10-18 13:58:51 +01:00
Terry Jan Reedy baefbb21d9
gh-103737: IDLE - Remove unneeded .keys() for dict iteration (#110960)
Add comments where .keys() is needed.
Leave debugger usages along because situation is unclear as indicated in expanded comment.
Most testing is manual.
2023-10-18 04:14:52 -04:00
James 77dbd95609
gh-111019: Align expected and actual titles in test output (#111020)
Align expected and actual titles in output from
assert_has_calls/assert_called_with for greater readability
2023-10-18 08:36:16 +01:00
Charles Machalow 738574fb21
gh-108747: Add unit tests for site.{usercustomize,sitecustomize} hooks (#109470) 2023-10-17 22:05:41 -07:00
Nikita Sobolev 220bcc9e27
gh-110938: More syntax tests for PEP695 funcs and classes (#110986) 2023-10-17 22:00:04 -07:00
Bar Harel 7025844f4c
gh-110961: Fixed asyncio.wait docstring to remove deprecated coroutine reference (#111017)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-10-18 04:40:26 +00:00
Eric Snow c58c63fdf6
gh-84570: Add Timeouts to SendChannel.send() and RecvChannel.recv() (gh-110567) 2023-10-17 23:05:49 +00:00
Eric Snow a53d7cb672
gh-84570: Send-Wait Fixes for _xxinterpchannels (gh-111006)
There were a few things I did in gh-110565 that need to be fixed. I also forgot to add tests in that PR.

(Note that this PR exposes a refleak introduced by gh-110246. I'll take care of that separately.)
2023-10-17 16:32:00 -06:00
Victor Stinner 920b3dfaca
gh-110995: Fix test_gdb check_usable_gdb() (#110998)
Fix detection of gdb built without Python scripting support.

* check_usable_gdb() doesn't check gdb exit code when calling
  run_gdb().
* Use shutil.which() to get the path to the gdb program.
2023-10-17 20:19:14 +02:00
Victor Stinner 232465204e
gh-85283: Add PySys_Audit() to the limited C API (#108571)
The PySys_Audit() function was added in Python 3.8 by the PEP 578
"Python Runtime Audit Hooks".

Add also PySys_AuditTuple() to the limited C API, function added
to Python 3.13.

Move non-limited "PerfMap" C API from Include/sysmodule.h to
Include/cpython/sysmodule.h.
2023-10-17 16:02:23 +02:00
Pablo Galindo Salgado 24e4ec7766
gh-110938: Fix error messages for indented blocks with functions and classes with generic type parameters (#110973) 2023-10-17 13:45:13 +01:00
Victor Stinner 9a9fba825f
gh-110695: test_asyncio uses 50 ms for clock resolution (#110952)
Before utils.CLOCK_RES constant was added (20 ms), test_asyncio
already used 50 ms.
2023-10-17 11:34:04 +02:00
Victor Stinner cc71cc9256
gh-85283: Add PyMem_RawMalloc() to the limited C API (#108570)
Add PyMem_RawMalloc(), PyMem_RawCalloc(), PyMem_RawRealloc() and
PyMem_RawFree() to the limited C API.

These functions were added by Python 3.4 and are needed to port
stdlib extensions to the limited C API, like grp and pwd.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-10-17 02:41:51 +02:00
Pieter Eendebak a77180e663
gh-110905: [Enum] minor fixes and cleanup (GH-110906) 2023-10-16 13:37:54 -07:00
Alex Waygood 02d26c4bef
Enable ruff on several more files in `Lib/test` (#110929) 2023-10-16 15:57:01 +01:00
Lysandros Nikolaou a1ac5590e0
gh-107450: Check for overflow in the tokenizer and fix overflow test (#110832)
Co-authored-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-16 16:42:49 +02:00
Pablo Galindo Salgado b3c9faf056
gh-110912: Correctly display tracebacks for MemoryError exceptions using the traceback module (#110921) 2023-10-16 15:39:23 +01:00
Nikita Sobolev bad7a35055
gh-110907: AC: Disallow using `*` with vararg (#110908) 2023-10-16 15:26:11 +01:00
Alex Waygood 14d2d1576d
gh-110923: Fix silently skipped tests in test__opcode.py (#110926) 2023-10-16 13:30:35 +00:00
Nikita Sobolev c2192a2bee
gh-110864: Fix _PyArg_UnpackKeywordsWithVararg overwriting vararg with NULL (#110868) 2023-10-16 13:42:44 +02:00
Radislav Chugunov 162213f2db
gh-108791: Fix `pdb` CLI invalid argument handling (#108816) 2023-10-16 10:38:07 +01:00
Zachary Ware b75186f69e
regrtest: Prepend 'use' options in --{fast,slow}-ci (GH-110363)
This allows individual resources to be disabled without having to explicitly re-enable all others.
2023-10-15 20:34:28 +02:00
Hugo van Kemenade 9608704cde
Lint: Include test_monitoring.py for Ruff (#110898) 2023-10-15 17:48:00 +01:00
Tian Gao fa18b0afe4
gh-84583: Make pdb enter post-mortem mode even for SyntaxError (#110883) 2023-10-15 11:55:00 +01:00
Łukasz Langa 84b7e9e3fa
gh-110722: Add PYTHON_PRESITE to import a module before site.py is run (#110769) 2023-10-14 23:32:57 +02:00
Serhiy Storchaka ab08ff7882
bpo-42663: Fix parsing TZ strings in zoneinfo module (GH-23825)
zipinfo now supports the full range of values in the TZ string
determined by RFC 8536 and detects all invalid formats.
Both Python and C implementations now raise exceptions of the same
type on invalid data.
2023-10-14 23:24:33 +03:00
Thomas Grainger 596589104f
remove redundant call to attach_loop in watcher (#110847) 2023-10-14 10:24:02 +02:00
Kirill Podoprigora 4110cfec12
gh-110715: Add missing import in zipfile (gh-110822) 2023-10-14 16:17:47 +09:00
Serhiy Storchaka e2b3d831fd
gh-109747: Improve errors for unsupported look-behind patterns (GH-109859)
Now re.error is raised instead of OverflowError or RuntimeError for
too large width of look-behind pattern.

The limit is increased to 2**32-1 (was 2**31-1).
2023-10-14 09:13:02 +03:00
Serhiy Storchaka ca0f3d858d
gh-107705: Fix file leak in test_tkinter in the C locale (GH-110507) 2023-10-14 09:09:07 +03:00
Serhiy Storchaka 38bd2c520a
gh-88434: Emit deprecation warnings for non-integer numbers in gettext if translation not found (GH-110574) 2023-10-14 09:07:02 +03:00
Serhiy Storchaka 9d40ebf190
gh-110628: Add tests for PyLong C API (GH-110629) 2023-10-14 08:53:57 +03:00
Serhiy Storchaka 84e2096fbd
gh-110392: Fix tty functions (GH-110642)
* tty.setraw() and tty.setcbreak() previously returned partially modified
  list of the original tty attributes. Now they return the correct list of
  the original tty attributes

* tty.cfmakeraw() and tty.cfmakecbreak() now make a copy of the list of
  special characters before modifying it.
2023-10-14 08:50:41 +03:00
Serhiy Storchaka 7284e0ef84
gh-110815: Support non-ASCII keyword names in PyArg_ParseTupleAndKeywords() (GH-110816)
It already mostly worked, except in the case when invalid keyword
argument with non-ASCII name was passed to function with non-ASCII
parameter names. Then it crashed in the debug mode.
2023-10-14 08:50:03 +03:00
Victor Stinner ce298a1c15
regrtest: --fast-ci/slow-ci no longer imply --rerun-fail (#110849) 2023-10-14 00:25:38 +00:00
Victor Stinner 8f07b6e4e3
gh-110697: test_os TimerfdTests uses selectors (#110789)
Replace select.epoll() with selectors.DefaultSelector to support
FreeBSD 14 and newer.

* Merge common code between test_timerfd_epoll()
  test_timerfd_ns_epoll().
* Replace "_ = func()" with "func()".
* Add TimerfdTests.read_count_signaled() method.
2023-10-13 16:20:18 +02:00
Russell Keith-Magee a7e2a10a85
gh-110771: Decompose run_forever() into parts (#110773)
Effectively introduce an unstable, private (really: protected) API for subclasses that want to override `run_forever()`.
2023-10-13 14:12:32 +00:00
Serhiy Storchaka 548ce0923b
gh-110815: Improve tests for PyArg_ParseTupleAndKeywords() (GH-110817) 2023-10-13 16:05:01 +03:00
Thomas Wouters 11bbe6c6e1 Merge branch 'main' of https://github.com/python/cpython 2023-10-13 13:40:12 +02:00
Pablo Galindo Salgado e1d8c65e1d
gh-110805: Allow the repl to show source code and complete tracebacks (#110775) 2023-10-13 09:25:37 +00:00
Thomas Wouters ad056f03ae Python 3.13.0a1 2023-10-13 10:52:10 +02:00
Lysandros Nikolaou 2a68f77026
gh-107450: Fix testMemoryErrorBigSource using the bigmemtest decorator (GH-110810) 2023-10-13 08:30:56 +00:00
Nikita Sobolev 989a253947
gh-110525: Delete `test_c_api` method from `set` object (#110688) 2023-10-13 10:06:25 +02:00
Lysandros Nikolaou 05439d3087
gh-107450: Fix parser column offset overflow test on Windows (#110768)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-13 09:41:00 +02:00
Filipe Laíns 2f59d418cf
GH-110796: fix intermittent test failure in test_current_exceptions 2023-10-13 06:26:27 +00:00
Filipe Laíns 6478dea3c8
GH-110786: suppress BrokenPipeError on the sysconfig CLI (#110791) 2023-10-13 06:49:55 +01:00
Filipe Laíns 4a53a397c3
GH-103480: make sysconfig a package (GH-110785) 2023-10-12 23:41:34 +00:00
Jelle Zijlstra d2a536b170
gh-110782: Fix crash when TypeVar is constructed with keyword args (#110784) 2023-10-12 16:00:12 -07:00
Alex Waygood aa3f419acb
gh-109653: Improve the import time of `email.utils` (#109824) 2023-10-12 15:03:20 -07:00
Pablo Galindo Salgado e7331365b4
gh-110721: Use the traceback module for PyErr_Display() and fallback to the C implementation (#110702) 2023-10-12 14:52:14 +00:00
Thomas Grainger 8c6c14b91b
gh-94597: Add asyncio.EventLoop (#110723)
This is needed to pave the way for deprecating and eventually killing the event loop policy system (which is over-engineered and rarely used).
2023-10-12 07:13:57 -07:00
Nikita Sobolev b6000d2874
gh-109409: Fix inheritance of frozen dataclass from non-frozen dataclass mixins (gh-109437)
Fix inheritance of frozen dataclass from non-frozen dataclass mixins
2023-10-12 09:05:23 -04:00
Lysandros Nikolaou fb7843ee89
gh-107450: Raise OverflowError when parser column offset overflows (#110754) 2023-10-12 09:34:12 +00:00
Pablo Galindo Salgado 3d180347ae
gh-110696: Fix incorrect syntax error message for incorrect argument unpacking (#110706) 2023-10-12 09:02:02 +00:00
Hugo van Kemenade ea530f2f9a
gh-106193: Rename and fix duplicated tests in `test_monitoring` (GH-109139) 2023-10-12 08:43:58 +01:00
Lysandros Nikolaou 17d65547df
gh-104169: Fix test_peg_generator after tokenizer refactoring (#110727)
* Fix test_peg_generator after tokenizer refactoring
* Remove references to tokenizer.c in comments etc.
2023-10-12 09:34:35 +02:00
Nikita Sobolev 5257ade0bc
gh-110682: Ignore `__match_args__` from `__instancecheck__` in protocols (#110683)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-10-11 19:20:20 -07:00
Victor Stinner b4e8049766
gh-110673: test_pty raises on short write (#110677)
Add write_all() helper function to test_pty to raise an exception on
short write: if os.writes() does not write all bytes. It should not
happen for a PTY.
2023-10-11 21:30:15 +00:00
J. Nick Koston 3ac8e6955f
gh-110733: Micro-optimization in BaseEventLoop._run_once (#110735) 2023-10-11 20:59:27 +00:00
Tian Gao c523ce0f43
gh-65052: Prevent pdb from crashing when trying to display objects (#110578) 2023-10-11 19:52:14 +02:00
Serhiy Storchaka eb50cd37ea
gh-110289: C API: Add PyUnicode_EqualToUTF8() and PyUnicode_EqualToUTF8AndSize() functions (GH-110297) 2023-10-11 16:41:58 +03:00
Zackery Spytz f83fa0b9eb
gh-84489: Properly handle trailing spaces in Py_BuildValue() format strings (GH-21158)
The docs state that the space, tab, colon, and comma characters are
ignored in Py_BuildValue() format strings.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-11 14:44:06 +03:00
Serhiy Storchaka f27b830907
gh-76106: Remove the cleanup lock in test_socket (GH-110539)
It does not already work (because it locks only addCleanup(), not doCleanups()),
and it is no longer needed since the clean up procedure waits for all test threads to join.
2023-10-11 13:52:06 +03:00
Serhiy Storchaka 5c6e85480a
gh-84489: C API: Add tests for Py_BuildValue() (GH-110596) 2023-10-11 10:08:51 +03:00
Barney Gale b5f7777cb3
GH-110488: Fix two small issues in `pathlib.PurePath.with_name()` (#110651)
Ensure that `PurePath('foo/a').with_name('.')` raises `ValueError`

Ensure that `PureWindowsPath('foo/a').with_name('a:b')` does not raise
`ValueError`.
2023-10-11 04:45:11 +01:00
Victor Stinner 790ecf6302
gh-110662: multiprocessing test_async_timeout() increase timeout (#110663)
Increase timeout from 1 second to 30 seconds, if not longer. The
important part is that apply_async() takes longer than TIMEOUT2.
2023-10-11 02:36:06 +00:00
Victor Stinner 1556f426da
gh-110666: Fix multiprocessing test_terminate() elapsed (#110667)
multiprocessing test_terminate() and test_wait_socket_slow() no
longer test the CI performance: no longer check maximum elapsed time.

Add CLOCK_RES constant: tolerate a difference of 100 ms.
2023-10-11 01:49:09 +00:00
Victor Stinner f901f56313
gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (#110657)
Skip test_post_fork_child_no_deadlock() if Python is built with ASAN.

Add support.HAVE_ASAN_FORK_BUG.
2023-10-11 02:57:53 +02:00
Victor Stinner 7ca4aafa0e
gh-108277: test_os tolerates 1 ms diff for timerfd (#110661) 2023-10-11 00:38:04 +00:00
Victor Stinner e07c37cd52
gh-110647: Fix signal test_stress_modifying_handlers() (#110650)
* cycle_handlers() now waits until at least one signal is received.
* num_received_signals can be equal to num_sent_signals.
2023-10-10 23:59:43 +00:00
Barney Gale da0a68afc9
GH-110109: Simplify pathlib test setup (#110308)
Use the class under test to create files, directories and symlinks.
2023-10-11 00:03:42 +01:00
Radislav Chugunov 0d805b998d
gh-108826: Document `dis` module CLI and rename `_test` function to `main` (#108827)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-10-10 16:31:28 -06:00
Nikita Sobolev 732532b0af
gh-108303: Move all inspect test files to `test_inspect/` (#109607) 2023-10-10 22:15:11 +02:00
Nikita Sobolev 9cfb4e0d1e
gh-110525: Add tests for internal `set` CAPI (GH-110630) 2023-10-10 19:00:05 +03:00
Yilei Yang ce43d5f0e1
gh-110050: Adjust the newline position in the TypeError message of the random.seed call. (#110051)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-10-10 14:16:26 +02:00
Serhiy Storchaka 7f702b26db
gh-110388: Add tests for tty (GH-110394) 2023-10-10 13:42:25 +02:00
Serhiy Storchaka 92a9e98024
gh-81002: Add tests for termios (GH-110386) 2023-10-10 13:35:15 +02:00
Nikita Sobolev 344d3a222a
gh-110590: Fix a bug where _sre.compile would overwrite exceptions (#110591)
TypeError would be overwritten by OverflowError
if 'code' param contained non-ints.
2023-10-10 10:15:12 +00:00
Donghee Na 0362cbf908
gh-109595: Add -Xcpu_count=<n> cmdline for container users (#109667)
---------

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-10-10 19:00:09 +09:00
Serhiy Storchaka 5aa62a8de1
gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_async (#110500)
It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.
2023-10-10 11:38:40 +02:00
Alex Waygood fc811c8d20
gh-110558: Enable ruff's pyupgrade rules when running on Argument Clinic (#110603) 2023-10-10 09:35:36 +00:00
Eric Snow 757cc35b6b
gh-84570: Implement Waiting in SendChannel.send() (gh-110565)
We had been faking it (poorly).

We will add timeouts separately.
2023-10-10 09:35:14 +00:00
Alex Waygood 7b2764e798
gh-110558: Run ruff on Argument Clinic in CI (#110559) 2023-10-10 07:52:39 +00:00
Serhiy Storchaka 96fed66a65
gh-110378: Close invalid generators in contextmanager and asynccontextmanager (GH-110499)
contextmanager and asynccontextmanager context managers now close an invalid
underlying generator object that yields more then one value.
2023-10-10 09:43:04 +02:00
Serhiy Storchaka 326c6c4e07
gh-110519: Improve deprecation warning in the gettext module (#110520)
Deprecation warning about non-integer numbers in gettext now always refers
to the line in the user code where gettext function or method is used.
Previously, it could refer to a line in gettext code.

Also, increase test coverage for NullTranslations and domain-aware functions
like dngettext().
2023-10-09 15:45:22 +02:00
Eric Snow 7bd560ce8d
gh-76785: Add SendChannel.send_buffer() (#110246)
(This is still a test module.)
2023-10-09 07:39:51 -06:00
Nikita Sobolev c49edd7d9c
gh-110525: Add CAPI tests for set and frozenset objects (GH-110526) 2023-10-09 11:57:48 +03:00
Tian Gao dd4bb0529e
gh-110514: Add PY_THROW to `sys.setprofile` events (GH-110524) 2023-10-09 09:38:45 +01:00
Tian Gao 9f8282de6b
gh-106670: Set convenience variable for post mortem debugging (#110493) 2023-10-09 08:17:24 +00:00
Victor Stinner 7e30821b17
gh-108277: Fix test_os TimerfdTests (#110515)
* test_timerfd_TFD_TIMER_ABSTIME() and
  test_timerfd_ns_TFD_TIMER_ABSTIME() tolerate a difference of 50 us.
* test_timerfd_negative() checks if os.TFD_TIMER_CANCEL_ON_SET is
  defined.
2023-10-08 11:26:18 +00:00
Serhiy Storchaka d96a8cdfe2
gh-89902: Deprecate non-standard format specifier "N" for Decimal (GH-110508)
It was not documented and only supported in the C implementation.
2023-10-08 10:01:39 +03:00
Nikita Sobolev 6780d63ae5
gh-110378: Move to `IsolatedAsyncTestCase` in `test_contextlib_async.py` (#110379) 2023-10-08 11:44:56 +05:30
Masaru Tsuchiyama de2a4036cb
gh-108277: Add os.timerfd_create() function (#108382)
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-07 19:33:22 +02:00
Victor Stinner 64f158e7b0
gh-110397: Add Py_IsFinalizing() to the stable ABI (#110441) 2023-10-07 17:59:16 +02:00
Serhiy Storchaka b987fdb19b
gh-109848: Make test_rot13_func in test_codecs independent (GH-109850) 2023-10-07 16:01:39 +03:00
Serhiy Storchaka 1aad4fc5db
gh-109864: Make test_gettext tests order independent (GH-109866) 2023-10-07 16:00:28 +03:00
Eric Snow 92ca90b762
gh-76785: Support Running Some Functions in Subinterpreters (gh-110251)
This specifically refers to `test.support.interpreters.Interpreter.run()`.
2023-10-06 17:52:22 -06:00
Victor Stinner d023d4166b
gh-110184: Fix subprocess test_pipesize_default() (#110465)
For proc.stdin, get the size of the read end of the test pipe.

Use subprocess context manager ("with proc:").
2023-10-06 15:44:53 +02:00
Victor Stinner e0c4437793
Add support.MS_WINDOWS constant (#110446) 2023-10-06 02:37:28 +02:00
Carl Meyer 3c0f65ebce
gh-109287: fix overrides in cases generator (#110419) 2023-10-05 15:05:29 -07:00
Victor Stinner bb057b3370
gh-85283: Add PySys_AuditTuple() function (#108965)
sys.audit() now has assertions to check that the event argument is
not NULL and that the format argument does not use the "N" format.

Add tests on PySys_AuditTuple().
2023-10-05 21:59:35 +00:00
Victor Stinner aaf297c048
gh-109888: Fix test_os _kill_with_event() on Windows (#110421)
Replace os.kill() with proc.kill() which catchs PermissionError.

Rewrite _kill_with_event():

* Use subprocess context manager ("with proc:").
* Use sleeping_retry() to wait until the child process is ready.
* Replace SIGINT with proc.kill() on error.
* Replace 10 seconds with SHORT_TIMEOUT to wait until the process is
  ready.
* Replace 0.5 seconds with SHORT_TIMEOUT to wait for the process
  exit.
2023-10-05 21:40:49 +00:00
Sam Gross 3c2f3215cc
gh-110119: Fix test_importlib `--disable-gil` Windows test failures (#110422)
Use "t" in the expected tag for `--disable-gil` builds in test_tagged_suffix.
2023-10-05 19:51:17 +00:00
Victor Stinner 5eae8dc2cb
gh-109840: Fix multiprocessing test_waitfor_timeout() (#110428)
Don't measure the CI performance: don't fail if cond.wait_for() takes
longer than 1 second on a slow CI.
2023-10-05 19:32:06 +00:00
Victor Stinner 0db2f1475e
gh-110167: Increase support.LOOPBACK_TIMEOUT to 10 seconds (#110413)
Increase support.LOOPBACK_TIMEOUT from 5 to 10 seconds. Also increase
the timeout depending on the --timeout option. For example, for a
test timeout of 40 minutes (ARM Raspbian 3.x), use LOOPBACK_TIMEOUT
of 20 seconds instead of 5 seconds before.
2023-10-05 20:54:27 +02:00
Victor Stinner 318f5df271
gh-110167: Fix test_socket deadlock in doCleanups() (#110416)
Fix a deadlock in test_socket when server fails with a timeout but
the client is still running in its thread. Don't hold a lock to call
cleanup functions in doCleanups(). One of the cleanup function waits
until the client completes, whereas the client could deadlock if it
called addCleanup() in such situation.

doCleanups() is called when the server completed, but the client can
still be running in its thread especially if the server failed with a
timeout. Don't put a lock on doCleanups() to prevent deadlock between
addCleanup() called in the client and doCleanups() waiting for
self.done.wait of ThreadableTest._setUp().
2023-10-05 20:53:03 +02:00
AN Long 1f3af03f83
gh-110147: test_msvcrt: run console I/O tests in new processes (#110268) 2023-10-05 19:52:26 +02:00
Victor Stinner e37d4557c3
gh-110391: socket NetworkConnectionAttributesTest always declare cli (#110401)
NetworkConnectionAttributesTest of test_socket now always declare the
'cli' attribute, so clientTearDown() cannot fail with AttributeError.
2023-10-05 18:31:02 +02:00
Victor Stinner 1328fa31fe
gh-110393: Remove watchdog with hardcoded timeout (#110400)
test_builtin and test_socketserver no longer use signal.alarm() to
implement a watchdog with a hardcoded timeout (2 and 60 seconds).
Python test runner regrtest has two watchdogs: faulthandler and
timeout on running worker processes. Tests using short hardcoded
timeout can fail on slowest buildbots just because the timeout is too
short.
2023-10-05 15:02:48 +00:00
박문식 d33aa18f15
gh-82367: Use `FindFirstFile` Win32 API in `ntpath.realpath()` (GH-110298)
* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
2023-10-05 09:49:07 -05:00
sunmy2019 2cb62c6437
gh-110309: Prune empty constant in format specs (#110320)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-10-05 14:08:42 +00:00
Pablo Galindo Salgado cc389ef627
gh-110259: Fix f-strings with multiline expressions and format specs (#110271)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2023-10-05 14:26:44 +01:00
Victor Stinner af29282fce
gh-110367: Fix regrtest test_worker_output_on_failure() on ASAN build (#110387)
Set ASAN_OPTIONS="handle_segv=0" env var to run the test.
2023-10-05 14:42:36 +02:00
Victor Stinner 6592976061
gh-110367: Enhance regrtest -jN --verbose3 (#110368)
When using worker processes (-jN) with --verbose3 option, regrtest
can now display the worker output even if a worker process does
crash.  Previously, sys.stdout and sys.stderr were replaced and so
the worker output was lost on a crash.
2023-10-05 08:24:43 +02:00
Sam Gross cf6f23b0e3
gh-88402: Add new sysconfig variables on Windows (GH-110049)
Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
2023-10-04 22:50:29 +00:00
Xuehai Pan 3bbe3b7c82
gh-110222: Add support of PyStructSequence in copy.replace() (GH-110223) 2023-10-04 19:47:41 +03:00
Xuehai Pan 9561648f4a
gh-110235: Raise TypeError for duplicate/unknown fields in PyStructSequence constructor (GH-110258) 2023-10-04 19:44:17 +03:00
Hugo van Kemenade d8c00d2a60
Lint: Remove files that no longer fail to parse or with F811 (#110356) 2023-10-04 16:11:32 +03:00
Serhiy Storchaka 254e30c487
gh-109151: Enable readline in the sqlite3 CLI (GH-109152) 2023-10-04 14:16:44 +03:00
Nikita Sobolev e9f2352b7b
gh-110332: Remove mentions of `random.WichmannHill` from `test_zlib` (#110334) 2023-10-04 12:51:45 +02:00
Victor Stinner efd8c7a7c9
gh-109276: regrtest: shorter list of resources (#110326) 2023-10-04 09:39:50 +00:00
Victor Stinner 1337765225
gh-110335: asyncio test_unix_events cleans multiprocessing (#110336)
test_unix_events tests using the multiprocessing module now call
multiprocessing.util._cleanup_tests().
2023-10-04 09:19:08 +00:00
Victor Stinner 1de9406f91
gh-110166: Fix gdb CFunctionFullTests on ppc64le clang build (#110331)
CFunctionFullTests now also runs "bt" command before "py-bt-full",
similar to CFunctionTests which also runs "bt" command before
"py-bt". So test_gdb can skip the test if patterns like "?? ()" are
found in the gdb output.
2023-10-04 08:57:35 +00:00
Nikita Sobolev 1465386720
gh-110171: `libregrtest` always sets `random.seed` (#110172) 2023-10-04 06:42:12 +00:00
Serhiy Storchaka 5b9a3fd6a0
gh-110273: dataclasses.replace() now raise TypeError for all invalid arguments (GH-110274)
dataclasses.replace() now raises TypeError instead of ValueError if
specify keyword argument for a field declared with init=False or miss keyword
argument for required InitVar field.
2023-10-04 09:20:14 +03:00
Alex Waygood bfe7e72522
gh-109653: Defer importing `warnings` in several modules (#110286) 2023-10-04 06:09:43 +01:00
Eric Snow 269005e784
gh-110300: Fix Refleaks in test_interpreters and test__xxinterpchannels (gh-110318) 2023-10-04 00:36:50 +00:00
elfstrom a376a72bd9
gh-109917: Fix test instability in test_concurrent_futures (#110306)
The test had an instability issue due to the ordering of the dummy
queue operation and the real wakeup pipe operations. Both primitives
are thread safe but not done atomically as a single update and may
interleave arbitrarily. With the old order of operations this can lead
to an incorrect state where the dummy queue is full but the wakeup
pipe is empty. By swapping the order in clear() I think this can no
longer happen in any possible operation interleaving (famous last
words).
2023-10-03 22:59:49 +01:00
Guido van Rossum d67edcf0b3
gh-109979: Auto-generate the target for DEOPT_IF() (#110193)
In Python/bytecodes.c, you now write
```
    DEOPT_IF(condition);
```
The code generator expands this to
```
    DEOPT_IF(condition, opcode);
```
where `opcode` is the name of the unspecialized instruction.
This works inside macro expansions too.

**CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line.
If it isn't, the substitution will fail; an error will be printed by the code generator
and the C compiler will report some errors.
2023-10-03 10:13:50 -07:00
Eric Snow f5198b09e1
gh-109860: Use a New Thread State When Switching Interpreters, When Necessary (gh-110245)
In a few places we switch to another interpreter without knowing if it has a thread state associated with the current thread.  For the main interpreter there wasn't much of a problem, but for subinterpreters we were *mostly* okay re-using the tstate created with the interpreter (located via PyInterpreterState_ThreadHead()).  There was a good chance that tstate wasn't actually in use by another thread.

However, there are no guarantees of that.  Furthermore, re-using an already used tstate is currently fragile.  To address this, now we create a new thread state in each of those places and use it.

One consequence of this change is that PyInterpreterState_ThreadHead() may not return NULL (though that won't happen for the main interpreter).
2023-10-03 09:20:48 -06:00
Xuehai Pan 2d4865d775
gh-110267: Add tests for pickling and copying PyStructSequence objects (GH-110272) 2023-10-03 17:09:49 +03:00
Alex Waygood dddc757303
gh-110276: Run `test_str`, not `test_unicode`, as part of the PGO build (#110277)
`test_unicode` does not exist
2023-10-03 13:54:21 +01:00
Nikita Sobolev bb2e96f6f4
gh-109956: Also test typing.NamedTuple with copy.replace() (GH-109957) 2023-10-03 14:13:13 +03:00
Guido van Rossum 6678ef41d2
Add --inline-caches flag to dis command line (#110249) 2023-10-03 00:49:34 +00:00
Alex Waygood 21a6263020
gh-109653: Reduce the import time of `random` by 60% (#110221) 2023-10-02 22:56:31 +00:00
Eric Snow a8f5dab58d
gh-76785: Module-level Fixes for test.support.interpreters (gh-110236)
* add RecvChannel.close() and SendChannel.close()
* make RecvChannel and SendChannel shareable
* expose ChannelEmptyError and ChannelNotEmptyError
2023-10-02 20:47:41 +00:00
Alex Waygood 014aacda62
Enable ruff on `Lib/test/test_typing.py` (#110179) 2023-10-02 14:13:48 -06:00
Eric Snow 1dd9dee45d
gh-105716: Support Background Threads in Subinterpreters Consistently (gh-109921)
The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish.

We add PyInterpreterState.threads.main, with some internal C-API functions.
2023-10-02 20:12:12 +00:00
Eric Snow a040a32ea2
gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994)
This change makes sure sys.path[0] is set properly for subinterpreters. Before, it wasn't getting set at all. This PR does not address the broader concerns from gh-109853.
2023-10-02 19:59:05 +00:00
Victor Stinner 4d0d1c3866
gh-110014: Remove PY_TIMEOUT_MAX from limited C API (#110217)
If the timeout is greater than PY_TIMEOUT_MAX,
PyThread_acquire_lock_timed() uses a timeout of PY_TIMEOUT_MAX
microseconds, which is around 280.6 years. This case is unlikely and
limiting a timeout to 280.6 years sounds like a reasonable trade-off.

The constant PY_TIMEOUT_MAX is not used in PyPI top 5,000 projects.
2023-10-02 18:07:56 +02:00
Jelle Zijlstra 732ad44cec
gh-110178: Use fewer weakrefs in test_typing.py (#110194)
Confirmed that without the C changes from #108517, this test still segfaults with only 10 weakrefs.
2023-10-02 08:03:53 -07:00
Steve Dower 1b3bc610fd
gh-83180: Made launcher treat shebang 'python' tags as low priority so that active virtual environments are preferred (GH-108101) 2023-10-02 12:22:55 +00:00
AN Long 44b1e4ea48
gh-108963: using random to generate unique string in sys.intern test (#109491) 2023-10-02 13:07:56 +02:00