[Python-bugs-list] [ python-Bugs-532115 ] netrc module broken:not parsing macdefs
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 21 Mar 2002 18:47:47 -0800
Bugs item #532115, was opened at 2002-03-19 16:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=532115&group_id=5470
Category: Python Library
Group: Python 2.1.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Winston Collier (wacollier)
>Assigned to: A.M. Kuchling (akuchling)
Summary: netrc module broken:not parsing macdefs
Initial Comment:
The netrc module on linux and Solaris (and probably all
other platforms, possibly on higher versions as well)
is not properly parsing the .netrc module for macro
definitions (macdef). Its is supposed to return a
dictionary of strings with the macdef name being the
key, but instead it only parses the first macdef entry,
and returns everything else as the string list,
including the macdefs that follow the first on in the
file. Its ignoring the extra '\n' that delimits the
end of a macdef and the new 'macdef' statement for
subsequent macros.
example:
in .netrc
............
machine ftpme.foo.com
login luserhaxor
password im3733t
macdef downloadfoo
cd test
bin
get foo.test
quit
macdef uploadfoo
cd test
bin
put foo.test
quit
............
python:
............
>>> import netrc
>>> foo=netrc.netrc()
>>> foo.macros
{'downloadfoo': ['cd test\n', 'bin\n', 'get
foo.test\n', 'quit\n', '\n', 'macdef uploadfoo\n', 'cd
test\n', 'bin\n', 'put foo.test\n', 'quit\n', '\n']}
>>> foo.macros['downloadfoo']
['cd test\n', 'bin\n', 'get foo.test\n', 'quit\n',
'\n', 'macdef uploadfoo\n', 'cd test\n', 'bin\n', 'put
foo.test\n', 'quit\n', '\n']
>>> foo.macros['uploadfoo']
Traceback (most recent call last):
File "<pyshell#45>", line 1, in ?
foo.macros['uploadfoo']
KeyError: uploadfoo
>>>
As you can see, its broken as far as parsing macdefs
into a dictionary goes.
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2002-03-21 21:47
Message:
Logged In: YES
user_id=11375
I've checked in a fixed version as revision 1.14 in CVS;
please try it out and let me know if it fixes the problem
for you. (I've already tried it on your example, and it
parses it correctly.)
Thanks for your bug report!
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=532115&group_id=5470