On 8/27/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> --- From ConfigParser.py ---------------
>
> optname, vi, optval = mo.group('option', 'vi', 'value')
> if vi in ('=', ':') and ';' in optval:
> # ';' is a comment delimiter only if it follows
> # a spacing character
> pos = optval.find(';')
> if pos != -1 and optval[pos-1].isspace():
> optval = optval[:pos]
> optval = optval.strip()
> . . .
>
>
> optname, vi, optval = mo.group('option', 'vi', 'value')
> if vi in ('=', ':') and ';' in optval:
> # ';' is a comment delimiter only if it follows
> # a spacing character
> try:
> pos = optval.index(';')
> except ValueError():
I'm sure you meant "except ValueError:"
> pass
> else:
> if optval[pos-1].isspace():
> optval = optval[:pos]
> optval = optval.strip()
> . . .
That code is buggy before and after the transformation -- consider
what happens if optval *starts* with a semicolon. Also, the code is
searching optval for ';' twice. Suggestion:
if vi in ('=',':'):
try: pos = optval.index(';')
except ValueError: pass
else:
if pos > 0 and optval[pos-1].isspace():
optval = optval[:pos]
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com