From e3dcb01bfc6bd14da865b0f28c3c9ad8181ab212 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 6 May 2008 04:37:31 +0000 Subject: 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. --- Python/_warnings.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Python/_warnings.c') diff --git a/Python/_warnings.c b/Python/_warnings.c index 3e7dda7db8..0e48675d81 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -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; -- cgit v1.2.1