aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_cmd_line.py
Commit message (Collapse)AuthorAge
* gh-71339: Use new assertion methods in tests (GH-129046)Serhiy Storchaka2025-05-22
|
* gh-133374: fix test_python_legacy_windows_stdio (GH-134080)Inada Naoki2025-05-20
|
* gh-102567: Add -X importtime=2 for logging an importtime message for ↵Noah Kim2025-05-06
| | | | | already-loaded modules (#118655) Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
* gh-129027: Raise DeprecationWarning for sys._clear_type_cache (#129043)Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)2025-04-25
| | | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-103997: Automatically dedent the argument to "-c" (#103998)Jon Crall2025-04-18
| | | | | | | Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475)Victor Stinner2025-01-31
| | | Replace "on verb+ing" with "while verb+ing".
* gh-128377: Skip `test_cmd_line.test_non_interactive_output_buffering` when ↵Yan Yanchii2025-01-12
| | | | | | | `PYTHONUNBUFFERED=1` (#128378) The `test_cmd_line.test_non_interactive_output_buffering` test assumes a buffered `stdio` without checking the `PYTHONUNBUFFERED` value. Instead of changing the environment variable for the duration of the test, it is better to simply skip it.
* Make the Python CLI error message style more consistent (GH-128129)9cel2025-01-11
|
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-04
| | | | | | | | | `BINARY_OP` (#123926) Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
* gh-126353: remove implicit creation of loop from `asyncio.get_event_loop` ↵Kumar Aditya2024-11-04
| | | | | (#126354) Remove implicit creation of loop from `asyncio.get_event_loop`. This is a step forward of deprecating the policy system of asyncio.
* gh-123275: Add tests for `PYTHON_GIL=1` and `-Xgil=1` (gh-123754)Peter Bierma2024-09-06
|
* gh-121016: Add test for `PYTHON_BASIC_REPL` envioronment variable (#121017)devdanzin2024-06-26
|
* gh-119574: Add some missing environment variables to '--help-env'. (GH-120006)devdanzin2024-06-18
|
* gh-120417: Add #noqa: F401 to tests (#120627)Victor Stinner2024-06-18
| | | | Ignore linter "imported but unused" warnings in tests when the linter doesn't understand how the import is used.
* Fixing a typo in test_cmd_line.py (#118728)Yutian Li2024-05-08
|
* gh-112730: Make the test suite resilient to color-activation environment ↵Pablo Galindo Salgado2024-04-24
| | | | variables (#117672)
* gh-116858: Add `@cpython_only` to several tests in `test_cmd_line` (#116859)Nikita Sobolev2024-03-16
|
* gh-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` (#116338)Brett Simmers2024-03-11
| | | | | | | | | In free-threaded builds, running with `PYTHON_GIL=0` will now disable the GIL. Follow-up issues track work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default. In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag that causes `take_gil()` and `drop_gil()` to return early.
* gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec (#116359)Victor Stinner2024-03-06
| | | | | | _PyConfig_AsDict() now returns bool objects for options using the new PyConfig_MEMBER_BOOL type. Update tests for these changes.
* gh-112532: Require mimalloc in `--disable-gil` builds (gh-112883)Sam Gross2023-12-12
|
* gh-108082: Use PyErr_FormatUnraisable() (GH-111580)Serhiy Storchaka2023-11-02
| | | | | | Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-111374: Add a new PYTHON_FROZEN_MODULES env var, equivalent of `-X ↵Yilei Yang2023-11-01
| | | | | | | frozen_modules`. (#111411) Adds a new PYTHON_FROZEN_MODULES env var to correspond with -X frozen_modules. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* gh-90815: Add mimalloc memory allocator (#109914)Dino Viehland2023-10-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add mimalloc v2.12 Modified src/alloc.c to remove include of alloc-override.c and not compile new handler. Did not include the following files: - include/mimalloc-new-delete.h - include/mimalloc-override.h - src/alloc-override-osx.c - src/alloc-override.c - src/static.c - src/region.c mimalloc is thread safe and shares a single heap across all runtimes, therefore finalization and getting global allocated blocks across all runtimes is different. * mimalloc: minimal changes for use in Python: - remove debug spam for freeing large allocations - use same bytes (0xDD) for freed allocations in CPython and mimalloc This is important for the test_capi debug memory tests * Don't export mimalloc symbol in libpython. * Enable mimalloc as Python allocator option. * Add mimalloc MIT license. * Log mimalloc in Lib/test/pythoninfo.py. * Document new mimalloc support. * Use macro defs for exports as done in: https://github.com/python/cpython/pull/31164/ Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-109595: Add -Xcpu_count=<n> cmdline for container users (#109667)Donghee Na2023-10-10
| | | | | | --------- Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
* gh-109721: Guard `_testinternalcapi` imports in tests (GH-109722)Nikita Sobolev2023-09-22
|
* gh-106320: Remove private _PyMem API (#107187)Victor Stinner2023-07-24
| | | | | | | | | | | | | Move private _PyMem functions to the internal C API (pycore_pymem.h): * _PyMem_GetCurrentAllocatorName() * _PyMem_RawStrdup() * _PyMem_RawWcsdup() * _PyMem_Strdup() No longer export these functions. Move pymem_getallocatorsname() function from _testcapi to _testinternalcapi, since the API moved to the internal C API.
* gh-96512: Move int_max_str_digits setting to PyConfig (#96944)Gregory P. Smith2022-10-03
| | | | | | | | | | | It had to live as a global outside of PyConfig for stable ABI reasons in the pre-3.12 backports. This removes the `_Py_global_config_int_max_str_digits` and gets rid of the equivalent field in the internal `struct _is PyInterpreterState` as code can just use the existing nested config struct within that. Adds tests to verify unique settings and configs in subinterpreters.
* gh-96848: Fix -X int_max_str_digits option parsing (#96988)Victor Stinner2022-09-26
| | | | | Fix command line parsing: reject "-X int_max_str_digits" option with no value (invalid) when the PYTHONINTMAXSTRDIGITS environment variable is set to a valid limit.
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)Gregory P. Smith2022-09-02
| | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
* bpo-45445: Revert "bpo-45445: Fail if an invalid X-option is provided in the ↵Pablo Galindo Salgado2022-07-31
| | | | command line (GH-28823)" (#94745)
* gh-90300: split --help output into separate options (#30331)Éric2022-06-01
| | | | | | Make --help output shorter and add new help options. --help-env, --help-xoptions and --help-all command-line options are added to complement --help.
* gh-69443: Add test.support.Py_DEBUG constant (#93226)Victor Stinner2022-05-26
|
* gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)Victor Stinner2022-05-06
| | | | | Fix tests failing with the PYTHONSAFEPATH=1 env var. Enhance also -P help in Python usage (python --help).
* gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)Victor Stinner2022-05-06
| | | | | | | | | | | | Add the -P command line option and the PYTHONSAFEPATH environment variable to not prepend a potentially unsafe path to sys.path. * Add sys.flags.safe_path flag. * Add PyConfig.safe_path member. * Programs/_bootstrap_python.c uses config.safe_path=0. * Update subprocess._optim_args_from_interpreter_flags() to handle the -P command line option. * Modules/getpath.py sets safe_path to 1 if a "._pth" file is present.
* gh-91156: Use `locale.getencoding()` instead of getpreferredencoding (GH-91732)Inada Naoki2022-04-22
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654)Bader Zaidan2022-03-17
|
* bpo-1635741: test_embed cheks that Python does not leak (GH-31555)Victor Stinner2022-02-25
|
* bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615)Christian Heimes2022-01-25
|
* bpo-46417: Clear symtable identifiers at exit (GH-30809)Victor Stinner2022-01-23
| | | | | | Add _PySymtable_Fini() function, called by finalize_interp_clear(). Update test_cmd_line.test_showrefcount() to tolerate negative reference count.
* bpo-45020: Add tests for the -X "frozen_modules" option. (gh-28997)Eric Snow2021-10-25
| | | | | We hadn't explicitly added any tests for this, so here they are. https://bugs.python.org/issue45020
* bpo-45445: Fail if an invalid X-option is provided in the command line ↵Pablo Galindo Salgado2021-10-13
| | | | (GH-28823)
* bpo-45229: Remove test_main in many tests (GH-28405)Serhiy Storchaka2021-09-19
| | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests.
* bpo-43825: Fix deprecation warnings in test_cmd_line and test_collections ↵Karthikeyan Singaravelan2021-04-14
| | | | | | (GH-25380) * Fix deprecation warnings due to invalid escape sequences. * Use self.assertEqual instead of deprecated self.assertEquals.
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-04
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* bpo-43591: Fix error location in interactive mode for errors at the end of ↵Pablo Galindo2021-03-22
| | | | | the line (GH-24973) Co-authored-by: Erlend Egeberg Aasland
* bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (GH-24843)Victor Stinner2021-03-17
| | | | | | | | | | Python no longer fails at startup with a fatal error if a command line argument contains an invalid Unicode character. The Py_DecodeLocale() function now escapes byte sequences which would be decoded as Unicode characters outside the [U+0000; U+10ffff] range. Use MAX_UNICODE constant in unicodeobject.c.
* bpo-43410: Fix crash in the parser when producing syntax errors when reading ↵Pablo Galindo2021-03-14
| | | | from stdin (GH-24763)
* bpo-32381: pymain_run_command() uses PyCF_IGNORE_COOKIE (GH-23724)Victor Stinner2020-12-23
| | | | | | | | | | The coding cookie (ex: "# coding: latin1") is now ignored in the command passed to the -c command line option. Since pymain_run_command() uses UTF-8, pass PyCF_IGNORE_COOKIE compiler flag to the parser. pymain_run_python() no longer propages compiler flags between function calls.
* bpo-41525: Make the Python program help ASCII-only (GH-21836)Serhiy Storchaka2020-09-09
|
* bpo-40275: Use new test.support helper submodules in tests (GH-20849)Hai Shi2020-06-25
|