Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-33165: Remove redundant stack unwind for findCaller() #17714
+5
−10
Conversation
the right frame on Lib/logging/__init__.py:currentframe()
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
evandrocoan commentedDec 27, 2019
•
edited by bedevere-bot
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