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

bpo-33165: Remove redundant stack unwind for findCaller() #17714

Open
wants to merge 2 commits into
base: master
from

Conversation

@evandrocoan
Copy link

evandrocoan commented Dec 27, 2019

by directly getting the right frame on Lib/logging/init.py:currentframe()

This is a slight improvement for #7424 (bpo-33165: Added stacklevel parameter to logging APIs)

Instead of getting the fullstack trace and only then unwind the desired frames, just pass the required frame index and get it directly, i.e., without "unstacking" n frames.

I also added the frame level as a Logger attribute because when extending the default Logger and implementing/specializing the _log function, all stacktraces need to be increased by 1. For example, the debug_tools pypi module inherits from Logger and defines its own _log() function:
https://github.com/evandrocoan/debugtools/blob/d279bf3278f501294a72159f3aa189b7237528b2/all/debug_tools/logger.py#L166
https://github.com/evandrocoan/debugtools/blob/d279bf3278f501294a72159f3aa189b7237528b2/all/debug_tools/logger.py#L970
https://github.com/evandrocoan/debugtools/blob/d279bf3278f501294a72159f3aa189b7237528b2/all/debug_tools/logger.py#L1317

https://bugs.python.org/issue33165

@evandrocoan evandrocoan requested a review from vsajip as a code owner Dec 27, 2019
evandrocoan added a commit to evandrocoan/debugtools that referenced this pull request Dec 27, 2019
bpo-33165: Remove redundant stack unwind for findCaller()
python/cpython#17714
evandrocoan added a commit to evandrocoan/debugtools that referenced this pull request Dec 27, 2019
bpo-33165: Remove redundant stack unwind for findCaller()
python/cpython#17714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.