[New-bugs-announce] [issue12009] netrc module crashes if netrc file has comment lines
Ruslan Mstoi
report at bugs.python.org
Thu May 5 15:25:50 CEST 2011
New submission from Ruslan Mstoi <rmstoi at gmail.com>:
It seems recent patch from Issue 10464 has introduced problems into
one line comment handling of netrc module.
Problem 1:
If there is a line starting with a comment sign the
following traceback is shown:
Traceback (most recent call last):
File "/usr/lib/python2.7/netrc.py", line 32, in __init__
self._parse(file, fp)
File "/usr/lib/python2.7/netrc.py", line 90, in _parse
file, lexer.lineno)
netrc.NetrcParseError: bad follower token '#' (./.netrc, line 3)
This can be fixed by modifying netrc.py like this:
71c71
< if (tt=='' or tt == 'machine' or
---
> if (tt=='' or tt == 'machine' or tt[0] == "#" or
Problem 2:
Now with the patch above it seems to work as long as there are
no comment lines like these:
a) with only pound sign:
#
b) with a pound sign followed by text without any space in between
#comment
If comment line like that is followed by netrc token that token
is consumed by fp.readline(). For example, if netrc file has
these contents:
<<<
machine host.domain.com login username password something
# comment1
machine host2.domain.com login username2 password something2
#comment2
machine host3.domain.com login username3 password something3
#
machine host4.domain.com login username4 password something4
>>>
netrc object will have entries only for host3 and host4.
----------
messages: 135196
nosy: rmstoi
priority: normal
severity: normal
status: open
title: netrc module crashes if netrc file has comment lines
type: crash
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12009>
_______________________________________
More information about the New-bugs-announce
mailing list