@@ -266,15 +266,17 @@ operation is being performed, so the intermediate analysis object isn't useful:
266266
267267.. function :: findlinestarts(code)
268268
269- This generator function uses the ``co_firstlineno `` and `` co_lnotab ``
270- attributes of the code object *code * to find the offsets which are starts of
269+ This generator function uses the ``co_lines `` method
270+ of the code object *code * to find the offsets which are starts of
271271 lines in the source code. They are generated as ``(offset, lineno) `` pairs.
272- See :source: `Objects/lnotab_notes.txt ` for the ``co_lnotab `` format and
273- how to decode it.
274272
275273 .. versionchanged :: 3.6
276274 Line numbers can be decreasing. Before, they were always increasing.
277275
276+ .. versionchanged :: 3.10
277+ The :pep: `626 ` ``co_lines `` method is used instead of the ``co_firstlineno ``
278+ and ``co_lnotab `` attributes of the code object.
279+
278280
279281.. function :: findlabels(code)
280282
@@ -446,12 +448,13 @@ result back on the stack.
446448
447449**Binary and in-place operations **
448450
449- Binary operations remove the top of the stack (TOS) and the second top-most
450- stack item (TOS1) from the stack. They perform the operation, and put the
451- result back on the stack.
451+ In the following, TOS is the top-of-stack.
452+ TOS1, TOS2, TOS3 are the second, thrid and fourth items on the stack, respectively.
452453
453- In-place operations are like binary operations, in that they remove TOS and
454- TOS1, and push the result back on the stack, but the operation is done in-place
454+ Binary operations remove the top two items from the stack (TOS and TOS1).
455+ They perform the operation, then put the result back on the stack.
456+
457+ In-place operations are like binary operations, but the operation is done in-place
455458when TOS1 supports it, and the resulting TOS may be (but does not have to be)
456459the original TOS1.
457460
@@ -460,6 +463,7 @@ the original TOS1.
460463
461464 Implements the binary and in-place operators (depending on the value of
462465 *op *).
466+ ``TOS = TOS1 op TOS ``.
463467
464468 .. versionadded :: 3.11
465469
@@ -479,6 +483,20 @@ the original TOS1.
479483 Implements ``del TOS1[TOS] ``.
480484
481485
486+ .. opcode :: BINARY_SLICE
487+
488+ Implements ``TOS = TOS2[TOS1:TOS] ``.
489+
490+ .. versionadded :: 3.12
491+
492+
493+ .. opcode :: STORE_SLICE
494+
495+ Implements ``TOS2[TOS1:TOS] = TOS3 ``.
496+
497+ .. versionadded :: 3.12
498+
499+
482500**Coroutine opcodes **
483501
484502.. opcode :: GET_AWAITABLE (where)
@@ -1333,13 +1351,74 @@ iterations of the loop.
13331351.. opcode :: HAVE_ARGUMENT
13341352
13351353 This is not really an opcode. It identifies the dividing line between
1336- opcodes which don't use their argument and those that do
1337- (``< HAVE_ARGUMENT `` and ``>= HAVE_ARGUMENT ``, respectively).
1354+ opcodes in the range [0,255] which don't use their argument and those
1355+ that do (``< HAVE_ARGUMENT `` and ``>= HAVE_ARGUMENT ``, respectively).
1356+
1357+ If your application uses pseudo instructions, use the :data: `hasarg `
1358+ collection instead.
13381359
13391360 .. versionchanged :: 3.6
13401361 Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT ``
13411362 ignore it. Before, only opcodes ``>= HAVE_ARGUMENT `` had an argument.
13421363
1364+ .. versionchanged :: 3.12
1365+ Pseudo instructions were added to the :mod: `dis ` module, and for them
1366+ it is not true that comparison with ``HAVE_ARGUMENT `` indicates whether
1367+ they use their arg.
1368+
1369+
1370+ **Pseudo-instructions **
1371+
1372+ These opcodes do not appear in python bytecode, they are used by the compiler
1373+ but are replaced by real opcodes or removed before bytecode is generated.
1374+
1375+ .. opcode :: SETUP_FINALLY (target)
1376+
1377+ Set up an exception handler for the following code block. If an exception
1378+ occurs, the value stack level is restored to its current state and control
1379+ is transferred to the exception handler at ``target ``.
1380+
1381+
1382+ .. opcode :: SETUP_CLEANUP (target)
1383+
1384+ Like ``SETUP_FINALLY ``, but in case of exception also pushes the last
1385+ instruction (``lasti ``) to the stack so that ``RERAISE `` can restore it.
1386+ If an exception occurs, the value stack level and the last instruction on
1387+ the frame are restored to their current state, and control is transferred
1388+ to the exception handler at ``target ``.
1389+
1390+
1391+ .. opcode :: SETUP_WITH (target)
1392+
1393+ Like ``SETUP_CLEANUP ``, but in case of exception one more item is popped
1394+ from the stack before control is transferred to the exception handler at
1395+ ``target ``.
1396+
1397+ This variant is used in :keyword: `with ` and :keyword: `async with `
1398+ constructs, which push the return value of the context manager's
1399+ :meth: `~object.__enter__ ` or :meth: `~object.__aenter__ ` to the stack.
1400+
1401+
1402+ .. opcode :: POP_BLOCK
1403+
1404+ Marks the end of the code block associated with the last ``SETUP_FINALLY ``,
1405+ ``SETUP_CLEANUP `` or ``SETUP_WITH ``.
1406+
1407+ .. opcode :: JUMP
1408+ .. opcode :: JUMP_NO_INTERRUPT
1409+ .. opcode :: POP_JUMP_IF_FALSE
1410+ .. opcode :: POP_JUMP_IF_TRUE
1411+ .. opcode :: POP_JUMP_IF_NONE
1412+ .. opcode :: POP_JUMP_IF_NOT_NONE
1413+
1414+ Undirected relative jump instructions which are replaced by their
1415+ directed (forward/backward) counterparts by the assembler.
1416+
1417+ .. opcode :: LOAD_METHOD
1418+
1419+ Optimized unbound method lookup. Emitted as a ``LOAD_ATTR `` opcode
1420+ with a flag set in the arg.
1421+
13431422
13441423.. _opcode_collections :
13451424
@@ -1349,6 +1428,10 @@ Opcode collections
13491428These collections are provided for automatic introspection of bytecode
13501429instructions:
13511430
1431+ .. versionchanged :: 3.12
1432+ The collections now contain pseudo instructions as well. These are
1433+ opcodes with values ``>= MIN_PSEUDO_OPCODE ``.
1434+
13521435.. data :: opname
13531436
13541437 Sequence of operation names, indexable using the bytecode.
@@ -1364,6 +1447,13 @@ instructions:
13641447 Sequence of all compare operation names.
13651448
13661449
1450+ .. data :: hasarg
1451+
1452+ Sequence of bytecodes that use their argument.
1453+
1454+ .. versionadded :: 3.12
1455+
1456+
13671457.. data :: hasconst
13681458
13691459 Sequence of bytecodes that access a constant.
@@ -1400,3 +1490,9 @@ instructions:
14001490.. data :: hascompare
14011491
14021492 Sequence of bytecodes of Boolean operations.
1493+
1494+ .. data :: hasexc
1495+
1496+ Sequence of bytecodes that set an exception handler.
1497+
1498+ .. versionadded :: 3.12
0 commit comments