Commit Graph

118925 Commits

Author SHA1 Message Date
Guido van Rossum b86ce91bfe
gh-106581: Honor 'always_exits' in write_components() (#109338)
I must have overlooked this when refactoring the code generator.
The Tier 1 interpreter contained a few silly things like
```
            goto resume_frame;
            STACK_SHRINK(1);
```
(and other variations, some where the unconditional `goto` was hidden in a macro).
2023-09-12 17:58:40 +00:00
Victor Stinner d12b3e3152
gh-109276: test.pythoninfo gets more test.support data (#109337)
Collect data from:

* test.support
* test.support.os_helper
* test.support.socket_helper
* test.support.threading_helper
2023-09-12 18:43:32 +02:00
Irit Katriel b303d3ad3e
gh-109319: deprecate dis.HAVE_ARGUMENT (#109320) 2023-09-12 16:45:35 +01:00
Hugo van Kemenade 3cb9a8edca
gh-60283: Check for redefined test names in CI (#109161)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-12 15:28:20 +00:00
Irit Katriel 0e76cc359b
gh-109184: update traceback module doc w.r.t notes (message is no longer always at the end) (#109201) 2023-09-12 14:54:04 +00:00
AN Long e121fca33b
gh-109266: Fix msvcrt.kbhit's documented return value (GH-109267) 2023-09-12 15:44:48 +01:00
Nikita Sobolev 42ab2cbd7b
gh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314) 2023-09-12 16:05:29 +02:00
Nikita Sobolev 66d1d7eb06
gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497) 2023-09-12 16:33:30 +03:00
Victor Stinner d13f782a18
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.
2023-09-12 15:13:29 +02:00
Irit Katriel 8b55adfa8f
gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269) 2023-09-12 10:36:17 +00:00
Nikita Sobolev 247ee1bf84
gh-109216: Fix possible memory leak in `BUILD_MAP` (#109257) 2023-09-12 15:07:22 +05:30
Nikita Sobolev 1110c5bc82
gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265) 2023-09-12 09:37:42 +03:00
Victor Stinner 8c813faf86
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.
2023-09-12 03:47:04 +00:00
Victor Stinner a84cb74d42
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.
2023-09-12 05:35:08 +02:00
Victor Stinner 4e77645986
gh-109276: libregrtest only checks saved_test_environment() once (#109278)
There is no need to check for environment changes twice.
2023-09-12 05:01:33 +02:00
Victor Stinner df4f0fe203
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).
2023-09-12 02:50:05 +00:00
Victor Stinner 9363769161
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.
2023-09-12 04:30:07 +02:00
Raymond Hettinger f2a55fecd0
Fix iter_index() to work with lists which do not support stop=None. (gh-109306) 2023-09-12 04:04:28 +02:00
Victor Stinner 7dedfd36dc
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.
2023-09-12 03:35:26 +02:00
Victor Stinner 09ea4b8706
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.
2023-09-12 03:31:15 +02:00
Tian Gao 391f3e3ca9
GH-106734: Disable tab completion in pdb's multiline mode (GH-106735) 2023-09-11 18:28:43 -07:00
Jelle Zijlstra b88d9e75f6
gh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)
Fixes #109118. Fixes #109194.

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-09-11 17:11:06 -07:00
Carl Meyer 2b1e2f1cd1
gh-109292: add symtable impact of PEP 709 to What's New (#109293) 2023-09-11 18:03:04 -06:00
Carl Meyer ceeb4173ae
gh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289) 2023-09-11 17:35:49 -06:00
Guido van Rossum fbaf77eb9b
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
2023-09-11 15:39:19 -07:00
wim glenn 1ee50e2a78
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
2023-09-11 15:44:13 -04:00
Guido van Rossum bcce5e2718
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.
2023-09-11 18:20:24 +00:00
Irit Katriel ecd21a629a
gh-109179: Fix traceback display for SyntaxErrors with notes (#109197) 2023-09-11 19:18:34 +01:00
Victor Stinner de5f8f7d13
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.
2023-09-11 19:33:42 +02:00
Nikita Sobolev baa6dc8e38
gh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644) 2023-09-11 19:13:37 +03:00
Hugo van Kemenade 57b6205523
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>
2023-09-11 19:06:16 +03:00
Victor Stinner 517cd82ea7
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().
2023-09-11 17:27:03 +02:00
Serhiy Storchaka c0f488b88f
gh-109182: Fix and improve tests for gh-108654 (GH-109189) 2023-09-11 17:50:33 +03:00
Mark Shannon 4a69301ea4
GH-108976. Keep monitoring data structures valid during de-optimization during callback. (GH-109131) 2023-09-11 14:37:09 +01:00
Serhiy Storchaka 60b8341d07
Better integration of doctest and unittest in test_ctypes.test_objects (GH-108922)
Better integration of docrtest and unittest in test_ctypes.test_objects
2023-09-11 14:05:30 +03:00
Serhiy Storchaka 0abc935086
Test DocTestFinder directly instead of calling support.run_doctest() (GH-108917) 2023-09-11 14:03:30 +03:00
Victor Stinner c439f6a72d
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.
2023-09-11 08:52:03 +00:00
Victor Stinner a9b1f84790
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.
2023-09-11 08:11:31 +00:00
Victor Stinner 3b2ecbc127
GH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247) 2023-09-11 09:34:04 +02:00
Victor Stinner 7aa8fcc8eb
gh-109162: libregrtest: use relative imports (#109250)
libregrtest.__init__ no longer exposes any symbol, so
"python -m test.libregrtest.worker" imports less modules.
2023-09-11 07:02:35 +00:00
Victor Stinner 0c139b5f2f
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.
2023-09-11 03:27:37 +00:00
Victor Stinner 0b6b05391b
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.
2023-09-11 01:46:26 +00:00
Victor Stinner 1ec45378e9
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.
2023-09-11 00:07:18 +00:00
Victor Stinner a939b65aa6
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).
2023-09-11 01:11:22 +02:00
Victor Stinner e55aab9578
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.
2023-09-10 22:16:59 +00:00
Victor Stinner cbb3a6f8ad
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.
2023-09-10 22:04:35 +00:00
Serhiy Storchaka d6892c2b92
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.
2023-09-10 20:06:09 +03:00
Victor Stinner 71b6e2602c
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" (...)
2023-09-10 18:21:13 +02:00
云line 4297499696
gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) 2023-09-10 15:04:24 +03:00
Delgan 2dd6a86c4e
Fix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222) 2023-09-10 10:55:56 +00:00