-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
gh-127011: Add __str__ and __repr__ to ConfigParser #127014
base: main
Are you sure you want to change the base?
Conversation
Agent-Hellboy
commented
Nov 19, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Add __str__ and __repr__ to ConfigParser for Better Debugging and Unit Testing #127011
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a NEWS entry and tests.
@@ -1040,6 +1042,33 @@ def __iter__(self): | |||
# XXX does it break when underlying container state changed? | |||
return itertools.chain((self.default_section,), self._sections.keys()) | |||
|
|||
def __str__(self): | |||
config_dict = { | |||
section: dict(self.items(section)) for section in self.sections() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This performs interpolations on all of the values, which can raise InterpolationError
(or other arbitrary exceptions, depending on what interpolation
class was specified). I think generally __str__
should be "safe" and not perform operations that can fail unexpectedly