[issue37932] ConfigParser.items(section) with allow_no_value returns empty strings

Sean Robertson report at bugs.python.org
Fri Aug 23 16:58:17 EDT 2019


New submission from Sean Robertson <sdrobert at cs.toronto.edu>:

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)]

----------
components: Library (Lib)
messages: 350331
nosy: Sean Robertson
priority: normal
severity: normal
status: open
title: ConfigParser.items(section) with allow_no_value returns empty strings
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37932>
_______________________________________


More information about the Python-bugs-list mailing list