This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SafeConfigParser incorrectly detects lone percent signs
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, marcio
Priority: normal Keywords:

Created on 2009-04-12 12:35 by marcio, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg85899 - (view) Author: Márcio (marcio) Date: 2009-04-12 12:35
The SafeConfigParser class incorrectly detects lone percent signs,
for example, it doesn't accept "100%%" as a valid value. The cause of 
this is the "_badpercent_re" regular expression:
- The first alternative "%[^%]" fails with the string "%%_", because it 
matches "%_".
- The second alternative "%$" fails with the string "%%", because it 
matches "%".

---

from ConfigParser import *
SafeConfigParser().set('DEFAULT', 'test', '100%%')
msg85911 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-12 17:24
Should be fixed in r71537. Will backport to 2.6.
msg85941 - (view) Author: Márcio (marcio) Date: 2009-04-13 11:43
Shouldn't the "replace('%%', '')" take place before 
"_interpvar_re.sub"? For example, the value "%%(test)s" should be 
accepted as valid but it isn't because "_interpvar_re" has already 
changed it to "%".
msg85942 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-13 12:36
You're right, of course. Fixed in r71564.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49991
2009-04-13 12:36:43georg.brandlsetmessages: + msg85942
2009-04-13 11:43:02marciosetmessages: + msg85941
2009-04-12 17:24:31georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg85911

resolution: fixed
2009-04-12 12:35:09marciocreate