This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ConfigParser does not accept "No value" reversely to the doc
Type: behavior Stage: resolved
Components: Demos and Tools, Documentation, Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, lukasz.langa, miss-islington, pablogsal, sbougnoux, sobolevn
Priority: normal Keywords: patch

Created on 2021-09-16 08:51 by sbougnoux, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28396 merged sobolevn, 2021-09-16 19:48
PR 28416 merged miss-islington, 2021-09-17 10:56
PR 28418 merged miss-islington, 2021-09-17 11:40
Messages (9)
msg401932 - (view) Author: (sbougnoux) Date: 2021-09-16 08:51
Just the simple following config crashes

"""
[Bug]
Here
"""

Hopefully using "Here=" solves the issue, but the doc claims it shall work.
https://docs.python.org/3.8/library/configparser.html?highlight=configparser#supported-ini-file-structure

Save the config in "bug.ini", then write (it will raise an exception)
"""
from configparser import ConfigParser
ConfigParser().read('bug.ini')
"""
msg401983 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2021-09-16 19:28
Try this:

```
from configparser import ConfigParser
ConfigParser(allow_no_value=True).read('bug.ini')
```

It should work! :)

But, the docs are missing this config value here (which caused this issue):

> Values can be omitted, in which case the key/value delimiter may also be left out.

https://github.com/python/cpython/blame/f4b94b1f57827083990272b5f282aa1493ae2bf4/Doc/library/configparser.rst#L264

I will update the docs.
msg402005 - (view) Author: (sbougnoux) Date: 2021-09-17 07:18
Thanks for your prompt answer. Don't you think it should be the default? It seems like unneeded precision. Just if you want to check one don't miss a value, but in that case, one can use 'allow_no_value=False'.
msg402026 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-17 10:03
No, it shouldn't be the default. It never was before (this is a library that we've maintained for 20+ years now) and changing it now would mean that existing applications would stop validating their configuration in the way they did up to now.

.ini files are unfortunately very imprecisely specified but they are *mostly* interoperable between applications. Changing defaults at this point is therefore out of the question.
msg402036 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-17 10:55
New changeset cb07838ab756564988b1ffd23871f1222a832446 by Nikita Sobolev in branch 'main':
bpo-45217: adds note that `allow_no_value` in `configparser` is optional (GH-28396)
https://github.com/python/cpython/commit/cb07838ab756564988b1ffd23871f1222a832446
msg402039 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-17 11:41
New changeset 3ea1c4b66887e7ca920db487f6ffc5f1db3c873f by Miss Islington (bot) in branch '3.9':
bpo-45217: adds note that `allow_no_value` in `configparser` is optional (GH-28396) (GH-28416)
https://github.com/python/cpython/commit/3ea1c4b66887e7ca920db487f6ffc5f1db3c873f
msg402049 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-17 13:10
New changeset a10726d3141d8f52a108c4daf70eefa29401e2fc by Miss Islington (bot) in branch '3.10':
bpo-45217: adds note that `allow_no_value` in `configparser` is optional (GH-28396) (GH-28418)
https://github.com/python/cpython/commit/a10726d3141d8f52a108c4daf70eefa29401e2fc
msg402050 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-17 13:11
Thanks for the patch, Nikita! ✨ 🍰 ✨
msg403150 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-04 19:18
New changeset c4e9ef1f1d3bb7aca09f3ac6691a78d1341d7fcb by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-45217: adds note that `allow_no_value` in `configparser` is optional (GH-28396) (GH-28418)
https://github.com/python/cpython/commit/c4e9ef1f1d3bb7aca09f3ac6691a78d1341d7fcb
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89380
2021-10-04 19:18:41pablogsalsetnosy: + pablogsal
messages: + msg403150
2021-09-17 13:11:28lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg402050

stage: patch review -> resolved
2021-09-17 13:10:35lukasz.langasetmessages: + msg402049
2021-09-17 11:41:29lukasz.langasetmessages: + msg402039
2021-09-17 11:40:43miss-islingtonsetpull_requests: + pull_request26828
2021-09-17 10:56:03miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26827
2021-09-17 10:55:55lukasz.langasetmessages: + msg402036
2021-09-17 10:03:27lukasz.langasetnosy: + lukasz.langa
messages: + msg402026
2021-09-17 07:18:04sbougnouxsetmessages: + msg402005
2021-09-16 19:48:09sobolevnsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26809
2021-09-16 19:28:12sobolevnsetnosy: + sobolevn
messages: + msg401983
2021-09-16 08:51:18sbougnouxcreate