From ce042deddabc824caefdcaaf97f3ab9654777a96 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Sun, 11 Oct 2015 22:45:26 -0600 Subject: Fix Python 3.5 support Python 3.5 inserts an extra stackframe when calling extract_traceback, this adds in a check to see if the last frame is this extra frame, and if so removes it. This doesn't affect any other version of Python. --- pyramid/util.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyramid/util.py b/pyramid/util.py index 1ae7e6afc..12eae3626 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -554,7 +554,14 @@ def action_method(wrapped): info = ActionInfo(*info) if info is None: try: - f = traceback.extract_stack(limit=3) + f = traceback.extract_stack(limit=4) + + # Work around a Python 3.5 issue whereby it would insert an + # extra stack frame. This should no longer be necessary in + # Python 3.5.1 + last_frame = ActionInfo(*f[-1]) + if last_frame.function == 'extract_stack': + f.pop() info = ActionInfo(*f[-backframes]) except: # pragma: no cover info = ActionInfo(None, 0, '', '') -- cgit v1.2.3