Closed paljsingh closed 3 years ago
Hi, @paljsingh thanks for your issue.
I found that issue is related to how re.sub
works, more here
https://stackoverflow.com/questions/58328587/python-3-7-4-re-error-bad-escape-s-at-position-0
I'm in the process to find a solution for that.
@paljsingh please check with new version (1.8.210417)
Thanks @thesimj The latest version fixes the issue.
envyaml fails to load properties with env variables on Windows environment.
To reproduce:
test.py - from envyaml import EnvYAML config = EnvYAML('yaml.conf', strict=False) print(config['foo'])
yaml.conf - foo: $USERPROFILE/bar
$ python3.exe test.py Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\sre_parse.py", line 1039, in parse_template this = chr(ESCAPES[this][1]) KeyError: '\U'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\jpsjp\test.py", line 3, in
config = EnvYAML('yaml.conf', strict=False)
File "C:\Users\jpsjp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\envyaml\envyaml.py", line 114, in init
yaml_config = self.read_yaml_file(
File "C:\Users\jpsjp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\envyaml\envyaml.py", line 249, in read_yaml_file
content = re.sub(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64qbz5n2kfra8p0\lib\re.py", line 210, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64qbz5n2kfra8p0\lib\re.py", line 327, in _subx
template = _compile_repl(template, pattern)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64qbz5n2kfra8p0\lib\re.py", line 318, in _compile_repl
return sre_parse.parse_template(repl, pattern)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64qbz5n2kfra8p0\lib\sre_parse.py", line 1042, in parse_template
raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \U at position 2
Additional Details: OS: Windows 10
$ python3.exe --version Python 3.9.4
$ pip3.exe list Package Version
certifi 2020.12.5 chardet 4.0.0 envyaml 1.7.210310 idna 2.10 pycryptodome 3.10.1 PyYAML 5.4.1 requests 2.25.1 tk 0.1.0 tksheet 5.0.21 urllib3 1.26.4