mirror of
https://github.com/python/cpython.git
synced 2025-07-27 21:24:32 +00:00
Fix a bug in the handling of the stacklevel argument in warnings.warn() where
the stack was being unwound by two levels instead of one each time.
This commit is contained in:
parent
0b7f77847a
commit
e3dcb01bfc
2 changed files with 3 additions and 3 deletions
|
@ -445,10 +445,8 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
|
|||
|
||||
/* Setup globals and lineno. */
|
||||
PyFrameObject *f = PyThreadState_GET()->frame;
|
||||
while (--stack_level > 0 && f != NULL) {
|
||||
while (--stack_level > 0 && f != NULL)
|
||||
f = f->f_back;
|
||||
--stack_level;
|
||||
}
|
||||
|
||||
if (f == NULL) {
|
||||
globals = PyThreadState_Get()->interp->sysdict;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue