summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_code.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-071-1/+22
| | | | | | We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
* gh-117783: Immortalize objects that use deferred reference counting (#118112)Sam Gross2024-04-291-1/+5
| | | | | | | | | Deferred reference counting is not fully implemented yet. As a temporary measure, we immortalize objects that would use deferred reference counting to avoid multi-threaded scaling bottlenecks. This is only performed in the free-threaded build once the first non-main thread is started. Additionally, some tests, including refleak tests, suppress this behavior.
* gh-117683: Fix test_free_different_thread failures with GIL disabled (#117685)Sam Gross2024-04-161-2/+6
|
* gh-117376: Partial implementation of deferred reference counting (#117696)Sam Gross2024-04-121-0/+2
| | | | | This marks objects as using deferred refrence counting using the `ob_gc_bits` field in the free-threaded build and collects those objects during GC.
* gh-116303: Skip test module dependent tests if test modules are unavailable ↵Erlend E. Aasland2024-04-031-4/+3
| | | | (#117341)
* gh-110481: Implement inter-thread queue for biased reference counting (#114824)Sam Gross2024-02-091-0/+1
| | | | | | | | | Biased reference counting maintains two refcount fields in each object: `ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two fields. In some cases, when refcounting operations are split across threads, the ob_ref_shared field can be negative (although the total refcount must be at least zero). In this case, the thread that decremented the refcount requests that the owning thread give up ownership and merge the refcount fields.
* gh-112962: in dis module, put cache information in the Instruction instead ↵Irit Katriel2023-12-131-4/+4
| | | | of creating fake Instructions to represent it (#113016)
* gh-109052: Use the base opcode when comparing code objects (gh-109107)Tian Gao2023-09-091-0/+19
|
* gh-108751: Add copy.replace() function (GH-108752)Serhiy Storchaka2023-09-061-0/+7
| | | | | | | | | It creates a modified copy of an object by calling the object's __replace__() method. It is a generalization of dataclasses.replace(), named tuple's _replace() method and replace() methods in various classes, and supports all these stdlib classes.
* gh-106581: Project through calls (#108067)Guido van Rossum2023-08-171-1/+1
| | | | This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
* GH-103805: Lib test f541 linting issue fix (#103812)Rodolfo M. Pereira2023-04-241-1/+1
| | | | | | | | | | | | | | | | This PR makes some minor linting adjustments to the Lib/test module caught by [ruff](https://github.com/charliermarsh/ruff). The adjustments are all related to the `F541 f-string without any placeholders` issue. Issue: https://github.com/python/cpython/issues/103805 <!-- gh-issue-number: gh-103805 --> * Issue: gh-103805 <!-- /gh-issue-number --> --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-121-5/+5
| | | | | | | | | | (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-101865: Deprecate `co_lnotab` from code objects as per PEP 626 (#101866)Nikita Sobolev2023-04-031-0/+7
| | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-281-3/+3
|
* gh-101632: Add the new RETURN_CONST opcode (#101633)penguin_wwy2023-02-071-0/+1
|
* GH-100117: Make `co_lines` more efficient (GH-100447)Brandt Bucher2023-01-101-1/+2
|
* gh-94155: Reduce hash collisions for code objects (#100183)Dennis Sweeney2022-12-231-0/+26
| | | | | | | * Uses a better hashing algorithm to get better dispersion and remove commutativity. * Incorporates `co_firstlineno`, `Py_SIZE(co)`, and bytecode instructions. * This is now the entire set of criteria used in `code_richcompare`, except for `_PyCode_ConstantKey` (which would incorporate the types of `co_consts` rather than just their values).
* gh-100077: make test_code.test_invalid_bytecode more robust and maintainable ↵Irit Katriel2022-12-071-8/+12
| | | | (#100078)
* GH-97779: Ensure that *all* frame objects are backed by "complete" frames ↵Brandt Bucher2022-10-051-0/+33
| | | | (GH-97845)
* gh-96711: Enhance SystemError message upon Invalid opcode (#96712)serge-sans-paille2022-09-201-0/+11
| | | | | | Raise verbose SystemError instead of printing debug information upon Invalid opcode. Fix #96711
* GH-95150: Use position and exception tables for code hashing and equality ↵Brandt Bucher2022-08-011-0/+21
| | | | (GH-95509)
* Revert "gh-94816: Improve coverage of decode_linetable (GH-94853)" (GH-94982)Michael Droettboom2022-07-181-23/+0
| | | This reverts commit 20b9d2a658059c8c1624400f60bb6ba19a31ee9b.
* gh-94816: Improve coverage of decode_linetable (GH-94853)Michael Droettboom2022-07-141-0/+23
| | | | | | | This makes calls to co_lnotab to exercise this code, as well as generating synthetically large code to exercise the corner cases where line numbers need multiple bytes. Automerge-Triggered-By: GH:brandtbucher
* gh-94485: Set line number of module's RESUME instruction to 0, as specified ↵Irit Katriel2022-07-051-1/+0
| | | | | by PEP 626 (GH-94552) Co-authored-by: Mark Shannon <mark@hotpy.org>
* gh-84461: Fix ctypes and test_ctypes on Emscripten (#94142)Christian Heimes2022-06-241-0/+2
| | | | | - c_longlong and c_longdouble need experimental WASM bigint. - Skip tests that need threading - Define ``CTYPES_MAX_ARGCOUNT`` for Emscripten. libffi-emscripten 2022-06-23 supports up to 1000 args.
* GH-93662: Make sure that column offsets are correct in multi-line method ↵Mark Shannon2022-06-141-1/+30
| | | | calls. (GH-93673)
* GH-88116: Document that PyCodeNew is dangerous, and make PyCode_NewEmpty ↵Mark Shannon2022-04-211-0/+3
| | | | less dangerous. (GH-91790)
* GH-88116: Use a compact format to represent end line and column offsets. ↵Mark Shannon2022-04-211-39/+130
| | | | | | | | | | | | (GH-91666) * Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
* bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)Brandt Bucher2022-02-251-1/+1
|
* bpo-45923: Handle call events in bytecode (GH-30364)Mark Shannon2022-01-061-4/+11
| | | | * Add a RESUME instruction to handle "call" events.
* bpo-46202: Remove opcode POP_EXCEPT_AND_RERAISE (GH-30302)Irit Katriel2022-01-041-1/+3
| | | | | | * bpo-46202: remove opcode POP_EXCEPT_AND_RERAISE * do not assume that an exception group is truthy
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-1/+3
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* bpo-45229: Use doctest.DocTestSuite instead of run_doctest (GH-28468)Serhiy Storchaka2021-09-201-9/+7
| | | Alo use load_tests() for adding tests.
* bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)Serhiy Storchaka2021-08-291-1/+3
|
* bpo-44980: fix test_constructor to return None value (GH-27898)andrei kulakov2021-08-231-1/+1
|
* Fix a SystemError in code.replace() (#27771)Guido van Rossum2021-08-161-0/+9
| | | | | | | While the comment said 'We don't bother resizing localspluskinds', this would cause .replace() to crash when it happened. (Also types.CodeType(), but testing that is tedious, and this tests all code paths.)
* Remove __cleanenv from PEP-657 tests (GH-27060)Ammar Askar2021-07-071-2/+2
|
* bpo-43950: Add option to opt-out of PEP-657 (GH-27023)Ammar Askar2021-07-071-1/+29
| | | | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)Gabriele N. Tornetta2021-07-071-1/+9
|
* bpo-43950: use 0-indexed column offsets for bytecode positions (GH-27011)Batuhan Taskaya2021-07-041-1/+1
|
* bpo-43950: Add code.co_positions (PEP 657) (GH-26955)Pablo Galindo2021-07-021-0/+83
| | | | | | | | | | | | | | | This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-43693 Get rid of CO_NOFREE -- it's unused (GH-26839)Guido van Rossum2021-06-231-9/+5
| | | | | | All uses of this flag are either setting it or in doc or tests for it. So we should be able to get rid of it completely.
* bpo-43693: Clean up the PyCodeObject fields. (GH-26364)Eric Snow2021-05-261-2/+44
| | | | | | | | | | * Move up the comment about fields using in hashing/comparision. * Group the fields more clearly. * Add co_ncellvars and co_nfreevars. * Raise ValueError if nlocals != len(varnames), rather than aborting.
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-0/+1
| | | | | | | | "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-42739: Don't use sentinels to mark end of line table. (GH-25657)Mark Shannon2021-04-291-0/+6
| | | | | * Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust. * Update PyCodeAddressRange to match PEP 626.
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-1/+1
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-40443: Remove unused imports in tests (GH-19804)Victor Stinner2020-04-301-1/+0
|
* Cleanup exit code for interpreter. (GH-17756)Mark Shannon2020-01-131-36/+0
|
* bpo-38839: Fix some unused functions in tests (GH-17189)Adam Johnson2019-11-191-1/+1
|
* bpo-37122: Make co->co_argcount represent the total number of positonal ↵Pablo Galindo2019-06-011-1/+1
| | | | arguments in the code object (GH-13726)