Title: ConfigParser.items returns items present in vars
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, serhiy.storchaka, terry.reedy, timster
Priority: normal Keywords: patch

Created on 2018-04-09 20:04 by timster, last changed 2018-04-23 20:56 by lukasz.langa.

Pull Requests
URL Status Linked Edit
PR 6446 merged chrBrd, 2018-04-10 19:18
PR 6494 merged lukasz.langa, 2018-04-17 02:47
PR 6495 merged miss-islington, 2018-04-17 03:04
PR 6496 merged miss-islington, 2018-04-17 03:04
PR 6567 closed chrBrd, 2018-04-22 21:13
PR 6583 merged chrBrd, 2018-04-23 20:22
Messages (7)
msg315148 - (view) Author: Tim Shaffer (timster) Date: 2018-04-09 20:04
The documentation for ConfigParser.items(section, raw=False, vars=None) says the following:

> Changed in version 3.2: Items present in vars no longer appear in the result. The previous behaviour mixed actual parser options with variables provided for interpolation.

However, this does not seem to be the case. The keys from vars are present in the output. Tested on 3.6.5.

This example shows the issue:

    import configparser

    config = configparser.ConfigParser()

    config.set('example', 'name', 'timster %(suffix)s')

    data = config.items('example', vars={'suffix': 'user'})


Expected output:

    [('name', 'timster user')]

Actual output:

    [('name', 'timster user'), ('suffix', 'user')]
msg315374 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-17 02:36
Hm. The documentation change was done in issue12036 but it seems this was actually never the case, contrary to what the conversation on that other issue there states.

I wouldn't change it for 3.6.6 anymore since it's pretty late in the release cycle.  This looks like an interesting bug fix for 3.7.
msg315375 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-17 02:40
Well, now that I think about it, this is not even a *bug* fix since it's behavior that configparser had since 1997.

So that will have to go straight to 3.8.
msg315390 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-17 10:29
What *actually* was changed in 3.2?
msg315628 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-22 21:37
> What *actually* was changed in 3.2?

In terms of this issue, nothing.  That piece of documentation was put without proper testing, based purely on a comment that somebody put on issue12036.  My mistake.
msg315673 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-23 19:16
New changeset 1d4a733cceee237f0850b7887c2945dee707da27 by Łukasz Langa (Chris Bradbury) in branch 'master':
bpo-33251: Prevent ConfigParser.items returning items present in vars. (#6446)
msg315679 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-23 20:56
New changeset e500839796c7fa43998e72edb77165872b9ce034 by Łukasz Langa (Chris Bradbury) in branch 'master':
bpo-33251: Update documentation to reflect change. (GH-6446) (#6583)
Date User Action Args
2018-04-23 20:56:49lukasz.langasetmessages: + msg315679
2018-04-23 20:22:45chrBrdsetpull_requests: + pull_request6283
2018-04-23 19:16:23lukasz.langasetmessages: + msg315673
2018-04-22 21:37:43lukasz.langasetmessages: + msg315628
2018-04-22 21:13:47chrBrdsetpull_requests: + pull_request6264
2018-04-17 10:29:13serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg315390
2018-04-17 03:04:22miss-islingtonsetpull_requests: + pull_request6193
2018-04-17 03:04:17miss-islingtonsetpull_requests: + pull_request6192
2018-04-17 02:47:13lukasz.langasetpull_requests: + pull_request6191
2018-04-17 02:40:00lukasz.langasetmessages: + msg315375
versions: + Python 3.8, - Python 3.6
2018-04-17 02:36:25lukasz.langasetmessages: + msg315374
2018-04-13 19:50:39terry.reedysetnosy: + terry.reedy
2018-04-10 19:18:54chrBrdsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6141
2018-04-10 14:37:05ned.deilysetnosy: + lukasz.langa
2018-04-09 20:10:13timstersettype: behavior
2018-04-09 20:04:26timstercreate