Fix Logger.__getattr__ infinite recursion#683
Draft
kmontemayor2-sc wants to merge 1 commit into
Draft
Conversation
Logger(logging.LoggerAdapter) stores the wrapped logger as self.logger,
but __getattr__ delegated to self._logger (nonexistent). Since
__getattr__ only fires on failed lookups, resolving self._logger
re-entered __getattr__("_logger") and recursed forever -> RecursionError.
This was dormant for the info/debug/... methods (defined directly on
LoggerAdapter) but fired on any other attribute access, making Logger
impossible to copy/deepcopy/pickle and turning undefined-attribute
access into a crash instead of a clean AttributeError.
Read logger straight from __dict__ (cannot re-enter __getattr__) and
raise AttributeError when it is not yet set. Add a regression test
covering undefined-attr, delegation, deepcopy, and pickle.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
/all_test |
Contributor
GiGL Automation@ 16:09:26UTC : 🔄 @ 17:39:08UTC : ✅ Workflow completed successfully. |
Contributor
GiGL Automation@ 16:09:26UTC : 🔄 @ 17:18:11UTC : ✅ Workflow completed successfully. |
Contributor
GiGL Automation@ 16:09:26UTC : 🔄 @ 16:11:27UTC : ✅ Workflow completed successfully. |
Contributor
GiGL Automation@ 16:09:28UTC : 🔄 @ 16:20:04UTC : ✅ Workflow completed successfully. |
Contributor
GiGL Automation@ 16:09:29UTC : 🔄 @ 17:45:29UTC : ✅ Workflow completed successfully. |
Contributor
GiGL Automation@ 16:09:31UTC : 🔄 @ 16:17:14UTC : ✅ Workflow completed successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Logger(logging.LoggerAdapter) stores the wrapped logger as self.logger, but getattr delegated to self._logger (nonexistent). Since getattr only fires on failed lookups, resolving self._logger re-entered getattr("_logger") and recursed forever -> RecursionError.
This was dormant for the info/debug/... methods (defined directly on LoggerAdapter) but fired on any other attribute access, making Logger impossible to copy/deepcopy/pickle and turning undefined-attribute access into a crash instead of a clean AttributeError.
Read logger straight from dict (cannot re-enter getattr) and raise AttributeError when it is not yet set. Add a regression test covering undefined-attr, delegation, deepcopy, and pickle.
Scope of work done
Where is the documentation for this feature?: N/A
Did you add automated tests or write a test plan?
Updated Changelog.md? NO
Ready for code review?: NO