-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
[doc] configparser: modifying default_section at runtime #71770
Comments
Modifying "default_section" in the configparser at runtime does not behave as described. The documentation says about default_section: When default_section is given, it specifies the name for the special section holding default values for other sections and interpolation purposes (normally named "DEFAULT"). This value can be retrieved and changed on runtime using the default_section instance attribute. So, if I modify default_section at runtime, the default values for other sections should then come from the new default_section. But this is not the case. Instead, the default-values still come from self._default, which was set by self._read. So, this is either a bug in the library or a bug in the documentation. I've attached a testcase. |
Verified/tested with Python 2.7.9, 3.2.6, 3.3.6, 3.4.2, 3.5.1. I've also attached an updated testcase, which now works in both Python 2 and Python 3. |
(removed Python 2.7, since default_section was not supported there) |
We use the versions field to indicate which versions it might get fixed in. Since this is not a security issue, that would be 3.5 and 3.6, if it doesn't affect 2.7. If we decide to make the code match the docs, it will probably only get fixed in 3.6, since it is a behavior change. |
Well, you *can* change the value at runtime as you are demonstrating in your script, but you are misunderstanding the effect this will have. It *won't* cause a reevaluation of an already parsed config file. Instead it will affect the writing of the parsed settings to a new config file. So maybe this hint could be repeated in the actual parameter description of https://docs.python.org/3/library/configparser.html#configparser-objects to avoid confusion, but I don't think there is a bug here. |
…ion (#31562) Co-authored-by: Hugo van Kemenade <[email protected]>
…t_section (pythonGH-31562) (cherry picked from commit 891236f) Co-authored-by: Stanley <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…t_section (pythonGH-31562) (cherry picked from commit 891236f) Co-authored-by: Stanley <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
Thanks, fixed via #31562 and backports to 3.11. |
…lt_section (GH-31562) (#109089) Co-authored-by: Stanley <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…lt_section (GH-31562) (#109088) gh-71770: Add more details on behavior of configparser's default_section (GH-31562) (cherry picked from commit 891236f) Co-authored-by: Stanley <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: