Closed lannuttia closed 6 months ago
The problem is likely due to implicit parsing of dates... and likely due to a change in pyparsing.
Here is an minimal example:
from pyhocon import ConfigFactory
val = ConfigFactory.parse_string("""
a {
y_min: 3
y_max: 42
}
""")
assert val
assert val["a"]
print(val)
assert "y_min" in val["a"].keys()
assert "y_max" in val["a"].keys()
assert val["a"]["y_min"] == 3
assert val["a"]["y_max"] == 42
0.3.59
, pyparsing==2.4.7Works as expected!
pip install pyparsing==2.4.7 pyhocon==0.3.59 >/dev/null 2>/dev/null && python3 test_hocon.py
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
0.3.60
, pyparsing==2.4.7Works as expected!
pip install pyparsing==2.4.7 pyhocon==0.3.49 >/dev/null 2>/dev/null && python3 test_hocon.py
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
for pyhocon in 0.3.60; do for pyparsing in 2.4.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2; do pip install pyparsing==$pyparsing pyhocon==$pyhocon >/dev/null 2>/dev/null && python test_hocon.py 2>/dev/null && echo " RESULT: OK for pyhocon=$pyhocon pyparsing=$pyparsing" || echo "ERROR RESULT FAILED for pyhocon=$pyhocon pyparsing=$pyparsing"; done; done
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=2.4.7
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.0
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.1
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.2
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.3
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.4
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.5
ConfigTree([('a', ConfigTree([('y_min', 3), ('y_max', 42)]))])
RESULT: OK for pyhocon=0.3.60 pyparsing=3.0.6
But, from pyparsing version=3.0.7 ... 3.1.2 (lastest as today 2024-05-21):
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.0.7
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.0.8
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.0.9
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.1.0
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.1.1
ConfigTree([('a', ConfigTree([('y_min', 'relativedelta(years=+3)_max: 42')]))])
ERROR RESULT FAILED for pyhocon=0.3.60 pyparsing=3.1.2
It fails from version 3.0.6 of pyparsing. Likely, we should block those revisions!
@lannuttia fix in https://github.com/chimpler/pyhocon/pull/326
@lannuttia I think it has been fixed in 0.3.61
I can confirm that the issue that I was seeing was resolved after updating to v0.3.61. I appreciate the help here!
@lannuttia Then, you might close the issue :-)
Alright, it's closed
In
0.3.59
, parsing the following would work fine.As of
0.3.60
, running that same script would result in the following exception being thrown.Interestingly enough, if I add a space in between the \n and the 'd', It parses without error again. I suspect that since the 'd' comes immediately after the newline, it is erroneously being interpreted as a control character but I don't really know.