configfile: Workaround for non-ascii comments on Python2

Explicitly specify the comment_prefixes as regular Python2 strings -
otherwise the configparser wont ignore non-ascii characters in
comments.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-10-08 00:23:31 -04:00
parent 1a4d655a18
commit 5251bf23f1
1 changed files with 2 additions and 1 deletions

View File

@ -255,8 +255,9 @@ class PrinterConfig:
self._parse_config_buffer(buffer, filename, fileconfig) self._parse_config_buffer(buffer, filename, fileconfig)
visited.remove(path) visited.remove(path)
def _build_config_wrapper(self, data, filename): def _build_config_wrapper(self, data, filename):
cp = (';', '#')
fileconfig = configparser.RawConfigParser( fileconfig = configparser.RawConfigParser(
strict=False, inline_comment_prefixes=(';','#')) strict=False, comment_prefixes=cp, inline_comment_prefixes=cp)
self._parse_config(data, filename, fileconfig, set()) self._parse_config(data, filename, fileconfig, set())
return ConfigWrapper(self.printer, fileconfig, {}, 'printer') return ConfigWrapper(self.printer, fileconfig, {}, 'printer')
def _build_config_string(self, config): def _build_config_string(self, config):