Skip to content

bpo-45711: Remove type and traceback from exc_info #30122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
removed exc_type from stack
  • Loading branch information
iritkatriel committed Dec 15, 2021
commit c5c23bdb1ea02515925270956836982db17799e7
28 changes: 12 additions & 16 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,15 @@ the original TOS1.
.. opcode:: END_ASYNC_FOR

Terminates an :keyword:`async for` loop. Handles an exception raised
when awaiting a next item. If TOS is :exc:`StopAsyncIteration` pop 5
when awaiting a next item. If TOS is :exc:`StopAsyncIteration` pop 3
values from the stack and restore the exception state using the second
two of them. Otherwise re-raise the exception using the two values
of them. Otherwise re-raise the exception using the value
from the stack. An exception handler block is removed from the block stack.

.. versionadded:: 3.8

.. versionchanged:: 3.11

Exception representation on the stack now consist of two, not three, items.
Exception representation on the stack now consist of one, not three, items.

.. opcode:: BEFORE_ASYNC_WITH

Expand Down Expand Up @@ -564,11 +563,10 @@ iterations of the loop.

.. opcode:: POP_EXCEPT

Pops two values from the stack, which are used to restore the exception state.
Pops a value from the stack, which is used to restore the exception state.

.. versionchanged:: 3.11

Exception representation on the stack now consist of two, not three, items.
Exception representation on the stack now consist of one, not three, items.

.. opcode:: RERAISE

Expand All @@ -579,23 +577,21 @@ iterations of the loop.
.. versionadded:: 3.9

.. versionchanged:: 3.11

Exception representation on the stack now consist of two, not three, items.
Exception representation on the stack now consist of one, not three, items.

.. opcode:: PUSH_EXC_INFO

Pops two values from the stack. Pushes the current exception to the top of the stack.
Pushes the two values originally popped back to the stack.
Pops a value from the stack. Pushes the current exception to the top of the stack.
Pushes the value originally popped back to the stack.
Used in exception handlers.

.. versionadded:: 3.11


.. opcode:: WITH_EXCEPT_START

Calls the function in position 6 on the stack with the top two
items on the stack, as well as a traceback derived from the second item,
as arguments.
Calls the function in position 4 on the stack with arguments (type, val, tb)
representing the exception at the top of the stack.
Used to implement the call ``context_manager.__exit__(*exc_info())`` when an exception
has occurred in a :keyword:`with` statement.

Expand All @@ -604,8 +600,8 @@ iterations of the loop.
The ``__exit__`` function is in position 8 of the stack rather than 7.

.. versionchanged:: 3.11

Exception representation on the stack now consist of two, not three, items.
The ``__exit__`` function is in position 4 of the stack rather than 7.
Exception representation on the stack now consist of one, not three, items.

.. opcode:: POP_EXCEPT_AND_RERAISE

Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalRefcountErrorFunc(


/* number of items stored in the stack for each exception */
#define PY_EXC_INFO_STACK_SIZE 2
#define PY_EXC_INFO_STACK_SIZE 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary now?
I don't see why we would ever want to increase it, and I don't see how we could ever decrease it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is probably weird now, but I think it helps readability to have a macro. If we remove this we should find another way to make the code (particularly in compile.c) clear about where exceptions are showing up. Figuring out where to use this macro was the hardest part of making this change (because when you get it wrong it just segfaults before you finish make regen-all).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought there is no point in a macro for this unless we all agree on some kind of convention because it probably won't be updated correctly when people make changes. So I'll remove it.


#ifdef __cplusplus
}
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 @@ -382,7 +382,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 = (3466).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3467).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

_PYCACHE = '__pycache__'
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy