[Python-bugs-list] [ python-Bugs-511737 ] ConfigParser bug/limitation

noreply@sourceforge.net noreply@sourceforge.net
Fri, 25 Oct 2002 14:52:15 -0700


Bugs item #511737, was opened at 2002-02-01 10:35
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=511737&group_id=5470

Category: Python Library
Group: Feature Request
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Loïc Lefort (loicl)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: ConfigParser bug/limitation

Initial Comment:
It is not possible to use '%' character in config
options in combination with $() substitution.
Example: Given this configuration file:

[DEFAULT]
option1=xxx
option2=%(option1)s/xxx

ok=%(option1)s/%%s
not_ok=%(option2)s/%%s

config.get('DEFAULT', 'ok') returns xxx/%s
but config.get('DEFAULT', 'not_ok') fails with an
exception because the '%' needs to be escaped multiple
times depending on the evaluation depth:

%(option2)s/%%s -> %(option1)s/xxx/%s -> exception

what I would like it to do is:
%(option2)s/%%s -> %(option1)s/xxx/%%s -> xxx/xxx/%s

Attached to this bug report is a simple patch to work
around this limitation (not very elegant, but it works)



----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-10-25 17:52

Message:
Logged In: YES 
user_id=3066

I've added the SafeConfigParser class for Python 2.3.  This
version implements a safer (and more predictable)
interpolation.  This can't replace the original ConfigParser
since the behavior is different, but should be preferred for
new applications.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-06-21 12:18

Message:
Logged In: YES 
user_id=3066

Re-arranged summary so all ConfigParser reports can be
sorted together.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-06-17 11:19

Message:
Logged In: YES 
user_id=3066

I'm afraid getting this "right" is going to be much more
tedious that the proposed patch.  It's unclear to me at the
moment whether this should be a documented limitation or if
we should really fix it.  The ConfigParser module is
generally in bad shape, unfortunately.  ;-(

----------------------------------------------------------------------

Comment By: Loïc Lefort (loicl)
Date: 2002-02-01 10:38

Message:
Logged In: YES 
user_id=78862

Forgot the python version: this problem is present in both
python 2.1.2 and python 2.2

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=511737&group_id=5470