Skip to content
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

Misleading variable name in exception handling #71032

Closed
progval mannequin opened this issue Apr 25, 2016 · 3 comments
Closed

Misleading variable name in exception handling #71032

progval mannequin opened this issue Apr 25, 2016 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@progval
Copy link
Mannequin

progval mannequin commented Apr 25, 2016

BPO 26845
Nosy @vstinner, @progval, @isidentical

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-12-20.19:10:58.923>
created_at = <Date 2016-04-25.19:56:07.400>
labels = ['interpreter-core', 'invalid']
title = 'Misleading variable name in exception handling'
updated_at = <Date 2019-12-20.19:10:58.922>
user = 'https://github.com/ProgVal'

bugs.python.org fields:

activity = <Date 2019-12-20.19:10:58.922>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2019-12-20.19:10:58.923>
closer = 'vstinner'
components = ['Interpreter Core']
creation = <Date 2016-04-25.19:56:07.400>
creator = 'Valentin.Lorentz'
dependencies = []
files = []
hgrepos = []
issue_num = 26845
keywords = []
message_count = 3.0
messages = ['264198', '358716', '358728']
nosy_count = 3.0
nosy_names = ['vstinner', 'Valentin.Lorentz', 'BTaskaya']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue26845'
versions = ['Python 3.6']

@progval
Copy link
Mannequin Author

progval mannequin commented Apr 25, 2016

In Python/errors.c, PyErr_Restore is defined this way:

void
PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)

In Python/ceval.c, in the END_FINALLY case, it is called like this:

PyErr_Restore(status, exc, tb);

I believe “exc” should be renamed to “val”.

Indeed, END_FINALLY pops values from the stack like this:

PyObject *status = POP();
// ...
else if (PyExceptionClass_Check(status)) {
     PyObject *exc = POP();
     PyObject *tb = POP();
     PyErr_Restore(status, exc, tb);

And, they are pushed like this, in fast_block_end:

PUSH(tb);
PUSH(val);
PUSH(exc);

@progval progval mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 25, 2016
@isidentical
Copy link
Sponsor Member

I am not sure if calls like this constitutes a problem. By the way most of the things changed in Python/ceval.c including removal of END_FINALLY (bpo-33387) but calls to _PyErr_Restore is still there with that same arguments.

@vstinner
Copy link
Member

Variable names have no impact on the execution. Sometimes, it's called "exc", sometimes "val", sometimes "exc_val" :-) This issue is not a bug.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants