Commit Graph

29362 Commits

Author SHA1 Message Date
Miss Islington (bot) 46347d3caf
[3.11] gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) (#110659)
gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650)

* cycle_handlers() now waits until at least one signal is received.
* num_received_signals can be equal to num_sent_signals.
(cherry picked from commit e07c37cd52)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-11 00:21:51 +00:00
Miss Islington (bot) 28c6cc1928
[3.11] [3.12] gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489) (GH-109682) (#110646)
[3.12] gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489) (GH-109682)

* gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489)
(cherry picked from commit e57ecf6bbc)

Python 3.12 backport: update also `test_nntplib`.

(cherry picked from commit c2d542b42c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: T. Wouters <thomas@python.org>
2023-10-10 21:02:21 +00:00
Serhiy Storchaka 3788c48d12
[3.11] gh-110388: Add tests for tty (GH-110394) (GH-110634)
(cherry picked from commit 7f702b2)
2023-10-10 16:27:22 +02:00
Miss Islington (bot) e511f544ea
[3.11] gh-81002: Add tests for termios (GH-110386) (GH-110620)
(cherry picked from commit 92a9e98024)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-10 14:11:06 +02:00
Miss Islington (bot) bf1753bb4c
[3.11] gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_async (GH-110500) (#110611)
It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.
(cherry picked from commit 5aa62a8de1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-10 13:12:40 +02:00
Miss Islington (bot) 7fefed091a
[3.11] gh-110590: Fix a bug where _sre.compile would overwrite exceptions (GH-110591) (#110614)
TypeError would be overwritten by OverflowError
if 'code' param contained non-ints.
(cherry picked from commit 344d3a222a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-10 10:48:07 +00:00
Miss Islington (bot) 2b3a418279
[3.11] gh-110378: Close invalid generators in contextmanager and asynccontextmanager (GH-110499) (#110589)
contextmanager and asynccontextmanager context managers now close an invalid
underlying generator object that yields more then one value.
(cherry picked from commit 96fed66a65)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-10-10 11:12:52 +02:00
Miss Islington (bot) e913c6f4d6
[3.11] gh-110519: Improve deprecation warning in the gettext module (GH-110520) (GH-110564)
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().
(cherry picked from commit 326c6c4e07)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-09 16:10:34 +02:00
Miss Islington (bot) af168df78f
[3.11] gh-109848: Make test_rot13_func in test_codecs independent (GH-109850) (GH-110505)
(cherry picked from commit b987fdb19b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-07 13:24:27 +00:00
Miss Islington (bot) 682321292f
[3.11] gh-109864: Make test_gettext tests order independent (GH-109866) (GH-110503)
(cherry picked from commit 1aad4fc5db)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-07 13:23:54 +00:00
Miss Islington (bot) 49a45f6cd8
[3.11] gh-110184: Fix subprocess test_pipesize_default() (GH-110465) (#110472)
gh-110184: Fix subprocess test_pipesize_default() (GH-110465)

For proc.stdin, get the size of the read end of the test pipe.

Use subprocess context manager ("with proc:").
(cherry picked from commit d023d4166b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-06 14:11:51 +00:00
Victor Stinner 88223f15d7
[3.11] Add support.MS_WINDOWS constant (#110446) (#110452) (#110464)
[3.12] Add support.MS_WINDOWS constant (#110446) (#110452)

Add support.MS_WINDOWS constant (#110446)

(cherry picked from commit e0c4437793)
(cherry picked from commit e188534607)
2023-10-06 10:19:49 +00:00
Miss Islington (bot) 67129c379c
[3.11] gh-109888: Fix test_os _kill_with_event() on Windows (GH-110421) (#110443)
gh-109888: Fix test_os _kill_with_event() on Windows (GH-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.
(cherry picked from commit aaf297c048)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 22:06:28 +00:00
Miss Islington (bot) 4134036ce9
[3.11] gh-110393: Remove watchdog with hardcoded timeout (GH-110400) (#110444)
gh-110393: Remove watchdog with hardcoded timeout (GH-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.
(cherry picked from commit 1328fa31fe)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 22:05:20 +00:00
Miss Islington (bot) 331d90f30b
[3.11] [3.12] gh-110167: Increase support.LOOPBACK_TIMEOUT to 10 seconds (GH-110413) (GH-110427) (#110440)
[3.12] gh-110167: Increase support.LOOPBACK_TIMEOUT to 10 seconds (GH-110413) (GH-110427)

gh-110167: Increase support.LOOPBACK_TIMEOUT to 10 seconds (GH-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.

(cherry picked from commit 350d89b795)

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 0db2f1475e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 23:10:01 +02:00
Miss Islington (bot) a503bdf21f
[3.11] gh-109840: Fix multiprocessing test_waitfor_timeout() (GH-110428) (#110431)
gh-109840: Fix multiprocessing test_waitfor_timeout() (GH-110428)

Don't measure the CI performance: don't fail if cond.wait_for() takes
longer than 1 second on a slow CI.
(cherry picked from commit 5eae8dc2cb)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 19:53:14 +00:00
Miss Islington (bot) 8da3367067
[3.11] gh-110167: Fix test_socket deadlock in doCleanups() (GH-110416) (#110424)
gh-110167: Fix test_socket deadlock in doCleanups() (GH-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().
(cherry picked from commit 318f5df271)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 19:18:44 +00:00
Miss Islington (bot) cacea7a272
[3.11] gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-110401) (#110406)
gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-110401)

NetworkConnectionAttributesTest of test_socket now always declare the
'cli' attribute, so clientTearDown() cannot fail with AttributeError.
(cherry picked from commit e37d4557c3)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-05 16:58:46 +00:00
Hugo van Kemenade b0e43cb6cb
[3.11] Lint: Remove files that no longer fail to parse (GH-110356) (#110361)
Remove files that no longer fail to parse
2023-10-04 15:30:48 +01:00
Victor Stinner 8f22504d74
[3.11] gh-109974: Fix threading lock_tests race conditions (#110057) (#110355)
[3.12] gh-109974: Fix threading lock_tests race conditions (#110057) (#110346)

* gh-109974: Fix threading lock_tests race conditions (#110057)

Fix race conditions in test_threading lock tests. Wait until a
condition is met rather than using time.sleep() with a hardcoded
number of seconds.

* Replace sleeping loops with support.sleeping_retry() which raises
  an exception on timeout.
* Add wait_threads_blocked(nthread) which computes a sleep depending
  on the number of threads. Remove _wait() function.
* test_set_and_clear(): use a way longer Event.wait() timeout.
* BarrierTests.test_repr(): wait until the 2 threads are waiting for
  the barrier. Use a way longer timeout for Barrier.wait() timeout.
* test_thread_leak() no longer needs to count
  len(threading.enumerate()): Bunch uses
  threading_helper.wait_threads_exit() internally which does it in
  wait_for_finished().
* Add BaseLockTests.wait_phase() which implements a timeout.
  test_reacquire() and test_recursion_count() use wait_phase().

(cherry picked from commit 4e356ad183)

* gh-109974: Fix more threading lock_tests race conditions (#110089)

* Add context manager on Bunch class.
* Bunch now catchs exceptions on executed functions and re-raise them
  at __exit__() as an ExceptionGroup.
* Rewrite BarrierProxy.test_default_timeout(). Use a single thread.
  Only check that barrier.wait() blocks for at least default timeout
  seconds.
* test_with(): inline _with() function.

(cherry picked from commit 743e3572ee)
(cherry picked from commit 1d032ea3d6)
2023-10-04 12:07:57 +00:00
Miss Islington (bot) aa8d3db6f2
[3.11] [3.12] gh-109972: Enhance test_gdb (GH-110026) (GH-110351) (#110354)
[3.12] gh-109972: Enhance test_gdb (GH-110026) (GH-110351)

* gh-109972: Enhance test_gdb (GH-110026)

* Split test_pycfunction.py: add test_cfunction_full.py.
  Split the function into the following 6 functions. In verbose
  mode, these "pycfunction" tests now log each tested call.

  * test_pycfunction_noargs()
  * test_pycfunction_o()
  * test_pycfunction_varargs()
  * test_pycfunction_varargs_keywords()
  * test_pycfunction_fastcall()
  * test_pycfunction_fastcall_keywords()

* Move get_gdb_repr() to PrettyPrintTests.
* Replace DebuggerTests.get_sample_script() with SAMPLE_SCRIPT.
* Rename checkout_hook_path to CHECKOUT_HOOK_PATH.
* Rename gdb_version to GDB_VERSION_TEXT.
* Replace (gdb_major_version, gdb_minor_version) with GDB_VERSION.
* run_gdb() uses "backslashreplace" error handler instead of "replace".
* Add check_gdb() function to util.py.
* Enhance support.check_cflags_pgo(): check also for sysconfig
  PGO_PROF_USE_FLAG (if available) in compiler flags.
* Move some SkipTest checks to test_gdb/__init__.py.
* Elaborate why gdb cannot be tested on Windows: gdb doesn't support
  PDB debug symbol files.

(cherry picked from commit 757cbd4f29)

* gh-104736: Fix test_gdb tests on ppc64le with clang (GH-109360)

Fix test_gdb on Python built with LLVM clang 16 on Linux ppc64le (ex:
Fedora 38). Search patterns in gdb "bt" command output to detect
when gdb fails to retrieve the traceback. For example, skip a test if
"Backtrace stopped: frame did not save the PC" is found.

(cherry picked from commit 44d9a71ea2)

* gh-110166: Fix gdb CFunctionFullTests on ppc64le clang build (GH-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.

(cherry picked from commit bbce8bd05d)

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 1de9406f91)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-04 12:03:28 +00:00
Miss Islington (bot) d507493078
[3.11] gh-110332: Remove mentions of `random.WichmannHill` from `test_zlib` (GH-110334) (#110348)
gh-110332: Remove mentions of `random.WichmannHill` from `test_zlib` (GH-110334)
(cherry picked from commit e9f2352b7b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-04 11:17:38 +00:00
Victor Stinner f9ac377626
[3.11] Add test.support.busy_retry() (#93770) (#110341)
Add test.support.busy_retry() (#93770)

Add busy_retry() and sleeping_retry() functions to test.support.

(cherry picked from commit 7e9eaad864)
2023-10-04 12:58:49 +02:00
Victor Stinner 6c98c734c7
[3.11] gh-109972: Split test_gdb.py into test_gdb package (#109977) (… (#110343)
[3.12] gh-109972: Split test_gdb.py into test_gdb package (#109977) (#110339)

gh-109972: Split test_gdb.py into test_gdb package (#109977)

Split test_gdb.py file into a test_gdb package made of multiple
tests, so tests can now be run in parallel.

* Create Lib/test/test_gdb/ directory.
* Split test_gdb.py into multiple files in Lib/test/test_gdb/
  directory.
* Move Lib/test/gdb_sample.py to Lib/test/test_gdb/ directory.
  Update get_sample_script(): use __file__ to locate gdb_sample.py.
* Move gdb_has_frame_select() and HAS_PYUP_PYDOWN to test_misc.py.
* Explicitly skip test_gdb on Windows. Previously, test_gdb was
  skipped even if gdb was available because of
  gdb_has_frame_select().

(cherry picked from commit 8f324b7ecd)
(cherry picked from commit e7a61d34b7)
2023-10-04 10:53:28 +00:00
Miss Islington (bot) 5039db7f9b
[3.11] gh-110267: Add tests for pickling and copying PyStructSequence objects (GH-110272) (GH-110284)
(cherry picked from commit 2d4865d775)

Co-authored-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
2023-10-04 12:01:19 +03:00
Miss Islington (bot) 4e44927a0e
[3.11] gh-109917: Fix test instability in test_concurrent_futures (GH-110306) (#110316)
gh-109917: Fix test instability in test_concurrent_futures (GH-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).
(cherry picked from commit a376a72bd9)

Co-authored-by: elfstrom <elfstrom@users.noreply.github.com>
2023-10-03 23:27:56 +01:00
Alex Waygood 3079aa3f5d
[3.11] Enable ruff on `Lib/test/test_typing.py` (#110179) (#110290) 2023-10-03 15:09:06 +00:00
Miss Islington (bot) bf6843e91f
[3.11] [3.12] gh-109649: Enhance os.cpu_count() documentation (GH-110169) (#110226)
[3.12] gh-109649: Enhance os.cpu_count() documentation (GH-110169)

* gh-109649: Enhance os.cpu_count() documentation

* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!

* Restore removed text
(cherry picked from commit 5245b97e13)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 18:36:55 -07:00
Victor Stinner 86084d001f
[3.11] gh-110160: Fix flaky `test_find_periodic_pattern` in `string_tests` (… (#110183)
gh-110160: Fix flaky `test_find_periodic_pattern` in `string_tests` (#110170)

(cherry picked from commit 06faa9a39b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-01 22:43:57 +02:00
Miss Islington (bot) 446c81c3c3
[3.11] gh-110088: Fix asyncio test_prompt_cancellation() (GH-110157) (#110159)
gh-110088: Fix asyncio test_prompt_cancellation() (GH-110157)

Don't measure the CI performance: don't test the maximum elapsed
time. The check failed on a slow CI.
(cherry picked from commit c62b49ecc8)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-30 21:01:33 +00:00
Miss Islington (bot) 080f5b98d1
[3.11] gh-109748: Fix again venv test_zippath_from_non_installed_posix() (GH-110149) (#110153)
gh-109748: Fix again venv test_zippath_from_non_installed_posix() (GH-110149)

Call also copy_python_src_ignore() on listdir() names.

shutil.copytree(): replace set() with an empty tuple. An empty tuple
becomes a constant in the compiler and checking if an item is in an
empty tuple is cheap.
(cherry picked from commit 0def8c712b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-30 18:46:37 +00:00
Miss Islington (bot) 42b6883d5f
[3.11] gh-107888: Fix test_mmap PROT_EXEC comment (GH-110125) (#110130)
gh-107888: Fix test_mmap PROT_EXEC comment (GH-110125)
(cherry picked from commit 14098b78f7)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-29 22:19:33 +00:00
Victor Stinner 190e8fbfb7
[3.11] gh-108851: Fix support.get_recursion_available() for USE_STACKCHECK (#110127)
Add _testcapi.USE_STACKCHECK.

USE_STACKCHECK on using on Windows 32-bit.
2023-09-29 23:54:46 +02:00
Miss Islington (bot) a95e8cf908
gh-109615: Look for 'Modules' as landmark for test_copy_python_src_ignore (GH-110108)
(cherry picked from commit 20bc5f7c28)

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-09-29 15:48:59 +00:00
Miss Islington (bot) b07661d889
[3.11] gh-109592: test_eintr tolerates 20 ms when comparing timings (GH-110102) (#110107)
gh-109592: test_eintr tolerates 20 ms when comparing timings (GH-110102)
(cherry picked from commit 9c73a9acec)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-29 13:47:24 +00:00
Victor Stinner 8ac6890d5e
[3.11] gh-110031: Skip test_threading fork tests if ASAN (#110100) (#110104)
gh-110031: Skip test_threading fork tests if ASAN (#110100)

Skip test_threading tests using thread+fork if Python is built with
Address Sanitizer (ASAN).

(cherry picked from commit 86e76ab8af)
2023-09-29 15:19:37 +02:00
Victor Stinner 184ce1414b
[3.11] gh-110088, gh-109878: Fix test_asyncio timeouts (#110092) (#110099)
gh-110088, gh-109878: Fix test_asyncio timeouts (#110092)

Fix test_asyncio timeouts: don't measure the maximum duration, a test
should not measure a CI performance. Only measure the minimum
duration when a task has a timeout or delay. Add CLOCK_RES to
test_asyncio.utils.

(cherry picked from commit db0a258e79)
2023-09-29 14:16:15 +02:00
Miss Islington (bot) efe83ad276
[3.11] gh-110036: multiprocessing Popen.terminate() catches PermissionError (GH-110037) (#110065)
gh-110036: multiprocessing Popen.terminate() catches PermissionError (GH-110037)

On Windows, multiprocessing Popen.terminate() now catchs
PermissionError and get the process exit code. If the process is
still running, raise again the PermissionError. Otherwise, the
process terminated as expected: store its exit code.
(cherry picked from commit bd4518c60c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-29 01:04:58 +00:00
Miss Islington (bot) a99729599a
[3.11] gh-109960: Remove test_pty timeout of 10 seconds (GH-110058) (#110061)
gh-109960: Remove test_pty timeout of 10 seconds (GH-110058)

In 2003, test_pty got a hardcoded timeout of 10 seconds to prevent
hanging on AIX & HPUX "if run after test_openpty":
commit 7d8145268e. Since 2003, test_pty
was no longer reported to hang on AIX. But today, the test can fail
simply because a CI is busy running other tests in parallel.
The timeout of 10 seconds is no longer needed, just remove it.
Moreover, regrtest now has multiple built-in generic timeout
mecanisms.
(cherry picked from commit 5fdcea7440)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-29 00:30:38 +00:00
Davide Rizzo d6e8001467
[3.11] gh-110038: KqueueSelector must count all read/write events (GH-110039) (#110044)
[3.11] gh-110038: KqueueSelector must count all read/write events (GH-110039).
(cherry picked from commit b14f0ab51c)
2023-09-28 20:58:24 +02:00
Miss Islington (bot) 973d549e72
[3.11] gh-110033: Fix signal test_interprocess_signal() (GH-110035) (#110041)
gh-110033: Fix signal test_interprocess_signal() (GH-110035)

Fix test_interprocess_signal() of test_signal. Make sure that the
subprocess.Popen object is deleted before the test raising an
exception in a signal handler. Otherwise, Popen.__del__() can get the
exception which is logged as "Exception ignored in: ...." and the
test fails.
(cherry picked from commit 7e0fbf5175)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-28 17:48:58 +00:00
Miss Islington (bot) ff3cadd2a1
[3.11] gh-109594: Fix concurrent.futures test_timeout() (GH-110018) (#110022)
gh-109594: Fix concurrent.futures test_timeout() (GH-110018)

Fix test_timeout() of test_concurrent_futures.test_wait. Remove the
future which may or may not complete depending if it takes longer
than the timeout ot not. Keep the second future which does not
complete before wait(). Make also the test faster: 0.5 second instead
of 6 seconds, so remove @support.requires_resource('walltime')
decorator.
(cherry picked from commit 9be283e5e1)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-28 13:49:56 +00:00
Miss Islington (bot) 448a7071b1
[3.11] gh-109615: Fix support test_copy_python_src_ignore() on WASM (GH-109970) (#109976)
gh-109615: Fix support test_copy_python_src_ignore() on WASM (GH-109970)

Not only check if src_dir exists, but look also for Lib/os.py
landmark.
(cherry picked from commit cc54bcf17b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-27 15:58:20 +00:00
Victor Stinner 8ac20e5404
[3.11] gh-109615: Fix support test_copy_python_src_ignore() (#109958) (#109962)
gh-109615: Fix support test_copy_python_src_ignore() (#109958)

Fix the test when run on an installed Python: use "abs_srcdir" of
sysconfig, and skip the test if the Python source code cannot be
found.

* Tools/patchcheck/patchcheck.py, Tools/freeze/test/freeze.py and
  Lib/test/libregrtest/utils.py now first try to get "abs_srcdir"
  from sysconfig, before getting "srcdir" from sysconfig.
* test.pythoninfo logs sysconfig "abs_srcdir".

(cherry picked from commit b89ed9df39)
2023-09-27 11:00:22 +00:00
Victor Stinner 2423168604
[3.11] gh-109615: Fix test_tools.test_freeze SRCDIR (#109935) (#109951)
gh-109615: Fix test_tools.test_freeze SRCDIR (#109935)

Fix copy_source_tree() function of test_tools.test_freeze:

* Don't copy SRC_DIR/build/ anymore. This directory is modified by
  other tests running in parallel.
* Add test.support.copy_python_src_ignore().
* Use sysconfig to get the source directory.
* Use sysconfig.get_config_var() to get CONFIG_ARGS variable.

(cherry picked from commit 1512d6c6ee)
2023-09-27 08:59:02 +00:00
Miss Islington (bot) 88917ddf44
[3.11] gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928) (#109930)
gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928)
(cherry picked from commit 9dbfe2dc8e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-26 22:51:34 +00:00
Miss Islington (bot) 4e66eca489
[3.11] gh-109845: Make test_ftplib more stable under load (GH-109912) (GH-109920)
recv() can return partial data cut in the middle of a multibyte
character. Test raw binary data instead of data incorrectly decoded by parts.
(cherry picked from commit 2ef2fffe3b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-26 20:23:20 +00:00
Miss Islington (bot) f764abb375
[3.11] gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629) (#109897)
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629)

---------

(cherry picked from commit 0eb98837b6)

Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-26 12:21:52 +00:00
Miss Islington (bot) bda6949e86
[3.11] gh-109832: concurrent.futures test_deadlock restores sys.stderr (GH-109887) (#109893)
gh-109832: concurrent.futures test_deadlock restores sys.stderr (GH-109887)

test_error_at_task_unpickle() and
test_error_during_result_unpickle_in_result_handler() now restore
sys.stderr which is overriden by _raise_error_ignore_stderr().
(cherry picked from commit 2897142d2e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-26 11:08:27 +00:00
Miss Islington (bot) 95e616aee0
[3.11] gh-109401: Fix threading barrier test_default_timeout() (GH-109875) (#109877)
gh-109401: Fix threading barrier test_default_timeout() (GH-109875)

Increase timeouts. Barrier default timeout should be long enough to
spawn 4 threads on a slow CI.
(cherry picked from commit e5186c3de4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-26 00:34:00 +00:00
Miss Islington (bot) 358282e965
[3.11] gh-109748: Fix venv test_zippath_from_non_installed_posix() (GH-109872) (#109874)
gh-109748: Fix venv test_zippath_from_non_installed_posix() (GH-109872)

Fix test_zippath_from_non_installed_posix() of test_venv: don't copy
__pycache__/ sub-directories, because they can be modified by other
Python tests running in parallel.
(cherry picked from commit 25bb266fc8)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-26 01:41:32 +02:00
Miss Islington (bot) 22a8efa740
[3.11] gh-89363: Skip threading test_is_alive_after_fork() if ASAN (GH-109835) (#109856)
gh-89363: Skip threading test_is_alive_after_fork() if ASAN (GH-109835)

Skip test_is_alive_after_fork() of test_threading if Python is built
with Address Sanitizer (ASAN).
(cherry picked from commit bc06743533)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-25 16:29:56 +00:00
Miss Islington (bot) 9238c6880e
[3.11] gh-109833: Fix asyncio test_wait_for() (GH-109834) (#109838)
gh-109833: Fix asyncio test_wait_for() (GH-109834)

Expect the test to be "short" but don't measure the exact performance
of the CI. SHORT_TIMEOUT is about 30 seconds whereas the cancelled
coroutine takes around 1 hour.
(cherry picked from commit f29bc9c9a0)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-25 16:22:41 +02:00
elfstrom 97ea90194c
[3.11] gh-105829: Fix concurrent.futures.ProcessPoolExecutor deadlock (GH-108513) (#109783)
This fixes issue GH-105829, https://github.com/python/cpython/issues/105829

(cherry picked from commit 405b06375a)
2023-09-24 20:28:03 +01:00
Miss Islington (bot) 3db2ec26bc
[3.11] gh-109706: Fix multiprocessing test_nested_startmethod() (GH-109707) (#109763)
gh-109706: Fix multiprocessing test_nested_startmethod() (GH-109707)

Don't check order, queue items can be written in any order.
(cherry picked from commit b03a791497)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-22 22:09:46 +00:00
Nikita Sobolev 6bb18bb0b4
[3.11] gh-108303: Fix and move `badsyntax_pep3120.py` (GH-109513) (#109724)
* [3.11] gh-108303: Fix and move `badsyntax_pep3120.py` (GH-109513)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>.
(cherry picked from commit 4dd47c63a9)

Backport to 3.11: update also test_imp.

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-22 17:50:32 +02:00
Victor Stinner 1629b1d6f9
[3.11] gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710) (#109735)
gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710)

Replace harcoded sleep of 500 ms with synchronization using a pipe.

Fix also Process._feed_stdin(): catch also BrokenPipeError on
stdin.write(input), not only on stdin.drain().

(cherry picked from commit cbbdf2c144)
2023-09-22 14:34:53 +00:00
Nikita Sobolev f45ef5edab
[3.11] gh-109625: Move _ready_to_import() from test_import to support.import_helper (GH-109626) (#109718)
[3.11] gh-109625: Move _ready_to_import() from test_import to support.import_helper (GH-109626).
(cherry picked from commit 115c49ad5a)
2023-09-22 12:34:46 +02:00
Miss Islington (bot) 74978ae6c6
[3.11] gh-109702: Increase concurrent_futures deadlock timeout (GH-109703) (#109708)
gh-109702: Increase concurrent_futures deadlock timeout (GH-109703)

Replace SHORT_TIMEOUT with LONG_TIMEOUT in test_deadlock of
test_concurrent_futures.
(cherry picked from commit 1eb1b45183)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-22 02:02:57 +00:00
Miss Islington (bot) 43ff8fcce2
[3.11] gh-109375: Fix bug where pdb registers an alias without an associated command (GH-109376) (#109430)
gh-109375: Fix bug where pdb registers an alias without an associated command (GH-109376)
(cherry picked from commit 68a6f21f47)

Co-authored-by: buermarc <44375277+buermarc@users.noreply.github.com>
2023-09-22 03:45:11 +02:00
Victor Stinner 66a973a09e
[3.11] gh-108388: Convert test_concurrent_futures to package (#108401) (#109704)
* gh-108388: Convert test_concurrent_futures to package (#108401)

Convert test_concurrent_futures to a package of sub-tests.

(cherry picked from commit aa6f787faa)

Notes on backport to 3.11:

* AsCompletedTests: Revert test_future_times_out() => test_zero_timeout()
* Restore TODO comment
* ThreadPoolExecutorTest.test_hang_global_shutdown_lock():
  add @support.requires_resource('cpu').
2023-09-22 01:37:25 +00:00
Victor Stinner 3a6d8e615f
[3.11] gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#109697) (#109699)
gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#109697)

On FreeBSD, regular users cannot set the sticky bit. Skip the test if
chmod() fails with EFTYPE error.

(cherry picked from commit 26e06ad617)
2023-09-21 23:29:49 +00:00
Miss Islington (bot) b3af888342
[3.11] gh-108388: Split test_multiprocessing_spawn (GH-108396) (#109688)
gh-108388: Split test_multiprocessing_spawn (GH-108396)

Split test_multiprocessing_fork, test_multiprocessing_forkserver and
test_multiprocessing_spawn into test packages. Each package is made
of 4 sub-tests: processes, threads, manager and misc. It allows
running more tests in parallel and so reduce the total test duration.
(cherry picked from commit aa9a359ca2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-21 20:44:21 +00:00
Victor Stinner 8d99502aac
[3.11] gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265) (#109678)
* gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)

(cherry picked from commit 1110c5bc82)

* gh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314)

(cherry picked from commit 42ab2cbd7b)

---------

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-21 21:46:05 +02:00
Victor Stinner 37b261799b
[3.11] gh-108303: Move `test_future` into its own test_future_stmt subdir (#109368) (#109680)
gh-108303: Move `test_future` into its own test_future_stmt subdir (#109368)

(cherry picked from commit 82505dc351)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-21 21:45:37 +02:00
Victor Stinner 84d8fdb266
[3.11] gh-109546: Add more tests for formatting floats (GH-109548) (#109685)
gh-109546: Add more tests for formatting floats (GH-109548)

(cherry picked from commit beb5ec5817)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-21 21:45:18 +02:00
Victor Stinner ca8da713d5
[3.11] gh-108303: Create Lib/test/test_dataclasses/ directory (#108978) (#109675)
gh-108303: Create Lib/test/test_dataclasses/ directory (#108978)

Move test_dataclasses.py and its "dataclass_*.py" modules into the
new Lib/test/test_dataclasses/ subdirectory.

Backport to 3.11: update Lib/test/.ruff.toml.

(cherry picked from commit 14d6e197cc)
2023-09-21 18:59:11 +00:00
Victor Stinner e59ee6c59e
[3.11] gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354) (#109673)
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)

(cherry picked from commit 3f61cf646d)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-21 18:18:39 +00:00
Miss Islington (bot) 3ba4dfe9cd
[3.11] gh-108303: Remove unused Lib/test/sgml_input.html (GH-108305) (#109670)
gh-108303: Remove unused Lib/test/sgml_input.html (GH-108305)

In Python 2.7, the file was used by Lib/test/test_sgmllib.py to test
Lib/sgmllib.py. The sgmllib module and its tests have been removed in
Python 3.0.
(cherry picked from commit d2879f2095)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-21 18:07:14 +00:00
Alex Waygood a023de65fc
[3.11] Fix typos in docs and comments (#109619) (#109622)
Co-authored-by: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com>
2023-09-20 17:50:48 +00:00
Victor Stinner 8c7fadb9bf
[3.11] gh-103053: Skip test_freeze_simple_script() on PGO build (#109591) (#109616)
gh-103053: Skip test_freeze_simple_script() on PGO build (#109591)

Skip test_freeze_simple_script() of test_tools.test_freeze if Python
is built with "./configure --enable-optimizations", which means with
Profile Guided Optimization (PGO): it just makes the test too slow.
The freeze tool is tested by many other CIs with other (faster)
compiler flags.

test.pythoninfo now gets also get_build_info() of
test.libregrtests.utils.

(cherry picked from commit 81cd1bd713)
2023-09-20 15:45:23 +00:00
Shantanu 2184b76496
[3.11] gh-108843: fix ast.unparse for f-string with many quotes (#108980)
* [3.11] gh-108843: fix ast.unparse for f-string with many quotes

* 📜🤖 Added by blurb_it.

* simplify

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-18 15:11:56 +01:00
Hugo van Kemenade a95d159bba
[3.11] gh-60283: Check for redefined test names in CI (#109161) (#109366)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
(cherry picked from commit 3cb9a8edca)
2023-09-15 05:45:23 +00:00
Victor Stinner 7a20797056
[3.11] gh-108822: Fix regrtest clear_caches() (#109432)
gh-108822: Fix regrtest clear_caches()

Python 3.11 doesn't have fractions._hash_algorithm cache.
2023-09-15 00:07:28 +00:00
Miss Islington (bot) f7bfac4b3d
[3.11] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (#109427)
gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423)

Use a longer key: FIPS mode requires at least of at least 112 bits.
The previous key was only 32 bits.
(cherry picked from commit e091b9f20f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-15 00:52:40 +02:00
Miss Islington (bot) f1f85a42ea
[3.11] gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (#109380)
gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352)
(cherry picked from commit 79101edb03)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-13 16:32:08 +00:00
Miss Islington (bot) 66c0d0ac8c
[3.11] gh-104736: Fix test_gdb tests on ppc64le with clang (GH-109360) (#109362)
gh-104736: Fix test_gdb tests on ppc64le with clang (GH-109360)

Fix test_gdb on Python built with LLVM clang 16 on Linux ppc64le (ex:
Fedora 38). Search patterns in gdb "bt" command output to detect
when gdb fails to retrieve the traceback. For example, skip a test if
"Backtrace stopped: frame did not save the PC" is found.
(cherry picked from commit 44d9a71ea2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-13 04:48:44 +00:00
Irit Katriel 1e8696133c
[3.11] gh-109179: Fix traceback display for SyntaxErrors with notes (#109197) (#109283)
gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)

(cherry picked from commit ecd21a629a)
2023-09-12 09:57:28 +00:00
Miss Islington (bot) 5d47fb186e
[3.11] gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (GH-109299) (#109303)
gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (GH-109299)

Fix test_os.test_access_denied() when the TEMP environment variable
is equal to the current working directory. Run the test using a
different filename, since self.fname already exists in this case.
(cherry picked from commit 7dedfd36dc)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-12 02:00:36 +00:00
Miss Islington (bot) abf3a68fe3
[3.11] gh-109295: Clean up multiprocessing in test_asyncio and test_compileall (GH-109298) (#109302)
gh-109295: Clean up multiprocessing in test_asyncio and test_compileall (GH-109298)

test_asyncio and test_compileall now clean up multiprocessing by
calling multiprocessing _cleanup_tests(): explicitly clean up
resources and stop background processes like the resource tracker.
(cherry picked from commit 09ea4b8706)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-12 01:53:59 +00:00
Miss Islington (bot) 9297a72dbd
[3.11] gh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644) (GH-109274)
(cherry picked from commit baa6dc8e38)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-11 16:35:41 +00:00
Miss Islington (bot) 74988a47e7
[3.11] Test DocTestFinder directly instead of calling support.run_doctest() (GH-108917) (GH-109260)
(cherry picked from commit 0abc935086)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-11 11:30:24 +00:00
Miss Islington (bot) a7e80fb628
[3.11] gh-109230: test_pyexpat no longer depends on the current directory (GH-109233) (#109242)
gh-109230: test_pyexpat no longer depends on the current directory (GH-109233)

Fix test_pyexpat.test_exception(): it can now be run from a directory
different than Python source code directory. Before, the test failed
in this case.

Skip the test if Modules/pyexpat.c source is not available. Skip also
the test on Python implementations other than CPython.
(cherry picked from commit e55aab9578)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-10 22:46:47 +00:00
Miss Islington (bot) cef4951116
[3.11] gh-109237: Fix test_site for non-ASCII working directory (GH-109238) (#109240)
gh-109237: Fix test_site for non-ASCII working directory (GH-109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f8ad)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-10 22:39:49 +00:00
Miss Islington (bot) b070d73ff2
[3.11] gh-50644: Forbid pickling of codecs streams (GH-109180) (GH-109232)
Attempts to pickle or create a shallow or deep copy of codecs streams
now raise a TypeError.

Previously, copying failed with a RecursionError, while pickling
produced wrong results that eventually caused unpickling to fail with
a RecursionError.
(cherry picked from commit d6892c2b92)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-10 17:41:19 +00:00
Miss Islington (bot) c20658249d
[3.11] gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) (GH-109228)
(cherry picked from commit 4297499696)

Co-authored-by: 云line <31395137+yunline@users.noreply.github.com>
2023-09-10 16:50:22 +03:00
Miss Islington (bot) 6b2f44ea78
[3.11] GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142) (#109150)
GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142)

Use `asyncio.sleep(0)` instead of short sleeps.
(cherry picked from commit ccd48623d4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-09-08 17:02:57 +00:00
Miss Islington (bot) c1a2ef5efc
[3.11] gh-106922: Fix error location for constructs with spaces and parentheses (GH-108959) (#109148)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2023-09-08 16:56:10 +00:00
Miss Islington (bot) 9dd28d2da9
[3.11] gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964) (#108968)
gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964)

Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
(cherry picked from commit cd2ef21b07)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-08 07:07:54 +00:00
Ethan Furman effa2ecdcf
[3.11] gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704) (GH-108739)
When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .

    member = object.__new__(cls)
    member = int.__new__(cls, value)
    member = str.__new__(cls, value)

Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.

(cherry picked from commit d48760b2f1)
2023-09-07 18:57:48 -07:00
Miss Islington (bot) e46be0d2fa
[3.11] gh-68403: Fix test_coverage in test_trace (GH-108910) (GH-109105)
Its behavior no longer affected by test running options such as -m.
(cherry picked from commit 7e1a7abb98)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-07 19:10:19 +00:00
Miss Islington (bot) c2b8d4fe0d
[3.11] gh-75743: Restore test_timeout.testConnectTimeout() (GH-109087) (#109102)
gh-75743: Restore test_timeout.testConnectTimeout() (GH-109087)

This un-skips this test now that pythontest.net implements appropriate firewall
rules for it.
(cherry picked from commit 1829a3c9a3)

Co-authored-by: Ee Durbin <ewdurbin@gmail.com>
2023-09-07 18:55:50 +00:00
Serhiy Storchaka dae62d456e
[3.11] gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081) (GH-109091)
It now points on the invalid non-ASCII character, not on the valid numerical literal.
(cherry picked from commit b2729e93e9)
2023-09-07 14:54:07 +00:00
Serhiy Storchaka 49cc2e7984
[3.11] gh-103186: Suppress RuntimeWarning about unclosed async iterator in test_sys_settrace (GH-109075) (GH-109086)
(cherry picked from commit d485551c9d)
2023-09-07 14:16:13 +00:00
Miss Islington (bot) 12f40a4340
[3.11] gh-103186: Remove debug print in test_sys_settrace (GH-109077) (GH-109085)
(cherry picked from commit e4bb0026b9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-07 14:13:42 +00:00
Miss Islington (bot) 883ff44f0d
[3.11] test.pythoninfo logs freedesktop_os_release() (GH-109057) (#109063)
test.pythoninfo logs freedesktop_os_release() (GH-109057)
(cherry picked from commit babdced23f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-07 06:13:34 +00:00
Victor Stinner 1ebe014d62
[3.11] gh-109015: Add test.support.socket_helper.tcp_blackhole() (#109016) (#109042)
gh-109015: Add test.support.socket_helper.tcp_blackhole() (#109016)

Skip test_asyncio, test_imaplib and test_socket tests if FreeBSD TCP
blackhole is enabled (net.inet.tcp.blackhole=2).

(cherry picked from commit a52a350977)
2023-09-07 00:34:16 +00:00
Victor Stinner 95eb9849dd
[3.11] gh-108851: Fix tomllib recursion tests (#108853) (#109013)
gh-108851: Fix tomllib recursion tests (#108853)

* Add get_recursion_available() and get_recursion_depth() functions
  to the test.support module.
* Change infinite_recursion() default max_depth from 75 to 100.
* Fix test_tomllib recursion tests for WASI buildbots: reduce the
  recursion limit and compute the maximum nested array/dict depending
  on the current available recursion limit.
* test.pythoninfo logs sys.getrecursionlimit().
* Enhance test_sys tests on sys.getrecursionlimit()
  and sys.setrecursionlimit().

Backport notes:

* Set support.infinite_recursion() minimum to 4 frames.
* test_support.test_get_recursion_depth() uses limit-2, apparently
  f-string counts for 2 frames in Python 3.11.
* test_sys.test_setrecursionlimit_to_depth() tests depth+2 instead of
  depth+1.

(cherry picked from commit 8ff1142578)
2023-09-06 16:40:39 +00:00
Miss Islington (bot) d61b8f9b8b
[3.11] gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999) (#109011)
gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999)

Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a251)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-06 15:32:36 +00:00
Miss Islington (bot) b8340905fc
[3.11] gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984) (#109001)
gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984)
(cherry picked from commit 1fb20d42c5)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-06 14:09:54 +00:00
Serhiy Storchaka cf19e8ea3a
[3.11] gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480) (GH-108924)
(cherry picked from commit 1e0d62793a)
2023-09-05 15:27:55 +00:00
Miss Islington (bot) 4e5fd6dc14
[3.11] gh-89392: Use unittest test runner for doctests in test_getopt (GH-108916) (GH-108920)
(cherry picked from commit f980cc19b9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-05 15:08:14 +00:00
Miss Islington (bot) e2404f5ed9
[3.11] gh-89392: Use normal unittest runner in test_type_cache (GH-108911) (GH-108914)
(cherry picked from commit eaabaac7c0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-05 14:11:49 +00:00
Serhiy Storchaka 492e1ffdce
[3.11] gh-89392: Remove support of test_main() in libregrtest (GH-108876) (GH-108898)
(cherry picked from commit 04a0830b00)
2023-09-05 06:54:12 +00:00
Miss Islington (bot) 562c168856
[3.11] gh-89392: Fix running test_pep646_syntax as script (GH-108875) (GH-108877)
(cherry picked from commit f3b6608ba2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-05 06:41:15 +00:00
Serhiy Storchaka 3fd6ada2e6
[3.11] bpo-45229: Make ElementTree tests discoverable (GH-108859) (GH-108874)
(cherry picked from commit 074ac1f72e)
2023-09-04 10:43:12 +00:00
Miss Islington (bot) 723ca8c387
[3.11] gh-89392: Remove test_main() in test_netrc (GH-108860) (GH-108868)
(cherry picked from commit 76f3c043b6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-04 10:20:24 +00:00
Miss Islington (bot) 75df36e0d5
[3.11] gh-89392: Make test_pep646_syntax discoverable (GH-108861) (GH-108869)
(cherry picked from commit d0b22f6bd8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-04 13:11:33 +03:00
Victor Stinner 79f7a4c0a4
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"

This reverts commit d5418e97fc.

* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"

This reverts commit ecb09a8496.

* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"

This reverts commit b2aa28eec5.

* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"

This reverts commit 0122ab235b.

* Revert "Run Tools/scripts/reindent.py (GH-94225)"

This reverts commit f0f3a424af.

* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"

This reverts commit 1347607db1.

* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"

This reverts commit 1073184918.

* gh-93353: regrtest checks for leaked temporary files (#93776)

When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.

(cherry picked from commit e566ce5496)

* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)

(cherry picked from commit 36934a16e8)

* gh-93353: regrtest supports checking tmp files with -j2 (#93909)

regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.

(cherry picked from commit 4f85cec9e2)

* gh-84461: Fix Emscripten umask and permission issues (GH-94002)

- Emscripten's default umask is too strict, see
  https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
  (root). Disable effective uid/gid syscalls and fix tests that use
  chmod() current user.
- Cannot drop X bit from directory.

(cherry picked from commit 2702e408fd)

* gh-94052: Don't re-run failed tests with --python option (#94054)

(cherry picked from commit 0ff7b996f5)

* Run Tools/scripts/reindent.py (#94225)

Reindent files which were not properly formatted (PEP 8: 4 spaces).

Remove also some trailing spaces.

(cherry picked from commit e87ada48a9)

* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba23324)

* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)

Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f379433)

* gh-95027: Fix regrtest stdout encoding on Windows (#98492)

On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.

(cherry picked from commit ec1f6f5f13)

* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)

The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.

* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"

(cherry picked from commit c76db37c0d)

* gh-100086: Add build info to test.libregrtest (#100093)

The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.

(cherry picked from commit 3c89202247)

* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f)

* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)

This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.

After porting we can see the direct impact on a multicore system.

Without this change:
  Running make test is 5 min 26 seconds
With this change:
  Running make test takes 3 min 39 seconds

That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.

The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.

Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.

---------

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77)

* Display the sanitizer config in the regrtest header. (#105301)

Display the sanitizers present in libregrtest.

Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.

(cherry picked from commit 852348ab65)

* gh-101634: regrtest reports decoding error as failed test (#106169)

When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.

(cherry picked from commit 2ac3eec103)

* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)

Enable with --disable-gil --without-pydebug:

    $ make pythoninfo|grep NOGIL
    sysconfig[Py_NOGIL]: 1

    $ ./python -m test
    ...
    == Python build: nogil debug
    ...

(cherry picked from commit 5afe0c17ca)

* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)

* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".

(cherry picked from commit 3a1ac87f8f)

* gh-108388: regrtest splits test_asyncio package (#108393)

Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".

Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.

(cherry picked from commit 174e9da083)

* regrtest computes statistics (#108793)

test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.

Changes:

* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
  in-place.
* libregrtest summary lists the number of run tests and skipped
  tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
  test state.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb3)

* gh-108822: Add Changelog entry for regrtest statistics (#108821)

---------

Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
Miss Islington (bot) ba47d87282
[3.11] Reorder some test's decorators (GH-108804) (GH-108845)
For example, do not demand the 'cpu' resource if the test cannot be run
due to non-working threads.
(cherry picked from commit 509bb61977)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-03 13:01:49 +00:00
Serhiy Storchaka 76f52196b9
[3.11] gh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421) (GH-108799)
Only mark tests which spend significant system or user time,
by itself or in subprocesses.
(cherry picked from commit f3ba0a74cd)
2023-09-03 09:34:30 +03:00
Miss Islington (bot) fc114a72bc
[3.11] gh-103186: assert in tests that UnsafeMailcapInput warnings are provided (GH-103217) (GH-108800)
(cherry picked from commit 1724553e6e)

Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
2023-09-02 05:53:48 +00:00
Miss Islington (bot) 385b1952f0
[3.11] gh-108520: Fix bad fork detection in nested multiprocessing use case (GH-108568) (#108692)
gh-107275 introduced a regression where a SemLock would fail being passed along nested child processes, as the `is_fork_ctx` attribute would be left missing after the first deserialization.

---------

(cherry picked from commit add8d45cbe)

Co-authored-by: albanD <desmaison.alban@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-08-30 22:36:26 +02:00
Erlend E. Aasland 6f24420cbf
[3.11] gh-108590: Revert gh-108657 (commit 400a1cebc) (#108686) (#108694)
(cherry picked from commit 2a3926fa51)

Reverted per Serhiy's request.
2023-08-30 20:12:10 +00:00
Corvin 5a6d1238bb
[3.11] gh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (GH-108657) (#108674)
(cherry picked from commit 400a1cebc7)
2023-08-30 12:29:33 +02:00
Serhiy Storchaka 2e4c3efec1
[3.11] Revert "[3.11] Use non alternate name for Kyiv (GH-108533) (GH-108641)" (GH-108650)
This reverts commit 34f84f2b9f.

It broke tests on the Debian and macOS buildbots.
2023-08-29 23:09:20 +03:00
Miss Islington (bot) 34f84f2b9f
[3.11] Use non alternate name for Kyiv (GH-108533) (GH-108641)
tzdata provides Kiev as an alternative to Kyiv:

https://sources.debian.org/src/tzdata/2023c-10/backward/?hl=314GH-L314

But Debian moved it to the tzdata-legacy package breaking the test:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050530

This patch switches to the name provided by tzdata.
(cherry picked from commit 7659128b9d)

Co-authored-by: Jochen Sprickerhof <github@jochen.sprickerhof.de>
2023-08-29 15:47:54 +00:00
Miss Islington (bot) cc12c965af
[3.11] gh-108558: Improve sqlite3 row factory tests (GH-108578) (#108616)
Add test_sqlite_row_keys() to explicitly test sqlite3.Row.keys().

Cleanups:
- Reduce test noise by converting docstrings to regular comments
- Reduce boilerplate code by adding a setUp() method to RowFactoryTests

(cherry picked from commit 6eaddc10e9)

Co-authored-by: Edward Schauman-Haigh <142528725+EddInSverige@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-29 09:47:27 +00:00
Miss Islington (bot) ed749be3aa
[3.11] gh-105821: Use a raw f-string in test_httpservers.py (GH-105822) (#108576)
gh-105821: Use a raw f-string in test_httpservers.py (GH-105822)

Use a raw f-string in test_httpservers.py
(cherry picked from commit 09ce8c3b48)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2023-08-28 17:44:13 +00:00
Erlend E. Aasland 33eee4340e
[3.11] gh-64662: Fix virtual table support in sqlite3.Connection.iterdump (#108340) (#108564)
(cherry picked from commit d0160c7c22)

Co-authored-by: Aviv Palivoda <palaviv@gmail.com>
2023-08-28 13:09:33 +00:00
Erlend E. Aasland 6f6171b33b
[3.11] gh-108550: Speed up sqlite3 tests (#108551) (#108567)
Disable the busy handler for all concurrency tests; we have full
control over the order of the SQLite C API calls, so we can safely
do this.

test_sqlite3.test_transactions now completes ~10 times faster than before.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-28 13:09:10 +00:00
Serhiy Storchaka 0c79fabb03
[3.11] gh-108418: Speed up bigmem compression tests in dry mode (GH-108419) (GH-108481)
Only generate and compress small amount of random data in dry run.
(cherry picked from commit 4ae3edf300)
2023-08-25 12:10:22 +00:00
Łukasz Langa d90f2f3a62
[3.11] gh-108342: Make ssl TestPreHandshakeClose more reliable (GH-108370) (#108405)
* In preauth tests of test_ssl, explicitly break reference cycles
  invoving SingleConnectionTestServerThread to make sure that the
  thread is deleted. Otherwise, the test marks the environment as
  altered because the threading module sees a "dangling thread"
  (SingleConnectionTestServerThread). This test leak was introduced
  by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
  timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
  test_preauth_data_to_tls_client(): the server now waits until the
  client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
  explicitly.
* Replace "localhost" with server.listener.getsockname()[0].
(cherry picked from commit 592bacb6fc)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-24 12:08:52 +02:00
Miss Islington (bot) 34ef75d3ef
[3.11] gh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before serializing it (GH-107275) (#108378)
gh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before serializing it (GH-107275)

Ensure multiprocessing SemLock is valid for spawn Process before serializing it.

Creating a multiprocessing SemLock with a fork context, and then trying to pass it to a spawn-created Process, would segfault if not detected early.

---------

(cherry picked from commit 1700d34d31)

Co-authored-by: albanD <desmaison.alban@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-08-23 21:11:20 +00:00
Victor Stinner 1aff195903
[3.11] gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343) (#108347)
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)

Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.

(cherry picked from commit 9173b2bbe1)
2023-08-23 03:47:41 +00:00
Victor Stinner a15396146f
[3.11] gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325) (#108336)
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)

* Move test_cppext to its own directory
* Rename setup_testcppext.py to setup.py
* Rename _testcppext.cpp to extension.cpp
* The source (extension.cpp) is now also copied by the test.

(cherry picked from commit 21dda09600)
2023-08-23 05:11:53 +02:00
Łukasz Langa 75a875e0df
[3.11] gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108317)
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw

Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.

The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-08-22 19:53:19 +02:00
Miss Islington (bot) 5be32d8818
[3.11] gh-106016: Add Lib/test/test_module/ directory (GH-108293) (#108304)
gh-106016: Add Lib/test/test_module/ directory (GH-108293)

* Move Python scripts related to test_module to this new directory:
  good_getattr.py and bad_getattrX.py scripts.
* Move Lib/test/test_module.py to Lib/test/test_module/__init__.py.
(cherry picked from commit adfc118fda)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-22 15:42:00 +00:00
Miss Islington (bot) 8927cf0200
[3.11] gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)
gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)

---------

(cherry picked from commit de33b5c662)

Co-authored-by: Steve Dower <steve.dower@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-08-22 15:35:16 +01:00
Hugo van Kemenade d678ee7719
[3.11] Trim trailing whitespace and test on CI (GH-104275) (#108215) 2023-08-22 12:57:31 +03:00
Miss Islington (bot) 8e837373ed
[3.11] gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846) (GH-108209)
gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846)

(cherry picked from commit acbd3f9c5c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Lumír 'Frenzy' Balhar <frenzy.madness@gmail.com>
2023-08-22 10:51:58 +02:00
Miss Islington (bot) 75617ac3f0
[3.11] gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485) (GH-108208)
gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485)

In the stack call of: _init_read_gz()
```
_read, tarfile.py:548
read, tarfile.py:526
_init_read_gz, tarfile.py:491
```
a try;except exists that uses `self.exception`, so it needs to be set before
calling _init_read_gz().
(cherry picked from commit 37135d25e2)

Co-authored-by: balmeida-nokia <83089745+balmeida-nokia@users.noreply.github.com>
2023-08-21 17:16:59 +02:00
Miss Islington (bot) a1d2e2c2ac
[3.11] gh-105736: Sync pure python version of OrderedDict with the C version (GH-108098) (GH-108201)
(cherry picked from commit 20cc90c0df)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-08-21 10:37:09 +00:00
Miss Islington (bot) d4c66bd732
[3.11] gh-107895: Fix test_asyncio.test_runners when run it in CPython's "development mode" (GH-108168) (GH-108197)
(cherry picked from commit 014a5b71e7)

Co-authored-by: Joon Hwan 김준환 <xncbf12@gmail.com>
2023-08-21 08:36:37 +00:00
Miss Islington (bot) c1c3f0bfec
[3.11] bpo-18319: gettext() can retrieve a message even if a plural form exists (GH-19869) (GH-107107)
(cherry picked from commit 54632528ee)

Co-authored-by: Gilles Bassière <gbassiere@gmail.com>
2023-08-16 09:15:01 +00:00
Serhiy Storchaka 26137e2cf7
[3.11] gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612) (GH-108004)
Restore the global Input Stream pointer after trying to match a sub-pattern.

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>

(cherry picked from commit abd9cc52d9)
    
Co-authored-by: SKO <41810398+uyw4687@users.noreply.github.com>
2023-08-16 08:36:36 +00:00
Serhiy Storchaka 4cfbcffd3d
[3.11] gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802) (GH-107999)
Restore following CPython <= 3.10.5 behavior of shutil.make_archive()
that went away as part of gh-93160:

Do not create an empty archive if root_dir is not a directory, and, in
that case, raise FileNotFoundError or NotADirectoryError regardless
of format choice. Beyond the brought-back behavior, the function may
now also raise these exceptions in dry_run mode.
(cherry picked from commit a86df298df)

Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
2023-08-16 07:44:21 +00:00
Steve Dower ccf81e1088
[3.11] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107982)
Co-authored-by: Finn Womack <flan313@gmail.com>
2023-08-15 19:07:52 +02:00
Miss Islington (bot) db4400b5b2
[3.11] gh-107963: Fix set_forkserver_preload to check the type of given list (GH-107965) (gh-107976)
gh-107963: Fix set_forkserver_preload to check the type of given list (GH-107965)
(cherry picked from commit 6515ec3d3d)


gh-107963: Fix set_forkserver_preload to check the type of given list

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2023-08-15 23:53:25 +09:00
Serhiy Storchaka ec254c5dfa
[3.11] gh-106844: Fix issues in _winapi.LCMapStringEx (GH-107832) (GH-107875)
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError,
   it doesn't matter how much memory is available.
* Strings with length exactly 2**32-1 caused OSError.
* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.

Now strings longer than 2**31-1 characters caused OverflowError.
(cherry picked from commit 04cc01453d)
2023-08-12 14:06:56 +03:00
Serhiy Storchaka 5b76eaf02e
[3.11] gh-106052: Fix bug in the matching of possessive quantifiers (GH-106515) (GH-107795)
It did not work in the case of a subpattern containing backtracking.

Temporary implement possessive quantifiers as equivalent greedy qualifiers
in atomic groups.
(cherry picked from commit 7b6e34e5ba)
2023-08-09 06:15:27 +00:00
Serhiy Storchaka 22b39d13ec
[3.11] gh-107735: Add C API tests for PySys_GetObject() and PySys_SetObject() (GH-107736) (GH-107741)
(cherry picked from commit bea5f93196)
2023-08-07 20:51:00 +00:00
Serhiy Storchaka 81c8f7d619
[3.11] gh-104496: Use correct Tcl or Tk version in Tkinter tests (GH-107688) (GH-107719)
In future Tcl and Tk versions can be desynchronized.
(cherry picked from commit 3c8e8f3cee)
2023-08-07 14:48:43 +00:00
Charlie Zhao a15d06c230
[3.11] gh-106263: Fix segfault in `signaldict_repr` in `_decimal` module (#… (#107490)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
(cherry picked from commit 3979150a0d)
2023-07-31 15:52:23 +02:00
Miss Islington (bot) 81d0c7ca5a
[3.11] gh-106368: Add test for Argument Clinic misbehaving custom converter_init() (GH-107496) (#107500)
(cherry picked from commit 2c5d206b33)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-31 12:32:18 +00:00
Łukasz Langa 3abcdc71b6
[3.11] gh-104280: Add test cases for DTrace probes (GH-107125) (#107492)
(cherry picked from commit a1c737b73d)

Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
2023-07-31 11:40:20 +02:00
Miss Islington (bot) 51b302e3f3
[3.11] gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail (GH-107364) (#107366)
gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail (GH-107364)
(cherry picked from commit 76c26eaca4)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-28 00:36:34 +00:00
Erlend E. Aasland 9edeeb2014
[3.11] gh-106368: Increase Argument Clinic CLI test coverage (#107277) (#107326)
(cherry picked from commit 579100f6d7)
2023-07-26 23:02:24 +00:00
Miss Islington (bot) cebe60bb1a
[3.11] gh-106368: Increase Argument Clinic CLI test coverage (GH-107156) (#107190)
Instead of hacking into the Clinic class, use the Argument Clinic tool
to run the ClinicExternalTest test suite.

(cherry picked from commit 83a2837b32)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-26 22:24:09 +00:00
Miss Islington (bot) 41756e3960
[3.11] gh-62519: Make pgettext search plurals when translation is not found (GH-107118) (GH-107133)
(cherry picked from commit b3c34e55c0)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-07-25 21:49:28 +03:00
Victor Stinner db03cb953a
[3.11] gh-107237: Fix test_udp_reconnection() of test_logging (#107238) (#107245)
gh-107237: Fix test_udp_reconnection() of test_logging (#107238)

test_logging: Fix test_udp_reconnection() by increasing the timeout
from 100 ms to 5 minutes (LONG_TIMEOUT).

Replace also blocking wait() with wait(LONG_TIMEOUT) in
test_output() to prevent the test to hang.

(cherry picked from commit ed08238327)
2023-07-25 14:49:32 +00:00
Serhiy Storchaka b8b3e6afc0
[3.11] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224)
Previously *consumed was not set in this case.
(cherry picked from commit f08e52ccb0)
2023-07-25 14:15:14 +03:00
Miss Islington (bot) afa24d52b8
[3.11] gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only (GH-107016) (#107112)
(cherry picked from commit c65592c4d6)

Co-authored-by: htsedebenham <31847376+htsedebenham@users.noreply.github.com>
2023-07-23 14:28:35 +02:00
Erlend E. Aasland 63c945a3f5
[3.11] gh-106970: Fix Argument Clinic 'destination <name> clear' command (#106972) (#107059)
Add test for the 'destination <name> clear' command,
and the 'destination' directive in general.

Fix two bugs in 'destination <name> clear' command:

1. The text attribute of the allocator is called 'text', not '_text'
2. Return after processing the 'clear' command,
   instead of proceeding directly to the fail().

(cherry picked from commit 3372bcba98)
2023-07-22 17:44:11 +00:00
Łukasz Langa 06f8a43995
[3.11] gh-106368: Increase coverage for Argument Clinic output directive (GH-106979) (#107002)
(cherry picked from commit ee5c01b473)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-22 14:15:18 +02:00
Miss Islington (bot) 951b08c500
[3.11] gh-106368: Increase Argument Clinic test coverage for IndentStack (GH-106933) (#106944)
(cherry picked from commit 8d228cf66f)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-21 06:31:00 +00:00
Miss Islington (bot) a7acc5cb5c
[3.11] gh-106368: Increase Argument Clinic test coverage for cpp.Monitor (GH-106833) (#106839)
(cherry picked from commit 22379c60ab)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-17 21:22:43 +00:00
Jason R. Coombs 465f5b09df
[3.11] gh-106752: Sync with zipp 3.16.2 (GH-106757) (#106778)
* gh-106752: Sync with zipp 3.16.2 (#106757)

* gh-106752: Sync with zipp 3.16.2

* Add blurb

(cherry picked from commit 22980dc7c9)

* [3.11] gh-106752: Sync with zipp 3.16.2 (GH-106757)

* gh-106752: Sync with zipp 3.16.2

* Add blurb.
(cherry picked from commit 22980dc7c9)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Remove Python 3.12 concerns from changelog.
2023-07-15 10:15:38 -04:00
Miss Islington (bot) b132b77fb1
[3.11] gh-106368: Increase Argument Clinic BlockParser test coverage (GH-106759) (#106770)
(cherry picked from commit 2d7d1aa4bc)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-15 09:48:01 +00:00
Dennis Sweeney d488970ae6
[3.11] gh-105235: Prevent reading outside buffer during mmap.find() (… (#106710)
[3.11] gh-105235: Prevent reading outside buffer during mmap.find() (GH-105252)

* Add a special case for s[-m:] == p in _PyBytes_Find

* Add tests for _PyBytes_Find

* Make sure that start <= end in mmap.find.
(cherry picked from commit ab86426a34)
2023-07-14 22:17:09 -04:00
Erlend E. Aasland d22224a401
[3.11] gh-106368: Increase Argument Clinic test coverage (#106728) (#106731)
- improve output_parameter() coverage
- improve coverage for Function.kind

(cherry picked from commit ec45c513d3)

Co-authored-by: Erlend E. Aasland <erlend@python.org>

* Fix merge
2023-07-14 01:13:43 +02:00
Miss Islington (bot) a276ce4505
[3.11] gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106694)
gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106666)
(cherry picked from commit 357e9e9da3)

Co-authored-by: Prince Roshan <princekrroshan01@gmail.com>
2023-07-12 15:48:16 -07:00
Miss Islington (bot) 3e61e20043
[3.11] gh-102541: Add test case for help() for non_existent_module (GH-106340) (#106640)
gh-102541: Add test case for help() for non_existent_module (GH-106340)

Test fix for when one enters, for instance, 'abd' at the 'help>' prompt.
---------

(cherry picked from commit 292ac4bfe9)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-07-11 18:28:28 +00:00
Miss Islington (bot) da15b12d8d
[3.11] gh-106498: Revert incorrect colorsys.rgb_to_hls change (GH-106627) (#106633)
gh-106498: Revert incorrect colorsys.rgb_to_hls change (GH-106627)

gh-86618 assumed a-b-c = a-(b+c) = a-d where d = b+d.
For floats 2.0, 1.0, and 0.9999999999999999, this assumption
is false.  The net change of 1.1102230246251565e-16 to 0.0
results in division by 0.  Revert the replacement.  Add test.
(cherry picked from commit a2d54d4e8a)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-07-11 15:48:00 +00:00
Miss Islington (bot) 318f6ae1cd
[3.11] gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (GH-106468) (#106621)
gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (GH-106468)

For example:

    class Flag(enum.Flag):
        A = 0x01
        B = 0x02
        MASK = 0xff

    ~Flag.MASK is Flag(0)
(cherry picked from commit 95b7426f45)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2023-07-11 14:10:02 +02:00
Miss Islington (bot) d63953d0f5
[3.11] gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784) (#106607)
gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784)

Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe.  See GH-94777 for more details.
(cherry picked from commit 6782fc0502)

Co-authored-by: Louis Paulot <55740424+lpaulot@users.noreply.github.com>
2023-07-10 16:21:04 -06:00
Terry Jan Reedy 563829df55
[3.11] gh-103186: Fix or catch 'extra' stderr output from unittests (#103196) (#106606)
Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
(cherry picked from commit 9d582250d8)
2023-07-10 21:13:26 +00:00
Miss Islington (bot) 769b7d2d0b
[3.11] Move implementation specific RE tests to separate class (GH-106563) (GH-106565)
(cherry picked from commit 8cb6f9761e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-07-09 15:23:27 +03:00
Miss Islington (bot) 2d037fb406
[3.11] gh-106510: Fix DEBUG output for atomic group (GH-106511) (GH-106549)
(cherry picked from commit 74ec02e949)
2023-07-08 15:15:22 +03:00
Serhiy Storchaka 6cd08a566f
[3.11] gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302). (GH-106545)
(cherry picked from commit 6e6a4cd523)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-08 08:22:33 +00:00
Miss Islington (bot) 1931c2a438
[3.11] gh-90876: Restore the ability to import multiprocessing when `sys.executable` is `None` (GH-106464) (#106495)
gh-90876: Restore the ability to import multiprocessing when `sys.executable` is `None` (GH-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.
(cherry picked from commit c60df361ce)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-07-06 16:25:20 -07:00
Miss Islington (bot) 3f244b2f6e
[3.11] gh-105497: [Enum] Fix Flag inversion when alias/mask members exist. (GH-105542) (#105571)
When inverting a Flag member (or boundary STRICT), only consider other canonical flags; when inverting an IntFlag member (or boundary KEEP), also consider aliases.
(cherry picked from commit 59f009e589)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2023-07-05 13:59:18 +02:00
Miss Islington (bot) 33fb89552b
[3.11] gh-89392: Make test_decimal discoverable (GH-106209) (#106229)
(cherry picked from commit 0e24499129)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-07-05 13:00:56 +02:00
Miss Islington (bot) edb29f0fbe
[3.11] gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (GH-106443) (#106445)
gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (GH-106443)
(cherry picked from commit a941bd6c53)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-05 09:03:25 +00:00
Miss Islington (bot) 9f8aa7a6d7
[3.11] gh-106368: Add tests for permutation helpers in Argument Clinic (GH-106407) (#106410)
Added new test class PermutationTests()
(cherry picked from commit 8f6df5e9cb)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-04 14:17:26 +02:00
Miss Islington (bot) 3cc5c4a073
[3.11] gh-106368: Increase Argument Clinic test coverage (GH-106389) (#106391)
Add:

- test_disallowed_gropuing__no_matching_bracket
- test_double_slash
(cherry picked from commit 3406f8cce5)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-04 00:22:32 +00:00
Miss Islington (bot) 76889641e6
[3.11] gh-106368: Harden Argument Clinic parser tests (GH-106384) (#106388)
(cherry picked from commit 648688c137)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-07-03 23:35:42 +00:00
Erlend E. Aasland 3fdda976db
[3.11] gh-106368: Clean up Argument Clinic tests (#106373) (#106381)
(cherry picked from commit 3ee8dac7a1)
2023-07-03 22:33:45 +00:00
Erlend E. Aasland 52d5049cfd
[3.11] gh-106368: Increase Argument Clinic test coverage (#106369) (#106374)
Add tests for 'self' and 'defining_class' converter requirements.
(cherry picked from commit 7f4c8121db)
2023-07-03 22:07:05 +00:00
Miss Islington (bot) 9e33586018
[3.11] gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934) (#106323)
gh-102541: Fix Helper.help("mod") for non-existent mod (GH-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.
---------

(cherry picked from commit 0530f4f646)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-07-01 23:15:44 +00:00
Victor Stinner d5418e97fc
[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)
gh-101634: regrtest reports decoding error as failed test (#106169)

When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.

(cherry picked from commit 2ac3eec103)
2023-06-28 02:58:34 +00:00
Kumar Aditya 307c59a0c1
[3.11] gh-105979: Fix exception handling in unmarshal_frozen_code (`Python/import.c`) (GH-105980). (#106100)
* [3.11] gh-105979: Fix exception handling in `unmarshal_frozen_code` (`Python/import.c`) (GH-105980).
(cherry picked from commit cd5280367a)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-06-26 09:00:51 +00:00
Miss Islington (bot) 2944a6cc0a
[3.11] GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105864)
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
(cherry picked from commit 2beab5bdef)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2023-06-16 18:30:22 +00:00
Alex Waygood e590338893
[3.11] gh-105834: Backport new tests for `typing.Protocol` (#105835) (#105860) 2023-06-16 16:39:12 +00:00
Miss Islington (bot) c0c4186858
[3.11] GH-105588: Add missing error checks to some obj2ast_* converters (GH-105839)
GH-105588: Add missing error checks to some obj2ast_* converters (GH-105589)
(cherry picked from commit a4056c8f9c)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2023-06-15 23:13:51 +00:00
Miss Islington (bot) c2e51a9985
[3.11] gh-105436: Ignore unrelated errors when checking empty env (GH-105742) (#105757)
gh-105436: Ignore unrelated errors when checking empty env (GH-105742)
(cherry picked from commit 4cefe3cf10)

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-06-13 23:39:56 +00:00
Miss Islington (bot) 261d0b4f0e
[3.11] gh-105436: The environment block should end with two null wchar_t values (GH-105495) (#105701)
gh-105436: The environment block should end with two null wchar_t values (GH-105495)
(cherry picked from commit 4f7d3b602d)

Co-authored-by: Dora203 <66343334+sku2000@users.noreply.github.com>
2023-06-12 16:49:57 +00:00
Miss Islington (bot) 6dcbd50eb8
[3.11] gh-105557: Remove duplicate sqlite3 test method (GH-105558) (#105562)
test_func_return_too_large_int() was defined twice.
Keep only the redefined method, as that also checks the tracebacks.
(cherry picked from commit b8fa7bda4f)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 14:02:15 +00:00
Miss Islington (bot) fed1b5a198
[3.11] gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348) (GH-105519)
* revert enum pickling from by-name to by-value

(cherry picked from commit 4ff5690e59)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2023-06-08 18:02:12 -07:00
Miss Islington (bot) b073b30cae
[3.11] test_types: Replace raw assert statements (GH-105500) (#105508)
(cherry picked from commit a8eb7372ee)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-06-08 15:33:40 +00:00
Alex Waygood 18e9fd80d9
[3.11] gh-103171: Revert undocumented behaviour change for runtime-checkable protocols decorated with `@final` (#105445) 2023-06-07 21:18:21 +00:00
Miss Islington (bot) daf22ca7f9
[3.11] gh-104411: Update test_getint for Tcl 9.0 (GH-104412) (#105357)
gh-104411: Update test_getint for Tcl 9.0 (GH-104412)
(cherry picked from commit 2c49c759e8)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
2023-06-06 10:04:21 -04:00
Jelle Zijlstra 48957888d2
[3.11] gh-105164: Detect annotations inside match blocks (GH-105177). (#105314)
(cherry picked from commit 69d1245685)
2023-06-05 13:46:12 +00:00
Tian Gao aca77b5530
[3.11] gh-105080: Fixed inconsistent signature on derived classes (GH… (#105274) 2023-06-04 15:26:01 -06:00
Miss Islington (bot) ca5524745d
[3.11] Remove raw asserts in test_typing.py (GH-104951) (#104979)
Remove raw asserts in test_typing.py (GH-104951)
(cherry picked from commit 2cb445635e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-26 14:34:37 +00:00
Miss Islington (bot) 76873ca6b1
[3.11] Fix test_importlib.test_side_effect_import() (GH-104840) (#104843)
Fix test_importlib.test_side_effect_import() (GH-104840)

Wait until the thread spawn by the import completes to avoid dangling
threads. With this fix, the following command no longer fails:

./python -m test --fail-env-changed test_importlib -m test_side_effect_import -F -j20
(cherry picked from commit 426950993f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-25 02:35:34 +02:00
Miss Islington (bot) 5e911673e4
[3.11] Improve test coverage for is_typeddict (GH-104884) (#104888)
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607a8e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-24 19:23:35 +00:00
Miss Islington (bot) 582aadc80e
[3.11] gh-104271: Fix auto() fallback in case of mixed type Enum (GH-104809)
[3.12] gh-104271: Fix auto() fallback in case of mixed type Enum (GH-104279)
(cherry picked from commit f4e2049f14)

Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
2023-05-23 12:48:20 -07:00
Alex Waygood d691de1d2d
[3.11] gh-104683: `clinic.py`: Improve coverage for the `parse_converter` method (#104729) (#104730) 2023-05-21 23:48:25 +00:00
Prince Roshan 2ade563abc
[3.11] gh-103606: Improve error message from logging.config.FileConfig (GH-103628) (#104687)
* gh-103606: Improve error message from logging.config.FileConfig (GH-103628)

(cherry picked from commit 152227b569)

plus backport the followup exception change fix to that in #104701
2023-05-21 12:17:18 -07:00
Miss Islington (bot) 795b20e2f1
[3.11] gh-56276: Add tests to test_compare (GH-3199) (#104694)
gh-56276: Add tests to test_compare (GH-3199)
(cherry picked from commit 68ee8b3f15)

Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-20 16:31:42 +00:00
Miss Islington (bot) dbb011afae
[3.11] gh-103987: fix several crashes in mmap module (GH-103990) (#104677)
gh-103987: fix several crashes in mmap module (GH-103990)
(cherry picked from commit ceaa4c3476)

Co-authored-by: Prince Roshan <princekrroshan01@gmail.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-20 03:59:54 +00:00
Miss Islington (bot) 2801b3f8f7
[3.11] gh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (GH-104667) (#104673)
gh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (GH-104667)

Skip test_subprocess.ProcessTestCase.test_empty_env if ASAN is enabled.
(cherry picked from commit c3f43bfb4b)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-05-19 21:48:07 +00:00
Mark Shannon 7b3bc95067
[3.11] GH-102818: Do not call PyTraceBack_Here in sys.settrace trampoline (GH-104650)
Backport of GH-104579
2023-05-19 19:08:43 +01:00
Carl Meyer 667e4ece98
[3.11] gh-104615: don't make unsafe swaps in apply_static_swaps (GH-104620). (#104636)
(cherry picked from commit 0589c6a4d3)
2023-05-19 12:04:04 -06:00
Łukasz Langa 702ce87736
[3.11] gh-96522: Fix deadlock in pty.spawn (GH-96639) (#104655)
(cherry picked from commit 9c5aa8967b)

Co-authored-by: Youfu Zhang <1315097+zhangyoufu@users.noreply.github.com>
2023-05-19 16:54:50 +02:00
Miss Islington (bot) aaeaf01cc2
[3.11] gh-85984: Utilize new "winsize" functions from termios in pty tests. (GH-101831) (#104652)
Utilize new functions termios.tcgetwinsize() and termios.tcsetwinsize in test_pty.py.

(cherry picked from commit da2fb92643)

Co-authored-by: Soumendra Ganguly <67527439+8vasu@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-19 15:57:52 +02:00
Miss Islington (bot) 3d52f7e60c
[3.11] gh-104629: Don't skip test_clinic if _testclinic is missing (GH-104630) (#104632)
gh-104629: Don't skip test_clinic if _testclinic is missing (GH-104630)

Just skip the tests that depend on the _testclinic extension module;
we can still run the Python tests.
(cherry picked from commit 86ee49f469)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-18 23:20:35 +00:00
Miss Islington (bot) 610cc0ab1b
[3.11] gh-102153: Start stripping C0 control and space chars in `urlsplit` (GH-102508) (#104575)
* gh-102153: Start stripping C0 control and space chars in `urlsplit` (GH-102508)

`urllib.parse.urlsplit` has already been respecting the WHATWG spec a bit GH-25595.

This adds more sanitizing to respect the "Remove any leading C0 control or space from input" [rule](https://url.spec.whatwg.org/GH-url-parsing:~:text=Remove%20any%20leading%20and%20trailing%20C0%20control%20or%20space%20from%20input.) in response to [CVE-2023-24329](https://nvd.nist.gov/vuln/detail/CVE-2023-24329).

---------

(cherry picked from commit 2f630e1ce1)

Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-17 21:41:25 +00:00
Jelle Zijlstra f106aef24a
[3.11] typing: Add more tests for TypeVar (GH-104571) (#104577)
During the PEP 695 implementation at one point I made
TypeVar.__name__ return garbage, and all of test_typing passed.
So I decided to add a few more tests.
(cherry picked from commit 26931944dd)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-17 13:40:34 +00:00
Gregory P. Smith 133bf0927e
[3.11] gh-103861: Fix Zip64 extensions not being properly applied in some cases (GH-103863) (#104534)
Fix Zip64 extensions not being properly applied in some cases:

Fixes an issue where adding a small file to a `ZipFile`
object while forcing zip64 extensions causes an extra Zip64 record to be
added to the zip, but doesn't update the `min_version` or file sizes in
the primary central directory header.

Also fixed an edge case in checking if zip64 extensions are required:

This fixes an issue where if data requiring zip64 extensions was added
to an unseekable stream without specifying `force_zip64=True`, zip64
extensions would not be used and a RuntimeError would not be raised when
closing the file (even though the size would be known at that point).
This would result in successfully writing corrupt zip files.

Deciding if zip64 extensions are required outside of the `FileHeader`
function means that both `FileHeader` and `_ZipWriteFile` will always be
in sync. Previously, the `FileHeader` function could enable zip64
extensions without propagating that decision to the `_ZipWriteFile`
class, which would then not correctly write the data descriptor record
or check for errors on close.

If anyone is actually using `ZipInfo.FileHeader` as a public API without
explicitly passing True or False in for zip64, their own code may still be
susceptible to that kind of bug unless they make a similar change to
where the zip64 decision happens.

Fixes GH-103861

---------

.
(cherry picked from commit 798bcaa1eb)

Co-authored-by: Carey Metcalfe <carey@cmetcalfe.ca>
2023-05-17 01:07:10 -07:00
Miss Islington (bot) f748fc9f44
[3.11] gh-75367: Fix data descriptor detection in inspect.getattr_static (GH-104517) (#104557)
gh-75367: Fix data descriptor detection in inspect.getattr_static (GH-104517)
(cherry picked from commit 5e9f471e7d)

Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-16 17:57:34 +00:00
Irit Katriel 52a18feaaa
[3.11] gh-104482: Fix error handling bugs in ast.c (#104514) 2023-05-16 10:14:36 +01:00
Miss Islington (bot) 03f0d75f1d
[3.11] GH-71383: IDLE - Document testing subsets of modules (GH-104463) (#104464)
GH-71383: IDLE - Document testing subsets of modules (GH-104463)
(cherry picked from commit 080a596152)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-05-14 04:18:30 +00:00
Brandt Bucher fbb6def08a
[3.11] GH-104405: Add missing PEP 523 checks (GH-104441) 2023-05-12 23:03:47 +00:00
Miss Islington (bot) b4c1ca29cc
[3.11] gh-103204: `http.server` - Enforce that HTTP version numbers must consist only of digits (GH-103205) (#104438)
gh-103204: `http.server` - Enforce that HTTP version numbers must consist only of digits (GH-103205)

Reject HTTP requests with invalid http/x.y version numbers: x or y being non-digits or too-long.

---------

(cherry picked from commit cf720acfcb)

Co-authored-by: Ben Kallus <49924171+kenballus@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-12 20:54:12 +00:00
Miss Islington (bot) 846a23d0b8
[3.11] GH-87695: Fix OSError from `pathlib.Path.glob()` (GH-104292) (GH-104362)
Fix issue where `pathlib.Path.glob()` raised `OSError` when it encountered
a symlink to an overly long path.
(cherry picked from commit a33ce66dca)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-05-10 23:19:49 +00:00
Miss Islington (bot) 1cbf844875
[3.11] gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226) (#104345)
gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226)
(cherry picked from commit 22f3425c3d)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-05-10 07:53:19 -07:00
Miss Islington (bot) b2171a2fd4
[3.11] gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (GH-103849) (#104349)
gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (GH-103849)

* Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format

---------

(cherry picked from commit 29f348e232)

Co-authored-by: JohnJamesUtley <81572567+JohnJamesUtley@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-10 06:35:24 +00:00
Miss Islington (bot) 4ed59b1f33
[3.11] gh-99889: Fix directory traversal security flaw in uu.decode() (GH-104096) (#104329)
gh-99889: Fix directory traversal security flaw in uu.decode() (GH-104096)

* Fix directory traversal security flaw in uu.decode()
* also check absolute paths and os.altsep
* Add a regression test.

---------

(cherry picked from commit 0aeda29793)


 [Google]

Co-authored-by: Sam Carroll <70000253+samcarroll42@users.noreply.github.com>
2023-05-09 09:46:25 -07:00
Miss Islington (bot) d54f6441ce
[3.11] gh-103193: Improve `getattr_static` test coverage (GH-104286) (#104290)
gh-103193: Improve `getattr_static` test coverage (GH-104286)
(cherry picked from commit 921185ed05)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-08 14:44:10 +00:00
Miss Islington (bot) 065e2ae99a
[3.11] gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (GH-104266) (#104278)
gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (GH-104266)
(cherry picked from commit 06c2a4858b)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-05-08 17:34:43 +05:30
Erlend E. Aasland 681d5028bd
[3.11] gh-100370: fix OverflowError in sqlite3.Connection.blobopen for 32-bit builds (#103902) (#104285) 2023-05-08 08:41:34 +00:00
Tian Gao 19abf691fe
[3.11] gh-103225: Fixed zero lineno issue for pdb (#103265) (#104262)
gh-103225: Fixed zero lineno issue for pdb (#103265)

Co-authored-by: Artem Mukhin <ortem00@gmail.com>
2023-05-07 12:21:57 +01:00
Lysandros Nikolaou a09d3901a5
[3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195) 2023-05-07 11:12:04 +01:00
Miss Islington (bot) c5dafeaa6d
[3.11] Re-enable commented-out test in test_generators.py (GH-104130) (#104261)
Re-enable commented-out test in test_generators.py (GH-104130)
(cherry picked from commit 472938316a)

Co-authored-by: ymki4360 <132453923+ymki4360@users.noreply.github.com>
2023-05-07 05:11:00 +00:00
Miss Islington (bot) cf1c25fd6e
[3.11] gh-101640: Make argparse _print_message catch any write error (GH-101802) (#104250)
gh-101640: Make argparse _print_message catch any write error (GH-101802)

* In particular, don't exit when trying to print to stderr = None.
* Add tests

(cherry picked from commit 42f54d1f92)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-05-06 23:17:27 +00:00
Miss Islington (bot) 4536b2ec18
[3.11] gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067) (#104123)
gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067)

Do not expose the local server's on-disk location from `SimpleHTTPRequestHandler` when generating a directory index. (unnecessary information disclosure)

---------

(cherry picked from commit c7c3a60c88)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-03 04:27:04 +00:00
Irit Katriel 5386730cdd
[3.11] gh-103590: do not wrap a single exception raised from a try-except* (#104094) 2023-05-02 19:24:02 +01:00
Miss Islington (bot) 0d40264325
[3.11] GH-103472: close response in HTTPConnection._tunnel (GH-103473) (#104077)
GH-103472: close response in HTTPConnection._tunnel (GH-103473)

Avoid a potential `ResourceWarning` in `http.client.HTTPConnection`
by closing the proxy / tunnel's CONNECT response explicitly.

---------

(cherry picked from commit 9de0cf20fa)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-01 23:48:07 -07:00
Miss Islington (bot) 10db28bfcf
[3.11] gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033) (#104058)
gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033)

PEP-0682 specified that %-formatting would not support the "z" specifier,
but it was unintentionally allowed for bytes. This PR makes use of the "z"
flag an error for %-formatting in a bytestring.

Issue: GH-104018

---------

(cherry picked from commit 3ed8c88290)

Co-authored-by: John Belmonte <john@neggie.net>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-05-01 20:18:29 +00:00
Miss Islington (bot) 0df7c3a466
[3.11] gh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (GH-104041) (#104044)
gh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (GH-104041)
(cherry picked from commit 99aab61062)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-05-01 10:02:41 -06:00
Miss Islington (bot) 1be8bed236
[3.11] gh-104036: Fix direct invocation of test_typing (GH-104037) (#104039)
gh-104036: Fix direct invocation of test_typing (GH-104037)

Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not.
(cherry picked from commit 4181d078fc)

Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
2023-05-01 14:17:12 +00:00
Miss Islington (bot) 2be3656855
[3.11] Improve int test coverage (GH-104024) (#104026)
Improve int test coverage (GH-104024)

Following discussion in https://discuss.python.org/t/bug-in-int-42/26360/5

This tests some of the things documented in https://github.com/python/cpython/pull/100436

(cherry picked from commit 69bc86cb1a)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-01 00:50:01 +00:00
Tian Gao fee3c91a19
[3.11] GH-103971: Fix incorrect locations for code following case blocks 2023-04-28 20:08:25 +00:00
Petr Viktorin 241f2e54a6
[3.11] gh-102950: Implement PEP 706 – Filter for tarfile.extractall (GH-102953) (GH-103832)
See [Backporting & Forward Compatibility in PEP 706](https://peps.python.org/pep-0706/#backporting-forward-compatibility).

- Backport b52ad18a76
- Backport c8c3956d90
- Remove the DeprecationWarning
- Adjust docs
- Remove new `__all__` entries
2023-04-28 17:41:09 +02:00
Nikita Sobolev 7f70f1c5cc
[3.11] gh-103880: Fix `assertRaises` usage in `test_genericalias` (GH-103916) (#103917)
(cherry picked from commit dff8e5dc8d)
2023-04-27 16:03:29 +05:30
Miss Islington (bot) 2cd1b9c2ca
[3.11] gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425) (#103918)
gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425)
(cherry picked from commit 78942ecd9b)

Co-authored-by: Itayazolay <itayazolay@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-27 10:29:54 +00:00
Miss Islington (bot) f11ba1c2de
[3.11] gh-103578: Fix pdb reading code with non-utf8 encoding (GH-103581) (#103867)
`pdb` should use `io.open_code` to open code to avoid encoding issue.
(cherry picked from commit 31acfd78a0)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-04-26 05:28:29 +00:00
Irit Katriel 93a9535d54
[3.11] gh-101517: fix line number propagation in code generated for except* (#103550) (#103816)
Manual backport of https://github.com/python/cpython/pull/103550.



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

---------

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-25 18:08:54 +01:00
Miss Islington (bot) c8de883bcb
[3.11] gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (GH-99244) (#103789)
gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (GH-99244)
(cherry picked from commit 58b6be3791)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-24 19:58:55 +00:00
Miss Islington (bot) a8489f7f26
[3.11] Revert "Add tests for empty range equality (GH-103751)" (GH-103770) (#103781)
Revert "Add tests for empty range equality (GH-103751)" (GH-103770)

This reverts commit dca27a69a8.
Added tests are redundant with existing tests.
(cherry picked from commit ab25c7e311)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-04-24 18:54:21 +00:00
Miss Islington (bot) e0e1bee833
[3.11] gh-103746: Test `types.UnionType` and `Literal` types together (GH-103747) (#103772)
gh-103746: Test `types.UnionType` and `Literal` types together (GH-103747)
(cherry picked from commit 3d29edaf0a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-24 17:22:36 +00:00
Miss Islington (bot) 25406e5a35
[3.11] Add tests for empty range equality (GH-103751) (#103760)
(cherry picked from commit dca27a69a8)

Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com>
2023-04-24 11:09:46 -04:00
Miss Islington (bot) 7b2ac6cf3d
[3.11] gh-102310: Change error range for invalid bytes literals (GH-103663) (#103703) 2023-04-23 17:21:27 -06:00
Miss Islington (bot) 4e9635e2b1
[3.11] gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal`s (GH-103706) (#103720)
gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal`s (GH-103706)
(cherry picked from commit 5041c2ba6e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-23 12:15:24 -06:00
Miss Islington (bot) ec29d0c091
[3.11] gh-103449: Fix a bug in dataclass docstring generation (GH-103454) (#103599) 2023-04-23 09:40:52 -06:00
Miss Islington (bot) 6e25228b2e
[3.11] gh-81403: Fix for CacheFTPHandler in urllib (GH-13951) (#103705)
* gh-81403: Fix for CacheFTPHandler in urllib (GH-13951)

bpo-37222: Fix for CacheFTPHandler in urllib

A call to FTP.ntransfercmd must be followed by FTP.voidresp to clear
the "end transfer" message. Without this, the client and server get
out of sync, which will result in an error if the FTP instance is
reused to open a second URL. This scenario occurs for even the most
basic usage of CacheFTPHandler.

Reverts the patch merged as a resolution to bpo-16270 and adds a test
case for the CacheFTPHandler in test_urllib2net.py.

(cherry picked from commit e38bebb9ee)

Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>

* Added NEWS entry.

---------

Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
2023-04-23 05:20:34 -07:00
Miss Islington (bot) b2fdae9d86
[3.11] gh-103556: [inspect.Signature] disallow pos-or-kw params without default after pos-only with default (GH-103557) (#103675) 2023-04-22 09:13:02 -06:00
Miss Islington (bot) 9f3f109dd2
gh-103553: Improve `test_inspect`: add more assertions, remove unused (GH-103554)
(cherry picked from commit 4fe1c4b97e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-15 14:15:45 -07:00