summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-1/+1
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* GH-103082: Filter LINE events in VM, to simplify tool implementation. ↵Mark Shannon2023-05-121-1/+1
| | | | | | | | (GH-104387) When monitoring LINE events, instrument all instructions that can have a predecessor on a different line. Then check that the a new line has been hit in the instrumentation code. This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
* gh-84436: Implement Immortal Objects (gh-19474)Eddie Elizondo2023-04-221-1/+2
| | | | | | | | | This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-121-1/+1
| | | | | | | | | | (GH-103083) * The majority of the monitoring code is in instrumentation.c * The new instrumentation bytecodes are in bytecodes.c * legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
* gh-103176: sys._current_exceptions() returns mapping to exception instances ↵Irit Katriel2023-04-111-3/+3
| | | | instead of exc_info tuples (#103177)
* GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)Brandt Bucher2023-03-291-1/+1
|
* gh-102799: remove unnecessary calls to sys.exc_info() in tests (#102800)Irit Katriel2023-03-181-2/+2
|
* Fix deadlock on shutdown if test_current_{exception,frames} fails (#102019)Jacob Bower2023-02-231-73/+75
| | | | | | | | | | | | | | | | * Don't deadlock on shutdown if test_current_{exception,frames} fails These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads. Co-authored-by: Brett Simmers <bsimmers@meta.com> * Add a news entry * Fix whitespace --------- Co-authored-by: Brett Simmers <bsimmers@meta.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-1/+1
|
* gh-86682: Adds sys._getframemodulename as an alternative to using _getframe ↵Steve Dower2023-01-131-0/+20
| | | | | (GH-99520) Also updates calls in collections, doctest, enum, and typing modules to use _getframemodulename first when available.
* gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ↵Ionite2023-01-021-1/+2
| | | | | | | | ob_digit array for 0 and False (#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. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-89189: More compact range iterator (GH-27986)Serhiy Storchaka2022-11-301-1/+2
|
* GH-96793: Implement PEP 479 in bytecode. (GH-99006)Mark Shannon2022-11-031-1/+1
| | | | | * Handle converting StopIteration to RuntimeError in bytecode. * Add custom instruction for converting StopIteration into RuntimeError.
* gh-91051: allow setting a callback hook on PyType_Modified (GH-97875)Carl Meyer2022-10-211-1/+1
|
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)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. 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.
* gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126)Christian Heimes2022-08-191-0/+8
| | | Automerge-Triggered-By: GH:tiran
* GH-95707: Fix uses of `Py_TPFLAGS_MANAGED_DICT` (GH-95854)Mark Shannon2022-08-151-1/+1
| | | | | | * Make sure that tp_dictoffset is correct with Py_TPFLAGS_MANAGED_DICT is set. * Avoid traversing managed dict twice when subclassing class with Py_TPFLAGS_MANAGED_DICT set.
* gh-94673: Add Per-Interpreter tp_subclasses for Static Builtin Types (gh-95301)Eric Snow2022-08-051-1/+1
|
* gh-95174: Add pthread stubs for WASI (GH-95234)Christian Heimes2022-07-271-1/+1
| | | Co-authored-by: Brett Cannon <brett@python.org>
* gh-94673: Add Per-Interpreter Storage for Static Builtin Types (#95255)Eric Snow2022-07-261-1/+1
| | | | | | | | | | | | | | This is the last precursor to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types. Here we add per-type storage on PyInterpreterState, but only for the static builtin types. This involves the following: * add PyInterpreterState.types * move PyInterpreterState.type_cache to it * add a "num_builtins_initialized" field * add a "builtins" field (a static array big enough for all the static builtin types) * add _PyStaticType_GetState() to look up a static builtin type's state * (temporarily) add PyTypeObject.tp_static_builtin_index (to hold the type's index into PyInterpreterState.types.builtins) We will be eliminating tp_static_builtin_index in a later change.
* gh-93575: Use correct way to calculate PyUnicode struct sizes (GH-93602)Christian Heimes2022-06-081-0/+1
| | | | | | | * 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
* gh-92914: Round the allocated size for lists up to the even number (GH-92915)Serhiy Storchaka2022-05-191-3/+4
|
* gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537)Inada Naoki2022-05-121-2/+2
|
* 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)