]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agogh-109266: Fix msvcrt.kbhit's documented return value (GH-109267)
AN Long [Tue, 12 Sep 2023 14:44:48 +0000 (22:44 +0800)] 
gh-109266: Fix msvcrt.kbhit's documented return value (GH-109267)

2 years agogh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314)
Nikita Sobolev [Tue, 12 Sep 2023 14:05:29 +0000 (17:05 +0300)] 
gh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314)

2 years agogh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497)
Nikita Sobolev [Tue, 12 Sep 2023 13:33:30 +0000 (16:33 +0300)] 
gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497)

2 years agogh-109276: libregrtest: fix worker working dir (#109313)
Victor Stinner [Tue, 12 Sep 2023 13:13:29 +0000 (15:13 +0200)] 
gh-109276: libregrtest: fix worker working dir (#109313)

Fix Emscripten and WASI: start the test worker process in the Python
source code directory, where 'python.js' and 'python.wasm' can be
found. Then worker_process() changes to a temporary directory created
to run tests.

* create_worker_process() uses os_helper.SAVEDCWD as cwd.
* worker_process() uses get_temp_dir() as the parent directory for
  get_work_dir().
* Don't use plural but singual for "test" in "Run 1 test ..."
  message.
* Remove unused imports.
* Add WORK_DIR_PREFIX and WORKER_WORK_DIR_PREFIX constants.

2 years agogh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)
Irit Katriel [Tue, 12 Sep 2023 10:36:17 +0000 (11:36 +0100)] 
gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)

2 years agogh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)
Nikita Sobolev [Tue, 12 Sep 2023 09:37:22 +0000 (12:37 +0300)] 
gh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)

2 years agogh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)
Nikita Sobolev [Tue, 12 Sep 2023 06:37:42 +0000 (09:37 +0300)] 
gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)

2 years agogh-109276: libregrtest: limit number workers (#109288)
Victor Stinner [Tue, 12 Sep 2023 03:47:04 +0000 (05:47 +0200)] 
gh-109276: libregrtest: limit number workers (#109288)

Don't spawn more threads than the number of jobs: these worker
threads would never get anything to do.

* Add the number of tests in "Run ... tests in ..." message.
* Add RunTests.get_jobs() method.
* Add plural() function.
* count() uses f-string.

2 years agogh-109276: libregrtest calls random.seed() before each test (#109279)
Victor Stinner [Tue, 12 Sep 2023 03:35:08 +0000 (05:35 +0200)] 
gh-109276: libregrtest calls random.seed() before each test (#109279)

libregrtest now calls random.seed() before running each test file
when -r/--randomize command line option is used. Moreover, it's also
called in worker processes. It should help to make tests more
deterministic. Previously, it was only called once in the main
process before running all test files and it was not called in worker
processes.

* Convert some f-strings to regular strings in test_regrtest when
  f-string is not needed.
* Remove unused all_methods variable from test_regrtest.
* Add RunTests members are now mandatory.

2 years agogh-109276: libregrtest only checks saved_test_environment() once (#109278)
Victor Stinner [Tue, 12 Sep 2023 03:01:33 +0000 (05:01 +0200)] 
gh-109276: libregrtest only checks saved_test_environment() once (#109278)

There is no need to check for environment changes twice.

2 years agogh-109276: Complete test.pythoninfo (#109312)
Victor Stinner [Tue, 12 Sep 2023 02:50:05 +0000 (04:50 +0200)] 
gh-109276: Complete test.pythoninfo (#109312)

* Enable collect_sysconfig() on Windows.
* Add sysconfig 'abs_builddir' and 'srcdir'
* Add sysconfig.is_python_build()
* Add tempfile.gettempdir()
* Remove compatiblity with Python 2.7 (print_function).

2 years agogh-109295: Skip test_generated_cases if different mount drives (#109308)
Victor Stinner [Tue, 12 Sep 2023 02:30:07 +0000 (04:30 +0200)] 
gh-109295: Skip test_generated_cases if different mount drives (#109308)

On Windows, skip the test if the current working directory and the
Python source code directory have different mount drives. It happens
if the temporary directory is on a different mount drive than the
Python source code.

2 years agoFix iter_index() to work with lists which do not support stop=None. (gh-109306)
Raymond Hettinger [Tue, 12 Sep 2023 02:04:28 +0000 (04:04 +0200)] 
Fix iter_index() to work with lists which do not support stop=None. (gh-109306)

2 years agogh-109295: Fix test_os.test_access_denied() for TEMP=cwd (#109299)
Victor Stinner [Tue, 12 Sep 2023 01:35:26 +0000 (03:35 +0200)] 
gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (#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.

2 years agogh-109295: Clean up multiprocessing in test_asyncio and test_compileall (#109298)
Victor Stinner [Tue, 12 Sep 2023 01:31:15 +0000 (03:31 +0200)] 
gh-109295: Clean up multiprocessing in test_asyncio and test_compileall (#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.

2 years agoGH-106734: Disable tab completion in pdb's multiline mode (GH-106735)
Tian Gao [Tue, 12 Sep 2023 01:28:43 +0000 (18:28 -0700)] 
GH-106734: Disable tab completion in pdb's multiline mode (GH-106735)

2 years agogh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)
Jelle Zijlstra [Tue, 12 Sep 2023 00:11:06 +0000 (17:11 -0700)] 
gh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)

Fixes #109118. Fixes #109194.

Co-authored-by: Carl Meyer <carl@oddbird.net>
2 years agogh-109292: add symtable impact of PEP 709 to What's New (#109293)
Carl Meyer [Tue, 12 Sep 2023 00:03:04 +0000 (18:03 -0600)] 
gh-109292: add symtable impact of PEP 709 to What's New (#109293)

2 years agogh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289)
Carl Meyer [Mon, 11 Sep 2023 23:35:49 +0000 (17:35 -0600)] 
gh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289)

2 years agogh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
Guido van Rossum [Mon, 11 Sep 2023 22:39:19 +0000 (15:39 -0700)] 
gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)

* Rename SAVE_IP to _SET_IP
* Rename EXIT_TRACE to _EXIT_TRACE
* Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP
* Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter)
* Rename IS_NONE to _IS_NONE
* Rename JUMP_TO_TOP to _JUMP_TO_TOP

2 years agogh-107322: zipapp: Remove the suggestion to remove .dist-info directories (#107296)
wim glenn [Mon, 11 Sep 2023 19:44:13 +0000 (14:44 -0500)] 
gh-107322: zipapp: Remove the suggestion to remove .dist-info directories (#107296)

Removed zipapp suggestion to rm .dist-info subdirectories. This totally breaks importlib.metadata

2 years agogh-109039: Branch prediction for Tier 2 interpreter (#109038)
Guido van Rossum [Mon, 11 Sep 2023 18:20:24 +0000 (11:20 -0700)] 
gh-109039: Branch prediction for Tier 2 interpreter (#109038)

This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction.

Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped.

Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch.

The counter is initialized to a pattern of alternating ones and zeros to avoid bias.

The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.

2 years agogh-109179: Fix traceback display for SyntaxErrors with notes (#109197)
Irit Katriel [Mon, 11 Sep 2023 18:18:34 +0000 (19:18 +0100)] 
gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)

2 years agogh-109276: libregrtest: use separated file for JSON (#109277)
Victor Stinner [Mon, 11 Sep 2023 17:33:42 +0000 (19:33 +0200)] 
gh-109276: libregrtest: use separated file for JSON (#109277)

libregrtest now uses a separated file descriptor to write test result
as JSON.  Previously, if a test wrote debug messages late around the
JSON, the main test process failed to parse JSON.

Rename TestResult.write_json() to TestResult.write_json_into().

worker_process() no longer writes an empty line at the end. There is
no need to separate test process output from the JSON output anymore,
since JSON is now written into a separated file descriptor.

create_worker_process() now always spawn the process with
close_fds=True.

2 years agogh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644)
Nikita Sobolev [Mon, 11 Sep 2023 16:13:37 +0000 (19:13 +0300)] 
gh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644)

2 years agogh-109190: What's New in 3.12: Add subheadings to removals for easy linking (#109159)
Hugo van Kemenade [Mon, 11 Sep 2023 16:06:16 +0000 (10:06 -0600)] 
gh-109190: What's New in 3.12: Add subheadings to removals for easy linking (#109159)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2 years agogh-108987: Fix _thread.start_new_thread() race condition (#109135)
Victor Stinner [Mon, 11 Sep 2023 15:27:03 +0000 (17:27 +0200)] 
gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

2 years agogh-109182: Fix and improve tests for gh-108654 (GH-109189)
Serhiy Storchaka [Mon, 11 Sep 2023 14:50:33 +0000 (17:50 +0300)] 
gh-109182: Fix and improve tests for gh-108654 (GH-109189)

2 years agoGH-108976. Keep monitoring data structures valid during de-optimization during callba...
Mark Shannon [Mon, 11 Sep 2023 13:37:09 +0000 (14:37 +0100)] 
GH-108976. Keep monitoring data structures valid during de-optimization during callback. (GH-109131)

2 years agoBetter integration of doctest and unittest in test_ctypes.test_objects (GH-108922)
Serhiy Storchaka [Mon, 11 Sep 2023 11:05:30 +0000 (14:05 +0300)] 
Better integration of doctest and unittest in test_ctypes.test_objects (GH-108922)

Better integration of docrtest and unittest in test_ctypes.test_objects

2 years agoTest DocTestFinder directly instead of calling support.run_doctest() (GH-108917)
Serhiy Storchaka [Mon, 11 Sep 2023 11:03:30 +0000 (14:03 +0300)] 
Test DocTestFinder directly instead of calling support.run_doctest() (GH-108917)

2 years agogh-109162: libregrtest: move code around (#109253)
Victor Stinner [Mon, 11 Sep 2023 08:52:03 +0000 (10:52 +0200)] 
gh-109162: libregrtest: move code around (#109253)

* Move Regrtest.display_header() to utils.py.
* Move cleanup_temp_dir() to utils.py.
* Move list_cases() to findtests.py.

2 years agogh-107219: Fix concurrent.futures terminate_broken() (#109244)
Victor Stinner [Mon, 11 Sep 2023 08:11:31 +0000 (10:11 +0200)] 
gh-107219: Fix concurrent.futures terminate_broken() (#109244)

Fix a race condition in concurrent.futures. When a process in the
process pool was terminated abruptly (while the future was running or
pending), close the connection write end. If the call queue is
blocked on sending bytes to a worker process, closing the connection
write end interrupts the send, so the queue can be closed.

Changes:

* _ExecutorManagerThread.terminate_broken() now closes
  call_queue._writer.
* multiprocessing PipeConnection.close() now interrupts
  WaitForMultipleObjects() in _send_bytes() by cancelling the
  overlapped operation.

2 years agoGH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247)
Victor Stinner [Mon, 11 Sep 2023 07:34:04 +0000 (09:34 +0200)] 
GH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247)

2 years agogh-109162: libregrtest: use relative imports (#109250)
Victor Stinner [Mon, 11 Sep 2023 07:02:35 +0000 (09:02 +0200)] 
gh-109162: libregrtest: use relative imports (#109250)

libregrtest.__init__ no longer exposes any symbol, so
"python -m test.libregrtest.worker" imports less modules.

2 years agogh-109162: libregrtest: rename runtest_mp.py to run_workers.py (#109248)
Victor Stinner [Mon, 11 Sep 2023 03:27:37 +0000 (05:27 +0200)] 
gh-109162: libregrtest: rename runtest_mp.py to run_workers.py (#109248)

* Rename runtest_mp.py to run_workers.py
* Move exit_timeout() and temp_cwd() context managers from
  Regrtest.main() to Regrtest.run_tests(). Actions like --list-tests
  or --list-cases don't need these protections.
* Regrtest: remove selected and tests attributes. Pass 'selected' to
  list_tests(), list_cases() and run_tests(). display_result() now
  expects a TestTuple, instead of TestList.
* Rename setup_tests() to setup_process() and rename setup_support()
  to setup_tests().
* Move _adjust_resource_limits() to utils and rename it to
  adjust_rlimit_nofile().
* Move replace_stdout() to utils.
* Fix RunTests.verbose type: it's an int.

2 years agogh-109162: libregrtest: fix Logger (#109246)
Victor Stinner [Mon, 11 Sep 2023 01:46:26 +0000 (03:46 +0200)] 
gh-109162: libregrtest: fix Logger (#109246)

* Pass results, quiet and pgo to Logger constructor.
* Move display_progress() method from Regrtest to Logger.
* No longer pass Regrtest to RunWorkers, but logger and results.

2 years agogh-109162: libregrtest: add single.py and result.py (#109243)
Victor Stinner [Mon, 11 Sep 2023 00:07:18 +0000 (02:07 +0200)] 
gh-109162: libregrtest: add single.py and result.py (#109243)

* Add single.py and result.py files.
* Rename runtest.py to runtests.py.
* Move run_single_test() function and its helper functions to
  single.py.
* Move remove_testfn(), abs_module_name() and normalize_test_name()
  to utils.py.
* Move setup_support() to setup.py.
* Move type hints like TestName to utils.py.
* Rename runtest.py to runtests.py.

2 years agogh-109162: libregrtest: add worker.py (#109229)
Victor Stinner [Sun, 10 Sep 2023 23:11:22 +0000 (01:11 +0200)] 
gh-109162: libregrtest: add worker.py (#109229)

Add new worker.py file:

* Move create_worker_process() and worker_process() to this file.
* Add main() function to worker.py. create_worker_process() now
  runs the command: "python -m test.libregrtest.worker JSON".
* create_worker_process() now starts the worker process in the
  current working directory. Regrtest now gets the absolute path of
  the reflog.txt filename: -R command line option filename.
* Remove --worker-json command line option.
  Remove test_regrtest.test_worker_json().

Related changes:

* Add write_json() and from_json() methods to TestResult.
* Rename select_temp_dir() to get_temp_dir() and move it to utils.
* Rename make_temp_dir() to get_work_dir() and move it to utils.
  It no longer calls os.makedirs(): Regrtest.main() now calls it.
* Move fix_umask() to utils. The function is now called by
  setup_tests().
* Move StrPath to utils.
* Add exit_timeout() context manager to utils.
* RunTests: Replace junit_filename (StrPath) with use_junit (bool).

2 years agogh-109230: test_pyexpat no longer depends on the current directory (#109233)
Victor Stinner [Sun, 10 Sep 2023 22:16:59 +0000 (00:16 +0200)] 
gh-109230: test_pyexpat no longer depends on the current directory (#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.

2 years agogh-109237: Fix test_site for non-ASCII working directory (#109238)
Victor Stinner [Sun, 10 Sep 2023 22:04:35 +0000 (00:04 +0200)] 
gh-109237: Fix test_site for non-ASCII working directory (#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.

2 years agogh-50644: Forbid pickling of codecs streams (GH-109180)
Serhiy Storchaka [Sun, 10 Sep 2023 17:06:09 +0000 (20:06 +0300)] 
gh-50644: Forbid pickling of codecs streams (GH-109180)

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.

2 years agogh-109054: Don't use libatomic on cross-compilation (#109211)
Victor Stinner [Sun, 10 Sep 2023 16:21:13 +0000 (18:21 +0200)] 
gh-109054: Don't use libatomic on cross-compilation (#109211)

configure no longer uses libatomic by default when Python is
cross-compiled. The LIBATOMIC variable can be set manually in this
case:

    ./configure LIBATOMIC="-latomic" (...)

2 years agogh-109207: Fix SystemError when printing symtable entry object. (GH-109225)
云line [Sun, 10 Sep 2023 12:04:24 +0000 (20:04 +0800)] 
gh-109207: Fix SystemError when printing symtable entry object. (GH-109225)

2 years agoFix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222)
Delgan [Sun, 10 Sep 2023 10:55:56 +0000 (12:55 +0200)] 
Fix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222)

2 years agogh-93627: Align Python implementation of pickle with C implementation of pickle ...
Pieter Eendebak [Sun, 10 Sep 2023 07:06:08 +0000 (09:06 +0200)] 
gh-93627: Align Python implementation of pickle with C implementation of pickle (GH-103035)

If a method like __reduce_ex_ or __reduce__ is set to None, a TypeError is raised.

2 years agogh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175)
Serhiy Storchaka [Sun, 10 Sep 2023 05:09:25 +0000 (08:09 +0300)] 
gh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175)

2 years agogh-109162: libregrtest: add Logger class (#109212)
Victor Stinner [Sun, 10 Sep 2023 03:04:26 +0000 (05:04 +0200)] 
gh-109162: libregrtest: add Logger class (#109212)

* Add Logger class in a new logger.py file.
* Move Regrtest attributes to Logger:

  * start_time
  * test_count_text
  * test_count_width
  * win_load_tracker

* Move Regrtest method to Logger:

  * log()
  * getloadavg(): rename to get_load_avg()
  * set_tests()

* Add methods to the Logger class:

  * start_load_tracker()
  * stop_load_tracker()

2 years agogh-109162: libregrtest: add TestResults class (#109208)
Victor Stinner [Sun, 10 Sep 2023 02:30:43 +0000 (04:30 +0200)] 
gh-109162: libregrtest: add TestResults class (#109208)

* Add TestResults class.
* Move Regrtest methods to TestResults:

  * accumulate_result(): now takes a RunTests parameter
  * get_executed()
  * no_tests_run()

* Add methods to TestResults:

  * add_junit()
  * display_result()
  * display_summary()
  * need_rerun()
  * prepare_rerun()
  * write_junit()

* Rename 'need_rerun' attribute to 'bad_results'.
* Rename 'total_stats' attribute to 'stats'.

2 years agogh-109162: Refactor libregrtest.Regrtest (#109206)
Victor Stinner [Sun, 10 Sep 2023 01:07:05 +0000 (03:07 +0200)] 
gh-109162: Refactor libregrtest.Regrtest (#109206)

* Add type hint types: TestName, StrPath, StrJSON.
* Add attributes to Regrtest:

  * cmdline_args
  * coverage
  * coverage_dir
  * fail_rerun
  * next_single_filename
  * print_slowest
  * tmp_dir
  * want_rerun
  * want_run_leaks

* Remove Regrtest.ns attribute.
* Rename Regrtest methods:

  * cleanup() => cleanup_temp_dir()
  * create_temp_dir() => make_temp_dir()
  * set_temp_dir() => select_temp_dir()

* Convert Regrtest methods to static methods:

  * cleanup_temp_dir()
  * display_header()
  * fix_umask()
  * get_rerun_match_tests()
  * list_tests()
  * make_temp_dir()
  * select_temp_dir()

* Remove display_sanitizers() method: move code into
  display_header().
* Rename 'test_cwd' variable to 'work_dir'.

2 years agogh-109162: Refactor libregrtest.runtest_mp (#109205)
Victor Stinner [Sun, 10 Sep 2023 00:24:38 +0000 (02:24 +0200)] 
gh-109162: Refactor libregrtest.runtest_mp (#109205)

* Add attributes to Regrtest and RunTests:

  * fail_env_changed
  * num_workers

* Rename MultiprocessTestRunner to RunWorkers. Add num_workers
  parameters to RunWorkers constructor. Remove RunWorkers.ns
  attribute.
* Rename TestWorkerProcess to WorkerThread.
* get_running() now returns a string like: "running (...): ...".
* Regrtest.action_run_tests() now selects the number of worker
  processes, instead of the command line parser.

2 years agogh-109162: libregrtest: remove WorkerJob class (#109204)
Victor Stinner [Sat, 9 Sep 2023 23:41:21 +0000 (01:41 +0200)] 
gh-109162: libregrtest: remove WorkerJob class (#109204)

* Add attributes to Regrtest and RunTests:

  * gc_threshold
  * memory_limit
  * python_cmd
  * use_resources

* Remove WorkerJob class. Add as_json() and from_json() methods to
  RunTests. A worker process now only uses RunTests for all
  parameters.
* Add tests on support.set_memlimit() in test_support. Create
  _parse_memlimit() and also adds tests on it.
* Remove 'ns' parameter from runtest.py.

2 years agogh-109162: libregrtest: fix _decode_worker_job() (#109202)
Victor Stinner [Sat, 9 Sep 2023 22:51:24 +0000 (00:51 +0200)] 
gh-109162: libregrtest: fix _decode_worker_job() (#109202)

Decode also HuntRefleak() object inside the RunTests object.

Add an unit test on huntrleaks with multiprocessing (-R -jN).

2 years agoImprove the sieve() recipe in the itertools docs (gh-109199)
Raymond Hettinger [Sat, 9 Sep 2023 22:50:04 +0000 (17:50 -0500)] 
Improve the sieve() recipe in the itertools docs (gh-109199)

Lazier sieve

2 years agoFix an ironic typo in a code comment. (gh-109186)
Raymond Hettinger [Sat, 9 Sep 2023 15:21:42 +0000 (10:21 -0500)] 
Fix an ironic typo in a code comment. (gh-109186)

2 years agogh-109162: Refactor libregrtest.RunTests (#109177)
Victor Stinner [Sat, 9 Sep 2023 09:18:14 +0000 (11:18 +0200)] 
gh-109162: Refactor libregrtest.RunTests (#109177)

* Rename dash_R() runtest_refleak(). The function now gets
  huntrleaks and quiet arguments, instead of 'ns' argument.
* Add attributes to Regrtest and RunTests:

  * verbose
  * quiet
  * huntrleaks
  * test_dir

* Add HuntRefleak class.

2 years agogh-109050: Remove remaining tests for legacy Unicode C API (GH-109068)
Serhiy Storchaka [Sat, 9 Sep 2023 05:44:46 +0000 (08:44 +0300)] 
gh-109050: Remove remaining tests for legacy Unicode C API (GH-109068)

2 years agogh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123)
Jelle Zijlstra [Sat, 9 Sep 2023 02:49:20 +0000 (19:49 -0700)] 
gh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123)

2 years agogh-109162: Refactor libregrtest.runtest (#109172)
Victor Stinner [Sat, 9 Sep 2023 01:37:48 +0000 (03:37 +0200)] 
gh-109162: Refactor libregrtest.runtest (#109172)

* Rename runtest() to run_single_test().
* Pass runtests to run_single_test().
* Add type annotation to Regrtest attributes. Add missing attributes
  to Namespace.
* Add attributes to Regrtest and RunTests:

  * fail_fast
  * ignore_tests
  * match_tests
  * output_on_failure
  * pgo
  * pgo_extended
  * timeout

* Get pgo from 'runtests', rather than from 'ns'.
* Remove WorkerJob.match_tests.
* setup_support() now gets pgo_extended from runtests.
* save_env(): change parameter order, pass test_name first.
* Add setup_test_dir() function.
* Pass runtests to setup_tests().

2 years agogh-109052: Use the base opcode when comparing code objects (gh-109107)
Tian Gao [Sat, 9 Sep 2023 01:24:49 +0000 (18:24 -0700)] 
gh-109052: Use the base opcode when comparing code objects (gh-109107)

2 years agogh-109162: Refactor libregrtest WorkerJob (#109171)
Victor Stinner [Sat, 9 Sep 2023 01:03:39 +0000 (03:03 +0200)] 
gh-109162: Refactor libregrtest WorkerJob (#109171)

* Rename --worker-args command line option to --worker-json.
* Rename _parse_worker_args() to _parse_worker_json().
* WorkerJob:

  * Add runtests attribute
  * Remove test_name and rerun attribute

* Rename run_test_in_subprocess() to create_worker_process().
* Rename run_tests_worker() to worker_process().
* create_worker_process() uses json.dump(): write directly JSON to
  stdout.
* Convert MultiprocessResult to a frozen dataclass.
* Rename RunTests.match_tests to RunTests.match_tests_dict.

2 years agogh-109162: Refactor Regrtest.action_run_tests() (#109170)
Victor Stinner [Sat, 9 Sep 2023 00:30:28 +0000 (02:30 +0200)] 
gh-109162: Refactor Regrtest.action_run_tests() (#109170)

Refator Regrtest class:

* Rename finalize() finalize_tests().
* Pass tracer to run_test() and finalize_tests(). Remove Regrtest.tracer.
* run_test() does less things: move code to its caller.

2 years agogh-108996: Skip broken test_msvcrt for now (#109169)
Victor Stinner [Fri, 8 Sep 2023 23:56:53 +0000 (01:56 +0200)] 
gh-108996: Skip broken test_msvcrt for now (#109169)

2 years agogh-109162: Regrtest copies 'ns' attributes (#109168)
Victor Stinner [Fri, 8 Sep 2023 23:48:54 +0000 (01:48 +0200)] 
gh-109162: Regrtest copies 'ns' attributes (#109168)

* Regrtest.__init__() now copies 'ns' namespace attributes to
  Regrtest attributes. Regrtest match_tests and ignore_tests
  attributes have type FilterTuple (tuple), instead of a list.
* Add RunTests.copy(). Regrtest._rerun_failed_tests() now uses
  RunTests.copy().
* Replace Regrtest.all_tests (list) with Regrtest.first_runtests
  (RunTests).
* Make random_seed maximum 10x larger (9 digits, instead of 8).

2 years agogh-109162: Refactor Regrtest.main() (#109163)
Victor Stinner [Fri, 8 Sep 2023 22:41:26 +0000 (00:41 +0200)] 
gh-109162: Refactor Regrtest.main() (#109163)

* main() now calls _parse_args() and pass 'ns' to Regrtest
  constructor.  Remove kwargs argument from Regrtest.main().
* _parse_args() checks ns.huntrleaks.
* set_temp_dir() is now responsible to call expanduser().
* Regrtest.main() sets self.tests earlier.
* Add TestTuple and TestList types.
* Rename MatchTests to FilterTuple and rename MatchTestsDict
  to FilterTestDict.
* TestResult.get_rerun_match_tests() return type
  is now FilterTuple: return a tuple instead of a list.
  RunTests.tests type becomes TestTuple.

2 years agogh-108996: add tests for msvcrt (#109004)
AN Long [Fri, 8 Sep 2023 22:38:38 +0000 (06:38 +0800)] 
gh-108996: add tests for msvcrt (#109004)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2 years agogh-109054: configure checks if libatomic is needed (#109101)
Victor Stinner [Fri, 8 Sep 2023 21:14:33 +0000 (23:14 +0200)] 
gh-109054: configure checks if libatomic is needed (#109101)

Fix building the _testcapi extension on Linux AArch64 which requires
linking to libatomic when <cpython/pyatomic.h> is used: the
_Py_atomic_or_uint64() function requires libatomic
__atomic_fetch_or_8() on this platform.

The configure script now checks if linking to libatomic is needed and
generates a new LIBATOMIC variable used to build the _testcapi
extension.

Building the _testcapi extension now uses the LIBATOMIC variable in
its LDFLAGS, since Modules/_testcapi/pyatomic.c uses
<cpython/pyatomic.h>.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2 years agogh-108455: peg_generator: enable mypy's `--warn-unreachable` setting and `redundant...
Alex Waygood [Fri, 8 Sep 2023 21:05:40 +0000 (22:05 +0100)] 
gh-108455: peg_generator: enable mypy's `--warn-unreachable` setting and `redundant-expr` error code (#109160)

2 years agogh-91960: FreeBSD Cirrus CI runs configure separately (#109127)
Victor Stinner [Fri, 8 Sep 2023 20:06:34 +0000 (22:06 +0200)] 
gh-91960: FreeBSD Cirrus CI runs configure separately (#109127)

Run configure and make in separated steps to have more readable logs.

2 years agogh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positi...
Pablo Galindo Salgado [Fri, 8 Sep 2023 17:00:23 +0000 (18:00 +0100)] 
gh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positives (#109121)

2 years agoCheck the result of PySet_Contains() for error in Python/symtable.c (GH-109146)
Serhiy Storchaka [Fri, 8 Sep 2023 16:57:41 +0000 (19:57 +0300)] 
Check the result of PySet_Contains() for error in Python/symtable.c (GH-109146)

2 years agoGH-108614: Unbreak emscripten build (GH-109132)
Mark Shannon [Fri, 8 Sep 2023 16:54:45 +0000 (17:54 +0100)] 
GH-108614: Unbreak emscripten build (GH-109132)

2 years agoGH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (#109142)
Kumar Aditya [Fri, 8 Sep 2023 16:27:58 +0000 (21:57 +0530)] 
GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (#109142)

Use `asyncio.sleep(0)` instead of short sleeps.

2 years agogh-109136: Fix summarize_stats.py tool (#109137)
Michael Droettboom [Fri, 8 Sep 2023 16:23:58 +0000 (12:23 -0400)] 
gh-109136: Fix summarize_stats.py tool (#109137)

2 years agogh-106922: Fix error location for constructs with spaces and parentheses (#108959)
Pablo Galindo Salgado [Fri, 8 Sep 2023 16:18:35 +0000 (17:18 +0100)] 
gh-106922: Fix error location for constructs with spaces and parentheses (#108959)

2 years agogh-109140: Rename duplicated tests in `test_binascii` (#109141)
Hugo van Kemenade [Fri, 8 Sep 2023 15:30:28 +0000 (09:30 -0600)] 
gh-109140: Rename duplicated tests in `test_binascii` (#109141)

2 years agogh-104690: thread_run() checks for tstate dangling pointer (#109056)
Victor Stinner [Fri, 8 Sep 2023 09:50:46 +0000 (11:50 +0200)] 
gh-104690: thread_run() checks for tstate dangling pointer (#109056)

thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.

Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.

2 years agoGH-91079: Rename C_RECURSION_LIMIT to Py_C_RECURSION_LIMIT (#108507)
Victor Stinner [Fri, 8 Sep 2023 09:48:28 +0000 (11:48 +0200)] 
GH-91079: Rename C_RECURSION_LIMIT to Py_C_RECURSION_LIMIT (#108507)

Symbols of the C API should be prefixed by "Py_" to avoid conflict
with existing names in 3rd party C extensions on "#include <Python.h>".

test.pythoninfo now logs Py_C_RECURSION_LIMIT constant and other
_testcapi and _testinternalcapi constants.

2 years agoGH-108716: Turn off deep-freezing of code objects. (GH-108722)
Mark Shannon [Fri, 8 Sep 2023 09:34:40 +0000 (10:34 +0100)] 
GH-108716: Turn off deep-freezing of code objects. (GH-108722)

2 years agoUpdate `CODEOWNERS` for `Tools/wasm/` (#109119)
Brett Cannon [Fri, 8 Sep 2023 05:37:29 +0000 (22:37 -0700)] 
Update `CODEOWNERS` for `Tools/wasm/` (#109119)

2 years agogh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)
Ethan Furman [Fri, 8 Sep 2023 01:19:03 +0000 (18:19 -0700)] 
gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)

add guard so that ``Enum('bar')`` raises a TypeError instead of
creating a new enum class called `bar`.  To create the new but
empty class, use:

    huh = Enum('bar', names=())

2 years agoUse unittest test runner for doctests in test_statistics (GH-108921)
Serhiy Storchaka [Thu, 7 Sep 2023 20:08:55 +0000 (23:08 +0300)] 
Use unittest test runner for doctests in test_statistics (GH-108921)

2 years agoAdd version directives to ast docs (#108788)
Shantanu [Thu, 7 Sep 2023 18:34:18 +0000 (11:34 -0700)] 
Add version directives to ast docs (#108788)

2 years agogh-68403: Fix test_coverage in test_trace (GH-108910)
Serhiy Storchaka [Thu, 7 Sep 2023 18:28:18 +0000 (21:28 +0300)] 
gh-68403: Fix test_coverage in test_trace (GH-108910)

Its behavior no longer affected by test running options such as -m.

2 years agogh-75743: Restore test_timeout.testConnectTimeout() (#109087)
Ee Durbin [Thu, 7 Sep 2023 18:13:32 +0000 (14:13 -0400)] 
gh-75743: Restore test_timeout.testConnectTimeout() (#109087)

This un-skips this test now that pythontest.net implements appropriate firewall
rules for it.

2 years agogh-103186: Make test_generated_cases less noisy by default (GH-109100)
Serhiy Storchaka [Thu, 7 Sep 2023 17:53:38 +0000 (20:53 +0300)] 
gh-103186: Make test_generated_cases less noisy by default (GH-109100)

Print additional details only when tests are run with -vv.

2 years agogh-109094: remove unnecessary updates of frame->prev_instr in instrumentation functio...
Irit Katriel [Thu, 7 Sep 2023 17:23:11 +0000 (18:23 +0100)] 
gh-109094: remove unnecessary updates of frame->prev_instr in instrumentation functions (#109076)

2 years agogh-107924: re-order os.sendfile() flag documentation (#107926)
Christoph Anton Mitterer [Thu, 7 Sep 2023 15:50:10 +0000 (17:50 +0200)] 
gh-107924: re-order os.sendfile() flag documentation (#107926)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-108732: include comprehension locals in frame.f_locals (#109026)
Carl Meyer [Thu, 7 Sep 2023 14:56:43 +0000 (08:56 -0600)] 
gh-108732: include comprehension locals in frame.f_locals (#109026)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agogh-102823: Document return type of floor division on floats (#102824)
Mark Dickinson [Thu, 7 Sep 2023 14:20:33 +0000 (15:20 +0100)] 
gh-102823: Document return type of floor division on floats (#102824)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-88943: Improve syntax error for non-ASCII character that follows a numerical liter...
Serhiy Storchaka [Thu, 7 Sep 2023 14:00:13 +0000 (17:00 +0300)] 
gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081)

It now points on the invalid non-ASCII character, not on the valid numerical literal.

2 years agogh-107544: Add docs about `json.dumps(..., default=)` (#108259)
Nikita Sobolev [Thu, 7 Sep 2023 13:53:33 +0000 (16:53 +0300)] 
gh-107544: Add docs about `json.dumps(..., default=)` (#108259)

2 years agogh-71770: Add more details on behavior of configparser's default_section (#31562)
Stanley [Thu, 7 Sep 2023 13:52:58 +0000 (06:52 -0700)] 
gh-71770: Add more details on behavior of configparser's default_section (#31562)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agoGH-108614: Add `RESUME_CHECK` instruction (GH-108630)
Mark Shannon [Thu, 7 Sep 2023 13:39:03 +0000 (14:39 +0100)] 
GH-108614: Add `RESUME_CHECK` instruction (GH-108630)

2 years agogh-103186: Suppress RuntimeWarning about unclosed async iterator in test_sys_settrace...
Serhiy Storchaka [Thu, 7 Sep 2023 13:34:44 +0000 (16:34 +0300)] 
gh-103186: Suppress RuntimeWarning about unclosed async iterator in test_sys_settrace (GH-109075)

2 years agogh-103186: Remove debug print in test_sys_settrace (GH-109077)
Serhiy Storchaka [Thu, 7 Sep 2023 13:30:41 +0000 (16:30 +0300)] 
gh-103186: Remove debug print in test_sys_settrace (GH-109077)

2 years agoGH-90915: Document that SystemExit doesn't trigger sys.excepthook (#31357)
Colin Watson [Thu, 7 Sep 2023 13:14:27 +0000 (14:14 +0100)] 
GH-90915: Document that SystemExit doesn't trigger sys.excepthook (#31357)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agosocket documentation fix - rename triple to 3-tuple (#24722)
Ori Hoch [Thu, 7 Sep 2023 10:33:02 +0000 (13:33 +0300)] 
socket documentation fix - rename triple to 3-tuple (#24722)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agobpo-38157: Add example about per file output for mock_open. (#16090)
Karthikeyan Singaravelan [Thu, 7 Sep 2023 09:19:13 +0000 (14:49 +0530)] 
bpo-38157: Add example about per file output for mock_open. (#16090)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-103186: Suppress and assert expected RuntimeWarnings in test_sys_settrace (GH...
Ijtaba Hussain [Thu, 7 Sep 2023 07:41:38 +0000 (12:41 +0500)] 
gh-103186: Suppress and assert expected RuntimeWarnings in test_sys_settrace (GH-103244)

Caused as a result of frame manipulation where locals are never assigned / initialised.