Skip to content

removed quotation marks if writing keys containing equal sign and "less than" sign #273

@roe-dl

Description

@roe-dl

If a key contains an equal sign surrounded by a "less than" and "greater than" sign, then no quotation marks are written, resulting in an unreadable file.

Example configuration file test.conf:

"x <a='b'>" = c

Example script:

import configobj
config = configobj.ConfigObj("test.conf")
config.write()

If you run the script the first time, it changes the configuration file to:

x <a='b'> = c

If you run the same script another time, an exception is raised:

Traceback (most recent call last):
  File "/home/user/configtest.py", line 3, in <module>
    config = configobj.ConfigObj("test.conf")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 1228, in __init__
    self._load(infile, configspec)
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 1317, in _load
    raise error
configobj.ParseError: Parse error in value at line 1.

Note that the key in this example is shortened to show the issue, but not a real world example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions