summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-108851: Fix tomllib recursion tests (#108853) (#109013)Victor Stinner2023-09-061-26/+31
| | | | | | | | | | | | | | | | | | | | | | | 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 8ff11425783806f8cb78e99f667546b1f7f3428e)
* [3.11] gh-100637: Fix int and bool __sizeof__ calculation to include the 1 ↵Miss Islington (bot)2023-01-031-1/+2
| | | | | | | | | | | | element ob_digit array for 0 and False (GH-100663) (#100717) gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ob_digit array for 0 and False (GH-100663) Fixes behaviour where int (and subtypes like bool) __sizeof__ under-reports true size as it did not take into account the size 1 `ob_digit` array for the zero int. (cherry picked from commit d7e7f79ca7c2029e46a06d21a7a5abea631b5d13) Co-authored-by: Ionite <dev@ionite.io> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* [3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)Gregory P. Smith2022-09-021-2/+8
| | | | | | | | | | | | | | | | | | 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. This backports https://github.com/python/cpython/pull/96499 aka 511ca9452033ef95bc7d7fc404b8161068226002 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#).
* gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126) (#96128)Miss Islington (bot)2022-08-211-0/+8
| | | | | | | | Automerge-Triggered-By: GH:tiran (cherry picked from commit 822955c16654c22c10a993f5a94bbb68b857a150) Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Christian Heimes <christian@python.org>
* [3.11] gh-95174: Add pthread stubs for WASI (GH-95234) (#95503)Christian Heimes2022-08-011-1/+1
| | | | | | Co-authored-by: Brett Cannon <brett@python.org>. (cherry picked from commit 0fe645d6fd22a6f57e777a29e65cf9a4ff9785ae) Co-authored-by: Christian Heimes <christian@python.org>
* gh-92914: Round the allocated size for lists up to the even number (GH-92915)Miss Islington (bot)2022-06-141-3/+4
| | | | | (cherry picked from commit 8a6af5a34642f5564220eb50d72caada8f17fc78) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-93575: Use correct way to calculate PyUnicode struct sizes ↵Christian Heimes2022-06-081-0/+1
| | | | | | | | | | | | (GH-93602) (GH-93613) * gh-93575: Use correct way to calculate PyUnicode struct sizes * Add comment to keep test_sys and test_unicode in sync * Fix case code < 256. (cherry picked from commit 5442561c1a094b68900198bade616da9ed509ac8) Co-authored-by: Christian Heimes <christian@python.org>
* gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)Victor Stinner2022-05-051-2/+2
| | | | | | | | | | | | 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-84461: Add sys._emscripten_info, improve docs and build (gh-91781)Christian Heimes2022-04-231-0/+8
|
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-071-4/+7
| | | Co-authored-by: Brett Cannon <brett@python.org>
* Fix whitespace/indentation issues in test_sys (GH-32369)Ken Jin2022-04-061-2/+2
|
* bpo-46845: Reduce dict size when all keys are Unicode (GH-31564)Inada Naoki2022-03-011-4/+8
|
* bpo-46841: Use inline cache for `BINARY_SUBSCR`. (GH-31618)Mark Shannon2022-03-011-1/+3
|
* bpo-46329: Change calling sequence (again) (GH-31373)Mark Shannon2022-02-181-1/+1
| | | | * Change calling sequence: Add PUSH_NULL. Merge PRECALL_FUNCTION and PRECALL_METHOD into PRECALL.
* bpo-46675: Allow object value arrays and split key dictionaries larger than ↵Mark Shannon2022-02-081-4/+5
| | | | 16 (GH-31191)
* bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615)Christian Heimes2022-01-251-0/+7
|
* bpo-46481: Implement vectorcall for weakref.ref.__call__ method. (GH-30820)Dong-hee Na2022-01-231-2/+2
|
* bpo-46409: Make generators in bytecode (GH-30633)Mark Shannon2022-01-201-2/+2
| | | | | | | | | | | | * Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes. * Trim frame and generator by word each. * Minor refactor of frame.c * Update test.test_sys to account for smaller frames. * Treat generator functions as normal functions when evaluating and specializing.
* bpo-42161: Hoist the _PyLong_GetOne() call out of the inner loop. (GH-30656)Raymond Hettinger2022-01-181-1/+1
|
* bpo-46328: Add sys.exception() (GH-30514)Irit Katriel2022-01-131-0/+63
|
* bpo-45256: Don't track the exact depth of each `InterpreterFrame` (GH-30372)Brandt Bucher2022-01-051-2/+2
|
* bpo-45711: Remove type and traceback from exc_info (GH-30122)Irit Katriel2021-12-171-1/+1
| | | | | | | | * Do not PUSH/POP traceback or type to the stack as part of exc_info * Remove exc_traceback and exc_type from _PyErr_StackItem * Add to what's new, because this change breaks things like Cython
* bpo-45947: Place dict and values pointer at fixed (negative) offset just ↵Mark Shannon2021-12-071-2/+2
| | | | | | | | | | | | | | | | | | | before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT.
* bpo-45963: Make space for the InterpreterFrame of a generator in that ↵Mark Shannon2021-12-061-1/+1
| | | | | | | generator. (GH-29891) * Make generator, coroutine and async gen structs all the same size. * Store interpreter frame in generator (and coroutine). Reduces the number of allocations neeeded for a generator from two to one.
* bpo-45607: Make it possible to enrich exception displays via setting their ↵Irit Katriel2021-12-031-4/+4
| | | | __note__ field (GH-29880)
* bpo-45786: Allocate space for frame in frame object. (GH-29729)Mark Shannon2021-11-291-3/+4
|
* bpo-45522: Allow to disable freelists on build time (GH-29056)Christian Heimes2021-10-211-1/+12
| | | | | | | | Freelists for object structs can now be disabled. A new ``configure`` option ``--without-freelists`` can be used to disable all freelists except empty tuple singleton. Internal Py*_MAXFREELIST macros can now be defined as 0 without causing compiler warnings and segfaults. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-45315: PyType_FromSpec: Copy spec->name and have the type own the memory ↵Petr Viktorin2021-10-211-1/+1
| | | | for its name (GH-29103)
* bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)Mark Shannon2021-10-131-5/+5
| | | | | | | | | | | | | | * Never change types' cached keys. It could invalidate inline attribute objects. * Lazily create object dictionaries. * Update specialization of LOAD/STORE_ATTR. * Don't update shared keys version for deletion of value. * Update gdb support to handle instance values. * Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.
* bpo-29410: Change the default hash algorithm to SipHash13. (GH-28752)Inada Naoki2021-10-101-2/+4
| | | | Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Christian Heimes <christian@python.org>
* bpo-45403: Fix test_sys.test_stdlib_dir() (GH-28785)Victor Stinner2021-10-071-2/+2
| | | | Fix test_sys.test_stdlib_dir() when Python is built outside the source tree: compare normalized paths.
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-061-2/+2
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-45211: Remember the stdlib dir during startup. (gh-28586)Eric Snow2021-09-281-0/+10
| | | | | During runtime startup we figure out the stdlib dir but currently throw that information away. This change preserves it and exposes it via PyConfig.stdlib_dir, _Py_GetStdlibDir(), and sys._stdlib_dir. https://bugs.python.org/issue45211
* bpo-41031: Match C and Python code formatting of unprintable exceptions and ↵Irit Katriel2021-09-051-8/+18
| | | | exceptions in the __main__ module. (GH-28139)
* bpo-45083: Include the exception class qualname when formatting an exception ↵Irit Katriel2021-09-031-0/+14
| | | | | (GH-28119) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* bpo-44590: Lazily allocate frame objects (GH-27077)Mark Shannon2021-07-261-1/+1
| | | | | | | | | | | | | | * Convert "specials" array to InterpreterFrame struct, adding f_lasti, f_state and other non-debug FrameObject fields to it. * Refactor, calls pushing the call to the interpreter upward toward _PyEval_Vector. * Compute f_back when on thread stack, only filling in value when frame object outlives stack invocation. * Move ownership of InterpreterFrame in generator from frame object to generator object. * Do not create frame objects for Python calls. * Do not create frame objects for generators.
* bpo-44207: Add an internal version number to function objects. (GH-27078)Mark Shannon2021-07-121-1/+1
|
* bpo-44032: Move pointer to code object from frame-object to frame specials ↵Mark Shannon2021-06-181-1/+1
| | | | array. (GH-26771)
* bpo-44206: Add a version number to dictionary keys (GH-26333)Mark Shannon2021-05-281-4/+5
| | | | | | | | * Store log2(size) instead of size in dict-keys. * Use enum instead of function pointer to record kind of keys. * Add version number to dict keys.
* bpo-44032: Move data stack to thread from FrameObject. (GH-26076)Mark Shannon2021-05-211-5/+1
| | | | | | | | | | | | | | | | * Remove 'zombie' frames. We won't need them once we are allocating fixed-size frames. * Add co_nlocalplus field to code object to avoid recomputing size of locals + frees + cells. * Move locals, cells and freevars out of frame object into separate memory buffer. * Use per-threadstate allocated memory chunks for local variables. * Move globals and builtins from frame object to per-thread stack. * Move (slow) locals frame object to per-thread stack. * Move internal frame functions to internal header.
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-4/+3
| | | | | | | | "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
* bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)Victor Stinner2021-04-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow creating type instances: set tp_new to NULL and don't create the "__new__" key in the type dictionary. The flag is set automatically on static types if tp_base is NULL or &PyBaseObject_Type and tp_new is NULL. Use the flag on the following types: * _curses.ncurses_version type * _curses_panel.panel * _tkinter.Tcl_Obj * _tkinter.tkapp * _tkinter.tktimertoken * _xxsubinterpretersmodule.ChannelID * sys.flags type * sys.getwindowsversion() type * sys.version_info type Update MyStr example in the C API documentation to use Py_TPFLAGS_DISALLOW_INSTANTIATION. Add _PyStructSequence_InitType() function to create a structseq type with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set. type_new() calls _PyType_CheckConsistency() at exit.
* bpo-43660: Fix crash when displaying exceptions with custom values for ↵Pablo Galindo2021-03-291-0/+15
| | | | sys.stderr (GH-25075)
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-291-1/+2
| | | | | | | | | | | See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
* bpo-42990: Introduce 'frame constructor' struct to simplify API for ↵Mark Shannon2021-01-291-1/+1
| | | | | | | PyEval_CodeEval and friends (GH-24298) * Introduce 'frame constructor' to simplify API for frame creation * Embed struct using a macro to conform to PEP 7
* bpo-42955: Rename module_names to sys.stdlib_module_names (GH-24332)Victor Stinner2021-01-251-2/+2
| | | | * Rename _Py_module_names to _Py_stdlib_module_names. * Rename Python/module_names.h to Python/stdlib_module_names.h.
* bpo-42955: Add sys.modules_names (GH-24238)Victor Stinner2021-01-251-0/+5
| | | | Add sys.module_names, containing the list of the standard library module names.
* bpo-27794: Add `name` attribute to `property` class (GH-23967)Yurii Karabas2020-12-301-1/+1
|
* bpo-42500: Fix recursion in or after except (GH-23568)Mark Shannon2020-12-021-39/+7
| | | * Use counter, rather boolean state when handling soft overflows.
* bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values ↵Vladimir Matveev2020-11-101-1/+1
| | | | (#22780)