[issue27762] ConfigParser ignores in-line comments for lines with semi-colons
Joshua Haas
report at bugs.python.org
Sat Aug 13 22:42:48 EDT 2016
New submission from Joshua Haas:
According to the 2.7 docs at https://docs.python.org/2/library/configparser.html, you can create in-line comments using ";" if it is preceded by white space.
However, if the value of a config option contains a semi-colon, for example "password=my;pass123", then only the first colon will be checked by the parser.
In the config file:
password=my;pass123 ;expires in 2018
Expected value:
my;pass123
Returned value:
my;pass123 ;expires in 2018
This is easily remedied with a while loop, lines 525-529 in the attached patch. Otherwise the docs should be changed to reflect this behavior, but a patch definitely seems more appropriate to me. Python 3.5 gives the expected value when using inline_comment_prefixes=';'.
----------
components: Library (Lib)
files: ConfigParser_patch.py
messages: 272641
nosy: jahschwa
priority: normal
severity: normal
status: open
title: ConfigParser ignores in-line comments for lines with semi-colons
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file44101/ConfigParser_patch.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27762>
_______________________________________
More information about the Python-bugs-list
mailing list