Closed lowell80 closed 5 years ago
This is BOM issue. BOM-UTF8. Most likely caused by parse_stream() vs parse_file(). Working on an alternative.
This needs a unit test!
Found another occurrence of this issue in 0.7.0 (230a0a7cf). The file
command reports this as:
UTF-8 Unicode (with BOM) text
This happens for merge and sort. (Though, depending on the python version you get two different errors:
Python 2:
Unhandled top-level exception. 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/Users/lalleman/Sandbox/ksconf/ksconf/__main__.py", line 155, in cli
return_code = args.funct(args)
File "ksconf/commands/__init__.py", line 364, in launch
return_code = self.run(args)
File "ksconf/commands/sort.py", line 111, in run
data = parse_conf(conf, profile=PARSECONF_STRICT)
File "ksconf/conf/parser.py", line 234, in parse_conf
return parse_conf_stream(stream, **profile)
File "ksconf/conf/parser.py", line 256, in parse_conf_stream
for section, entry in reader:
File "ksconf/conf/parser.py", line 118, in section_reader
line = line.rstrip("\r\n")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
Or in Python 3:
Error trying processing MYAPP/local/app.conf. Error: Unexpected entry:
Attempting to merge files written on a WIndows platform (CR/LF end-of-line) causes the merge to abort.
However,
ksconf check
of the same files says everything is fine. Weird:No ability to change the parsing profile from the CLI (strictness).
ksconf 0.5.2 (Build 157) Python: 3.6.5 (/Users/lalleman/.pyenv/versions/3.6.5/bin/python3.6) Git SHA1 fda4eecc committed on 2018-08-12