Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,10 @@ All of the following opcodes use their arguments.

.. versionadded:: 3.1

.. opcode:: JUMP_IF_NOT_EG_MATCH (target)

TODO: add doc

.. opcode:: JUMP_IF_NOT_EXC_MATCH (target)

Tests whether the second value on the stack is an exception matching TOS,
Expand Down
9 changes: 7 additions & 2 deletions Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,17 @@ with_item[withitem_ty]:
| e=expression { _Py_withitem(e, NULL, p->arena) }

try_stmt[stmt_ty]:
| 'try' ':' b=block f=finally_block { _Py_Try(b, NULL, NULL, f, EXTRA) }
| 'try' ':' b=block ex[asdl_excepthandler_seq*]=except_block+ el=[else_block] f=[finally_block] { _Py_Try(b, ex, el, f, EXTRA) }
| 'try' ':' b=block f=finally_block { _Py_Try(b, NULL, NULL, f, 0, EXTRA) }
| 'try' ':' b=block ex[asdl_excepthandler_seq*]=except_block+ el=[else_block] f=[finally_block] { _Py_Try(b, ex, el, f, 0, EXTRA) }
| 'try' ':' b=block ex[asdl_excepthandler_seq*]=except_star_block+ el=[else_block] f=[finally_block] { _Py_Try(b, ex, el, f, 1, EXTRA) }
except_block[excepthandler_ty]:
| 'except' e=expression t=['as' z=NAME { z }] ':' b=block {
_Py_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
| 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) }
except_star_block[excepthandler_ty]:
| 'except' '*' e=expression t=['as' z=NAME { z }] ':' b=block {
_Py_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
| 'except' '*' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) }
finally_block[asdl_stmt_seq*]: 'finally' ':' a=block { a }

return_stmt[stmt_ty]:
Expand Down
9 changes: 5 additions & 4 deletions Include/Python-ast.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Include/cpython/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ typedef struct {
PyObject *print_file_and_line;
} PySyntaxErrorObject;

typedef struct {
PyException_HEAD
PyObject *msg;
PyObject *excs;
} PyExceptionGroupObject;

typedef struct {
PyException_HEAD
PyObject *msg;
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ struct ast_state {
PyObject *right;
PyObject *simple;
PyObject *slice;
PyObject *star;
PyObject *step;
PyObject *stmt_type;
PyObject *tag;
Expand Down
3 changes: 2 additions & 1 deletion Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Include/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ PyAPI_DATA(PyObject *) PyExc_BufferError;
PyAPI_DATA(PyObject *) PyExc_EOFError;
PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
PyAPI_DATA(PyObject *) PyExc_OSError;
PyAPI_DATA(PyObject *) PyExc_ExceptionGroup;
PyAPI_DATA(PyObject *) PyExc_ImportError;
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError;
Expand Down
3 changes: 3 additions & 0 deletions Include/traceback.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extern "C" {
PyAPI_FUNC(int) PyTraceBack_Here(PyFrameObject *);
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);

int PyTraceBack_Print_Indented(PyObject *, PyObject *, int);
int _Py_WriteIndent(int, PyObject *);

/* Reveal traceback type so we can typecheck traceback objects */
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
#define PyTraceBack_Check(v) Py_IS_TYPE(v, &PyTraceBack_Type)
Expand Down
2 changes: 1 addition & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3432).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3433).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

_PYCACHE = '__pycache__'
Expand Down
1 change: 1 addition & 0 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def jabs_op(name, op):
def_op('IS_OP', 117)
def_op('CONTAINS_OP', 118)

jabs_op('JUMP_IF_NOT_EG_MATCH', 120)
jabs_op('JUMP_IF_NOT_EXC_MATCH', 121)
jrel_op('SETUP_FINALLY', 122) # Distance to target address

Expand Down
1 change: 1 addition & 0 deletions Lib/test/exception_hierarchy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- ExceptionGroup
+-- Exception
+-- StopIteration
+-- StopAsyncIteration
Expand Down
Loading