[issue25243] decouple string-to-boolean logic from ConfigParser.getboolean and offer as separate function

Joshua Bronson report at bugs.python.org
Sun Nov 1 18:50:21 EST 2015


Joshua Bronson added the comment:

My friend @novalis_dt and I worked up a patch for this including tests (attached). First time working with the CPython codebase but hope it's a reasonable start.

Here's a preview:

~> ./python.exe                                                                                                                                                              Python 3.6.0a0 (default:9f8b5053e30d+, Nov  1 2015, 18:38:37)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> trues = ['true', 'yes', 'on', '1']
>>> [bool.from_config_str(i) for i in trues]
[True, True, True, True]
>>> falses = ['false', 'no', 'off', '0', '']
>>> [bool.from_config_str(i) for i in falses]
[False, False, False, False, False]


I would be happy to try to make any additional changes necessary (including changing ConfigParser.getboolean to use the new method) if there is interest.

Thanks!

----------
keywords: +patch
nosy: +novalis_dt
Added file: http://bugs.python.org/file40923/bool_from_config_str.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25243>
_______________________________________


More information about the Python-bugs-list mailing list