summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
Commit message (Collapse)AuthorAgeFilesLines
* Use low bit of LOAD_GLOBAL's oparg to indicate whether it should push an ↵Mark Shannon2022-03-171-1/+7
| | | | additional NULL. (GH-31933)
* bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)Brandt Bucher2022-02-251-24/+41
|
* bpo-46724: Fix dis support for overflow args (GH-31285)Saul Shanabrook2022-02-181-0/+11
|
* bpo-46422: use `dis.Positions` in `dis.Instruction` (GH-30716)Nikita Sobolev2022-01-241-4/+1
| | | Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
* bpo-45636: Merge all numeric operators (GH-29482)Brandt Bucher2021-11-111-0/+4
|
* bpo-45757: Fix bug where dis produced an incorrect oparg on EXTENDED_ARG ↵Irit Katriel2021-11-091-0/+1
| | | | before a no-arg opcode (GH-29480)
* bpo-45152: refactor the dis module to make handling of hasconst opcodes more ↵Irit Katriel2021-09-151-19/+35
| | | | generic (GH-28258)
* bpo-45168: change dis output to omit missing values rather than replacing ↵Irit Katriel2021-09-141-9/+16
| | | | them by their index (GH-28313)
* bpo-45017: move opcode-related logic from modulefinder to dis (GH-28246)Irit Katriel2021-09-091-0/+36
|
* bpo-43950: support positions for dis.Instructions created through ↵Batuhan Taskaya2021-09-031-1/+2
| | | | dis.Bytecode (GH-28142)
* bpo-43950: include position in dis.Instruction (GH-27015)Batuhan Taskaya2021-07-041-9/+44
| | | Automerge-Triggered-By: GH:isidentical
* bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. (gh-26577)Eric Snow2021-06-071-26/+27
| | | | | | | | | | These were reverted in gh-26530 (commit 17c4edc) due to refleaks. * 2c1e258 - Compute deref offsets in compiler (gh-25152) * b2bf2bc - Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388) This change fixes the refleaks. https://bugs.python.org/issue43693
* bpo-43693: Revert commits 2c1e2583fdc4db6b43d163239ea42b0e8394171f and ↵Pablo Galindo2021-06-041-27/+26
| | | | | | | | | | | | | b2bf2bc1ece673d387341e06c8d3c2bc6e259747 (GH-26530) * Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)" This reverts commit b2bf2bc1ece673d387341e06c8d3c2bc6e259747. * Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)" This reverts commit 2c1e2583fdc4db6b43d163239ea42b0e8394171f. These two commits are breaking the refleak buildbots.
* bpo-43693: Compute deref offsets in compiler (gh-25152)Mark Shannon2021-06-041-4/+1
| | | | | | Merges locals and cells into a single array. Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more https://bugs.python.org/issue43693
* bpo-43693: Add new internal code objects fields: co_fastlocalnames and ↵Eric Snow2021-06-031-24/+28
| | | | | | | | | | | | | | | | | co_fastlocalkinds. (gh-26388) A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead. This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily). Aside from the (mild) performance impact, there are a number of other benefits: * there's now a clear, direct relationship between locals-plus and variables * code that relies on the locals-plus-to-name mapping is simpler * marshaled code objects are smaller and serialize/de-serialize faster Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further. https://bugs.python.org/issue43693
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-7/+49
| | | | | | | | "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-27129: Use instruction offsets, not byte offsets, in bytecode and ↵Mark Shannon2021-04-011-3/+6
| | | | | | | internally. (GH-25069) * Use instruction offset, rather than bytecode offset. Streamlines interpreter dispatch a bit, and removes most EXTENDED_ARGs for jumps. * Change some uses of PyCode_Addr2Line to PyFrame_GetLineNumber
* bpo-42562: Fix issue when dis failed to parse function that has no line ↵Yurii Karabas2020-12-041-1/+1
| | | | | | numbers (GH-23632) Fix issue when dis failed to parse function that has only annotations
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-25/+8
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-41497: Fix potential UnicodeDecodeError in dis CLI (GH-21757)Konge2020-08-081-1/+1
|
* bpo-38115: Deal with invalid bytecode offsets in lnotab (GH-16079)T. Wouters2019-09-281-0/+5
| | | | | | | | | | Document that lnotab can contain invalid bytecode offsets (because of terrible reasons that are difficult to fix). Make dis.findlinestarts() ignore invalid offsets in lnotab. All other uses of lnotab in CPython (various reimplementations of addr2line or line2addr in Python, C and gdb) already ignore this, because they take an address to look for, instead. Add tests for the result of dis.findlinestarts() on wacky constructs in test_peepholer.py, because it's the easiest place to add them.
* bpo-36540: PEP 570 -- Implementation (GH-12701)Pablo Galindo2019-04-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains the implementation of PEP570: Python positional-only parameters. * Update Grammar/Grammar with new typedarglist and varargslist * Regenerate grammar files * Update and regenerate AST related files * Update code object * Update marshal.c * Update compiler and symtable * Regenerate importlib files * Update callable objects * Implement positional-only args logic in ceval.c * Regenerate frozen data * Update standard library to account for positional-only args * Add test file for positional-only args * Update other test files to account for positional-only args * Add News entry * Update inspect module and related tests
* bpo-32970: Improve disassembly of the MAKE_FUNCTION instruction. (GH-5937)Serhiy Storchaka2018-03-111-2/+14
|
* bpo-31183: `dis` now handles coroutines & async generators (GH-3077)syncosmic2017-08-181-12/+30
| | | | | | | | | | | | | | Coroutines and async generators use a distinct attribute name for their code objects, so this updates the `dis` module to correctly disassemble objects with those attributes. Due to the increase in the test module length, it also fixes some latent defects in the tests related to how the displayed source line numbers are extracted. https://bugs.python.org/issue31230 is a follow-up issue suggesting we may want to solve this a different way, by instead giving all these object types a common `__code__` attribute, avoiding the need for special casing in the `dis` module.
* bpo-11822: Improve disassembly to show embedded code objects. (#1844)Serhiy Storchaka2017-06-111-6/+17
| | | The depth argument limits recursion.
* bpo-22352: Adjust widths in the output of dis.dis() for large line numbers ↵Serhiy Storchaka2017-04-191-7/+23
| | | | | | | and (#1153) instruction offsets. Add tests for widths of opcode names.
* bpo-29762: More use "raise from None". (#569)Serhiy Storchaka2017-04-051-1/+1
| | | This hides unwanted implementation details from tracebacks.
* Issue #28317: The disassembler now decodes FORMAT_VALUE argument.Serhiy Storchaka2016-10-081-0/+9
|
* Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka2016-09-111-2/+0
| | | | | | | | | | | * BUILD_TUPLE_UNPACK and BUILD_MAP_UNPACK_WITH_CALL no longer generated with single tuple or dict. * Restored more informative error messages for incorrect var-positional and var-keyword arguments. * Removed code duplications in _PyEval_EvalCodeWithName(). * Removed redundant runtime checks and parameters in _PyStack_AsDict(). * Added a workaround and enabled previously disabled test in test_traceback. * Removed dead code from the dis module.
* Rework CALL_FUNCTION* opcodesVictor Stinner2016-09-091-1/+1
| | | | | | | | | | | | | | | | | | | Issue #27213: Rework CALL_FUNCTION* opcodes to produce shorter and more efficient bytecode: * CALL_FUNCTION now only accepts position arguments * CALL_FUNCTION_KW accepts position arguments and keyword arguments, but keys of keyword arguments are packed into a constant tuple. * CALL_FUNCTION_EX is the most generic, it expects a tuple and a dict for positional and keyword arguments. CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW opcodes have been removed. 2 tests of test_traceback are currently broken: skip test, the issue #28050 was created to track the issue. Patch by Demur Rumed, design by Serhiy Storchaka, reviewed by Serhiy Storchaka and Victor Stinner.
* Issue #28003: Implement PEP 525 -- Asynchronous Generators.Yury Selivanov2016-09-091-0/+1
|
* Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.Serhiy Storchaka2016-05-241-22/+13
| | | | Patch by Demur Rumed.
* Issue #26881: The modulefinder module now supports extended opcode arguments.Serhiy Storchaka2016-05-081-29/+26
|\
| * Issue #26881: The modulefinder module now supports extended opcode arguments.Serhiy Storchaka2016-05-081-29/+26
| |
* | Issue #26733: Disassembling a class now disassembles class and static methods.Serhiy Storchaka2016-04-231-1/+2
|\ \ | |/ | | | | Patch by Xiang Zhang.
| * Issue #26733: Disassembling a class now disassembles class and static methods.Serhiy Storchaka2016-04-231-1/+2
| | | | | | | | Patch by Xiang Zhang.
* | co_lnotab supports negative line number deltaVictor Stinner2016-01-201-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26107: The format of the co_lnotab attribute of code objects changes to support negative line number delta. Changes: * assemble_lnotab(): if line number delta is less than -128 or greater than 127, emit multiple (offset_delta, lineno_delta) in co_lnotab * update functions decoding co_lnotab to use signed 8-bit integers - dis.findlinestarts() - PyCode_Addr2Line() - _PyCode_CheckLineNumber() - frame_setlineno() * update lnotab_notes.txt * increase importlib MAGIC_NUMBER to 3361 * document the change in What's New in Python 3.6 * cleanup also PyCode_Optimize() to use better variable names
* | Issue #24878: Add docstrings to selected namedtuplesRaymond Hettinger2015-08-181-0/+9
|/
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-0/+2
|
* Issue #21947: handle generator-iterator objects in disNick Coghlan2014-07-251-2/+6
| | | | Patch by Clement Rouault.
* Close #17916: dis.Bytecode based replacement for distbNick Coghlan2013-11-221-2/+15
| | | | | | | - Bytecode.from_traceback() alternate constructor - current_offset parameter and attribute Patch by Claudiu Popa
* Close #19378: address flaws in the new dis module APIsNick Coghlan2013-11-061-30/+42
| | | | | | | | | | | | | | | - confusing line_offset parameter -> first_line parameter - systematically test and fix new file parameter - remove redundant Bytecode.show_info() API - rename Bytecode.display_code() to Bytecode.dis() and have it return the multi-line string rather than printing it directly - eliminated some not-so-helpful helpers from the bytecode_helper test support module Also fixed a longstanding defect (worked around in the test suite) where lines emitted by the dis module could include trailing white space. That no longer happens, allowing the formatting tests to be simplified to use plain string comparisons.
* Close #18538: ``python -m dis`` now uses argparse.Nick Coghlan2013-08-241-19/+8
| | | | Patch by Michele Orrù.
* #18796: improve documentation of the file argument of dis.show_code. ↵Ezio Melotti2013-08-231-1/+4
| | | | Initial patch by Vajrasky Kok.
* Issue #11816: multiple improvements to the dis moduleNick Coghlan2013-05-061-97/+238
| | | | | | | | * get_instructions generator * ability to redirect output to a file * Bytecode and Instruction abstractions Patch by Nick Coghlan, Ryan Kelly and Thomas Kluyver.
* Issue #11823: disassembly now shows argument counts on calls with keyword argsAlexander Belopolsky2012-06-071-0/+6
|
* As per python-dev discussion with Eli, properly document and publish ↵Nick Coghlan2010-09-101-6/+2
| | | | dis.show_code
* Leave show_code out of __all__ and make it clear that its lack of ↵Nick Coghlan2010-09-101-1/+5
| | | | documentation is deliberate
* Fix dis.__all__ for new additions to module in 3.2(spotted by Eli Bendersky)Nick Coghlan2010-09-101-2/+2
|
* Address XXX comment in dis.py: inspect.py now attempts to reuse the dis.py ↵Nick Coghlan2010-08-171-4/+5
| | | | compiler flag values before resorting to defining its own