diff options
author | Zackery Spytz <zspytz@gmail.com> | 2019-08-25 09:44:09 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-25 09:44:09 (GMT) |
commit | ce6a070414ed1e1374d1e6212bfbff61b6d5d755 (patch) | |
tree | 55f9d0c54b98ad3c95e78a235668f6dbc314087b /Doc | |
parent | 8371799e300475c8f9f967e900816218d3500e5d (diff) | |
download | cpython-ce6a070414ed1e1374d1e6212bfbff61b6d5d755.zip cpython-ce6a070414ed1e1374d1e6212bfbff61b6d5d755.tar.gz cpython-ce6a070414ed1e1374d1e6212bfbff61b6d5d755.tar.bz2 |
bpo-34880: Add the LOAD_ASSERTION_ERROR opcode. (GH-15073)
Fix assert statement misbehavior if AssertionError is shadowed.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dis.rst | 8 | ||||
-rw-r--r-- | Doc/whatsnew/3.9.rst | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 4a20245..b5243d0 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -752,6 +752,14 @@ iterations of the loop. from the block stack. +.. opcode:: LOAD_ASSERTION_ERROR + + Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert` + statement. + + .. versionadded:: 3.9 + + .. opcode:: LOAD_BUILD_CLASS Pushes :func:`builtins.__build_class__` onto the stack. It is later called diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 10217f1..e20ae47 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -226,3 +226,12 @@ Changes in the Python API * The :mod:`venv` activation scripts no longer special-case when ``__VENV_PROMPT__`` is set to ``""``. + + +CPython bytecode changes +------------------------ + +* The :opcode:`LOAD_ASSERTION_ERROR` opcode was added for handling the + :keyword:`assert` statement. Previously, the assert statement would not work + correctly if the :exc:`AssertionError` exception was being shadowed. + (Contributed by Zackery Spytz in :issue:`34880`.) |