Skip to content

bpo-33504: Migrate configparser from OrderedDict to dict. #6819

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

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

amyreese
Copy link
Contributor

@amyreese amyreese commented May 14, 2018

With 3.7+, dictionary are ordered by design. Configparser still uses
collections.OrderedDict, which is unnecessary. This updates the module
to use the standard dict implementation by default, and changes the
docs and tests to match.

https://bugs.python.org/issue33504

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@@ -157,6 +157,7 @@
"LegacyInterpolation", "SectionProxy", "ConverterMapping",
"DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]

DEFAULT_DICT = dict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of introducing this variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit tests reach into configparser to use the default dict implementation, and I was unsure of whether it would be best practice to continue that behavior or just make the unit tests reference dict directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this back to _default_dict to keep the previous API.

@amyreese
Copy link
Contributor Author

Updated to retain _default_dict. Do I need to add a news entry for this change?

@amyreese
Copy link
Contributor Author

Added news entry.

@@ -445,7 +445,7 @@ the :meth:`__init__` options:
Hint: if you want to specify default values for a specific section, use
:meth:`read_dict` before you read the actual file.

* *dict_type*, default value: :class:`collections.OrderedDict`
* *dict_type*, default value: :class:`dict`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to reword the rest of this section. It suggests below that "you can also use a regular dictionary" (but we already are!) and that "When you use a regular dictionary in those operations, the order of the keys may be random." which is no longer true.

Would be good to change this to describe what is actually happening

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding .. versionchanged:: would be also nice.

@serhiy-storchaka
Copy link
Member

I don't think that the versionchanged directive and a news entry are needed if this type is not leaked to a user. It is just an implementation detail. The order of items is preserved, and it doesn't matter what data structure is used for satisfying this.

With 3.7+, dictionary are ordered by design.  Configparser still uses
collections.OrderedDict, which is unnecessary.  This updates the module
to use the standard dict implementation by default, and changes the
docs and tests to match.
@amyreese
Copy link
Contributor Author

Updated documentation.

@amyreese
Copy link
Contributor Author

Is there anything else I need to do, or is this ready to be merged?

@ambv ambv merged commit 3a5b0d8 into python:master Jun 5, 2018
@bedevere-bot
Copy link

@ambv: Please replace # with GH- in the commit message next time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants