[Python-bugs-list] [ python-Bugs-532115 ] netrc module broken:not parsing macdefs

noreply@sourceforge.net noreply@sourceforge.net
Tue, 19 Mar 2002 13:15:14 -0800


Bugs item #532115, was opened at 2002-03-19 21: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: Open
Resolution: None
Priority: 5
Submitted By: Winston Collier (wacollier)
Assigned to: Nobody/Anonymous (nobody)
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.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=532115&group_id=5470