-
-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
traceback.walk_stack(None) does not behave the same as traceback.walk_stack(inspect.currentframe()) #96092
Comments
On main your code doesn't work at all:
I see that this function changed in
This part:
|
I am currently in release hell, @ammaraskar @isidentical can you take a look? |
Added details on the root cause here: #99015 (comment) It looks like if f is None:
f = sys._getframe().f_back.f_back is a bit misleading, those lines don't run when you call So if you do something like: def outer():
return inner()
def inner():
return traceback.walk_stack(None)
frames = outer()
def print_frames(f):
print(list(f))
print_frames(frames) You might expect it to print My intuition is we should fix |
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
Thanks for the link. That use case is fine too since the generator is iterated over immediately. People tend to either pass into |
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
* use sys.executable for python binary * pass the desired frame to traceback.walk_stack for 3.11 see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment) * the GC overhead now depends on _PyType_PreHeaderSize faster-cpython/ideas#125 python/cpython@8319114#diff-a3a5c73931235f7f344c072dc755d6508e13923db3f5d581c5e88652075871cbR1684 * GH-6785: asyncio.wait no longer calls ensure_future python/cpython#95601 * test on python 3.11 * exclude macos py 3.10
In Python 3.11 and later, `traceback.walk_stack(None)` skips more stack frames than in the past: python/cpython#96092
* service: Include TS code module dir in .env search * examples: Update teststand_nivisa_dmm.py to search for `.env` starting with the code module's parent directory * tests: Fix mypy errors and last-minute rename errors * service: Work around lack of PurePath.is_relative_to() in Python 3.8 * service: Make _get_nims_path return package dir, not __init__.py path * service: Fix _get_caller_path() with Python >= 3.11 In Python 3.11 and later, `traceback.walk_stack(None)` skips more stack frames than in the past: python/cpython#96092 * tests: Make pytest path check less specific
Bug report
traceback.walk_stack(None)
omits the calling frame, making it equivalent totraceback.walk_stack(inspect.currentframe().f_back)
. Given the documentation just says "If f is None, the current stack is used.", I would have expectedtraceback.walk_stack(None)
to be equivalent totraceback.walk_stack(inspect.currentframe())
.Example code
The following code
has as output
Note that the frame for
abc
is missing in the first and last line.Your environment
The text was updated successfully, but these errors were encountered: