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.items(section) with allow_no_value returns empty strings
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Sean Robertson
Priority: normal Keywords:

Created on 2019-08-23 20:58 by Sean Robertson, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg350331 - (view) Author: Sean Robertson (Sean Robertson) Date: 2019-08-23 20:58
Hello and thanks for reading.

I've also experienced this in Python 3.7, and I believe it to be around since 3.2.

The allow_no_value option of ConfigParser allows None values when (de)serializing configuration files. Yet calling the "items(section)" method of a ConfigParser returns empty strings for values instead of None. See below for an MRE.

Thanks,
Sean

Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from configparser import ConfigParser
>>> a = ConfigParser(allow_no_value=True)
>>> a.add_section('foo')
>>> a.set('foo', 'bar')
>>> a.items('foo')
[('bar', '')]
>>> a.items('foo', raw=True)
[('bar', None)]
>>> a.get('foo', 'bar')
>>> list(a['foo'].items())
[('bar', None)]
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82113
2019-08-23 20:58:17Sean Robertsoncreate