[Python-checkins] python/dist/src/Lib ConfigParser.py,1.63,1.64
fdrake at users.sourceforge.net
fdrake at users.sourceforge.net
Mon May 17 22:25:53 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1097/Lib
Modified Files:
ConfigParser.py
Log Message:
ConfigParser:
- ensure that option names in interpolations are handled by
self.optionxform in the same way that other references to option
names
- add tests, documentation
(closes SF bug #857881, patch #865455)
Index: ConfigParser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** ConfigParser.py 4 May 2004 09:21:43 -0000 1.63
--- ConfigParser.py 18 May 2004 02:25:50 -0000 1.64
***************
*** 556,559 ****
--- 556,560 ----
depth -= 1
if "%(" in value:
+ value = self._KEYCRE.sub(self._interpolation_replace, value)
try:
value = value % vars
***************
*** 567,570 ****
--- 568,580 ----
return value
+ _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+
+ def _interpolation_replace(self, match):
+ s = match.group(1)
+ if s is None:
+ return match.group()
+ else:
+ return "%%(%s)s" % self.optionxform(s)
+
class SafeConfigParser(ConfigParser):
***************
*** 599,603 ****
raise InterpolationSyntaxError(option, section,
"bad interpolation variable reference %r" % rest)
! var = m.group(1)
rest = rest[m.end():]
try:
--- 609,613 ----
raise InterpolationSyntaxError(option, section,
"bad interpolation variable reference %r" % rest)
! var = self.optionxform(m.group(1))
rest = rest[m.end():]
try:
More information about the Python-checkins
mailing list