You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Delimiters are substrings that delimit keys from values within a section. The first occurrence of a delimiting substring on a line is considered a delimiter. This means values (BUT NOT KEYS) can contain substrings that are in the delimiters".
(emphasis mine)
But as of today's 3.13, nothing stops the user from using delimiters in keys, writing them to a file and finally reading back something completely different. Reproduction:
importconfigparsercfg2file=configparser.ConfigParser()
cfg2file['section1'] = {}
# This should fail. It "succeeds".cfg2file['section1']['one=two'] ='three'# Write ambiguous 'one = two = three' line in the .ini filewithopen('example.ini', 'w') asconfigfile:
cfg2file.write(configfile)
# Read the file back. First equal sign wins.file2cfg=configparser.ConfigParser()
file2cfg.read('example.ini')
forkeyinfile2cfg['section1']:
print(key+' is: '+file2cfg['section1'][key] )
# Trueassertcfg2file['section1']['one=two'] =='three'# False!assertfile2cfg['section1']['one=two'] =='three'# This is True insteadassertfile2cfg['section1']['one'] =='two = three'
This happens when someone enters west config key=val ... instead of west config key val ...:
Bug report
Bug description:
Since very first commit 26d513c 15 years ago,
configparser.rst
has stated:https://docs.python.org/3.13/library/configparser.html#customizing-parser-behaviour
(emphasis mine)
But as of today's 3.13, nothing stops the user from using delimiters in keys, writing them to a file and finally reading back something completely different. Reproduction:
This happens when someone enters
west config key=val ...
instead ofwest config key val ...
:zephyrproject-rtos/west#779
CPython versions tested on:
3.13
Operating systems tested on:
Linux
cc: @jaraco
The text was updated successfully, but these errors were encountered: