[issue41500] InterpolationSyntaxError reading the (windows) environment with unresolved environment variables

2020-08-09 Thread Pauser


Pauser  added the comment:

Thanks a lot for the fast response ... did not expect this ;)
I have looked into many threads and I will try to implement my own 
interpolation to use the current basic interpolation and process the current 
environment.

So thanks a lot, stay healthy and have a nice day!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41500] InterpolationSyntaxError reading the (windows) environment with unresolved environment variables

2020-08-07 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

There's multiple options:

1. Escape '%' in environment variables (%%not_existing%%) to avoid the exception

2. Switch to configparser.ExtendedInterpolation for the interpolation, which 
uses a different syntax that doesn't conflict with env. variables on Windows 
(but does conflict with that on Unix)

Note that regardless of the option ConfigParser will not expand the value of 
the environment variable reference. If you want to be able to interpolate env 
variables you need a different solution, for example by using the 'defaults' 
argument to ConfigParser and expand references using the ConfigParser 
interpolation syntax.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41500] InterpolationSyntaxError reading the (windows) environment with unresolved environment variables

2020-08-07 Thread Pauser


Pauser  added the comment:

So I have to use two config parser objects to merge the configuration of one 
config.ini (needs interpolation) and the environment on windows ?

So at the end choose wether to use environment variables or config parser 
interpolation, right? (only on windows) 

Not the solution I was looking for.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41500] InterpolationSyntaxError reading the (windows) environment with unresolved environment variables

2020-08-07 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

The exception is due to the interpolation feature of ConfigParser, which 
expects a different syntax. The default interpolation syntax is "%(key)s".

Interpolation can be turned off by passing "interpolation=None" when creating 
the ConfigParser object.

See also 
https://docs.python.org/3/library/configparser.html#interpolation-of-values

--
nosy: +ronaldoussoren
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41500] InterpolationSyntaxError reading the (windows) environment with unresolved environment variables

2020-08-07 Thread Pauser


New submission from Pauser :

Hello,
I tried to extend our config processing using the environment variables and the 
configparser module. 

On some machines (all windows) the configparser failed with an 
InterpolationSyntaxError ...
It seems that not resolved environment variables (e.g. "test":"%not_existing%") 
lead to this error.
I wrote little python test file reproducing the error and providing a very 
simple workaround to not fix all environments ;) Attention the bug is 
reproduced but the test is green ^^

I would be happy to remove the workaround as soon as possible ;)

--
components: Library (Lib)
files: test_EnvironmentProcessing.py
messages: 374991
nosy: c_panser, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: InterpolationSyntaxError reading the (windows) environment with 
unresolved environment variables
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49375/test_EnvironmentProcessing.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com