Fixed RecursionError caused by giving config_from_object nested mod…#8619
Merged
auvipy merged 2 commits intocelery:mainfrom Nov 8, 2023
Merged
Fixed RecursionError caused by giving config_from_object nested mod…#8619auvipy merged 2 commits intocelery:mainfrom
config_from_object nested mod…#8619auvipy merged 2 commits intocelery:mainfrom
Conversation
…ule that does not exist (celery#8517)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8619 +/- ##
==========================================
+ Coverage 87.32% 87.33% +0.01%
==========================================
Files 148 148
Lines 18512 18515 +3
Branches 3163 3163
==========================================
+ Hits 16165 16170 +5
+ Misses 2062 2060 -2
Partials 285 285
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Nusnus
reviewed
Nov 7, 2023
Member
Nusnus
left a comment
There was a problem hiding this comment.
Nice work!
Check out my comment
| with pytest.raises(ModuleNotFoundError) as exc: | ||
| self.app.config_from_object(f'{__name__}.bar') | ||
| # the module must exist, but it should not have the config attr | ||
| assert self.app.conf.broker_url is None |
Member
There was a problem hiding this comment.
Shouldn't this and the next assertion be outside the with scope?
Nusnus
reviewed
Nov 7, 2023
Contributor
Author
|
Thank you very much, I've incorporated your feedback. |
auvipy
reviewed
Nov 8, 2023
Member
auvipy
left a comment
There was a problem hiding this comment.
seems better now. waiting for another round of review from Nusnus
auvipy
approved these changes
Nov 8, 2023
Nusnus
approved these changes
Nov 8, 2023
Member
Nusnus
left a comment
There was a problem hiding this comment.
Sorry for the delay, good work!
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.
Fixed RecursionError caused by giving
config_from_objectnested module that does not exist (#8517)Description
The problem is described by new unit test: t/unit/app/test_app.py::test_config_form_object__module_attr_does_not_exist
When you provide a string with valid module name but invalid submodule (attr) to
app.config_from_objectthe 3rd party utilkombu.utils.imports.symbol_by_namewould raiseAttributeErrorwhich would be "handled" byPendingConfiguration(UserDict)and would cause infinite recursion. This happens during the "lazy initialization" of theapp.confwhenapp.confattr is accessed.The fix is to catch
AttributeErrorand raiseModuleNotFoundErrorwhich would be propagated correctly and would provide the real error message to the end user.I don't feel very good re: this fix, I am new to this project, so your criticism is highly desired.