Skip to content

Copying default values from configspec changes encoding #86

@dryo

Description

@dryo

When specifying an encoding for a config file with a configspec applying the configspec to copy the default values will change the encoding of the config file.

Here is the python snippet that shows the problem:

from configobj import ConfigObj
from validate import Validator

configspec = '''
    version = float
'''.splitlines()

config = ConfigObj(configspec=configspec,
                   encoding='utf8')

# verify that encoding is set correctly:
print(config.encoding)  # will return 'utf8', correct


# apply configspec while copying default values
config.validate(Validator(), copy=True)

# again verify that encoding is set correctly:
print(config.encoding)  # will return 'None', incorrect

To get around this you have to create the configspec as a distinct ConfigObject object specifying its encoding and hand it over to the real ConfigObj.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions