Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaveConfigParser.write() doesn't quote %-Sign #44283

Closed
rbreu mannequin opened this issue Nov 27, 2006 · 4 comments
Closed

SaveConfigParser.write() doesn't quote %-Sign #44283

rbreu mannequin opened this issue Nov 27, 2006 · 4 comments
Labels
stdlib Python modules in the Lib dir

Comments

@rbreu
Copy link
Mannequin

rbreu mannequin commented Nov 27, 2006

BPO 1603688
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-01-16.20:50:44.000>
created_at = <Date 2006-11-27.12:15:17.000>
labels = ['library']
title = "SaveConfigParser.write() doesn't quote %-Sign"
updated_at = <Date 2007-01-16.20:50:44.000>
user = 'https://bugs.python.org/rbreu'

bugs.python.org fields:

activity = <Date 2007-01-16.20:50:44.000>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2006-11-27.12:15:17.000>
creator = 'rbreu'
dependencies = []
files = []
hgrepos = []
issue_num = 1603688
keywords = []
message_count = 4.0
messages = ['30695', '30696', '30697', '30698']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'mark-roberts', 'rbreu']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1603688'
versions = ['Python 2.4']

@rbreu
Copy link
Mannequin Author

rbreu mannequin commented Nov 27, 2006

>>> parser = ConfigParser.SafeConfigParser()
>>> parser.add_section("test")
>>> parser.set("test", "foo", "bar%bar")
>>> parser.write(open("test.config", "w"))
>>> parser2 = ConfigParser.SafeConfigParser()
>>> parser2.readfp(open("test.config"))
>>> parser.get("test", "foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/ConfigParser.py", line 525, in get
    return self._interpolate(section, option, value, d)
  File "/usr/lib/python2.4/ConfigParser.py", line 593, in _interpolate
    self._interpolate_some(option, L, rawval, section, vars, 1)
  File "/usr/lib/python2.4/ConfigParser.py", line 634, in _interpolate_some
    "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%bar'

Problem: SaveConfigParser saves the string "bar%bar" as is and not as "bar%%bar".

@rbreu rbreu mannequin closed this as completed Nov 27, 2006
@rbreu rbreu mannequin added the stdlib Python modules in the Lib dir label Nov 27, 2006
@rbreu rbreu mannequin closed this as completed Nov 27, 2006
@rbreu rbreu mannequin added the stdlib Python modules in the Lib dir label Nov 27, 2006
@mark-roberts
Copy link
Mannequin

mark-roberts mannequin commented Jan 15, 2007

I'm not sure that automagically changing their input is such a great idea. I'm -0 for automagically changing their input, but +1 for raising ValueError when the input contains a string that can't be properly interpolated. I've implemented the patch both ways. Anyone else have an opinion about this?

Examples of such malformatted strings include bar%bar and bar%.

@mark-roberts
Copy link
Mannequin

mark-roberts mannequin commented Jan 15, 2007

Initially, I believed ValueError was the appropriate way to go with this. However, when I thought about how I use ConfigParser, I realized that it would be far nicer if it simply worked.

See the patches in 1635639.
http://sourceforge.net/tracker/index.php?func=detail&aid=1635639&group_id=5470&atid=105470

Good catch on this. I haven't caught it and I've been using ConfigParser for a while now.

@birkenfeld
Copy link
Member

Closing this as a duplicate.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant