diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-01-19 12:24:45 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-01-19 12:24:45 (GMT) |
commit | 40b9835e98e9e380cfa6eb76802567c97a82f0d8 (patch) | |
tree | ecdc35b2c4dfd9e77927699745256228411db86d /Lib/ftplib.py | |
parent | c39f4f8968d223c3ee4247e93304b3573d3d3333 (diff) | |
download | cpython-40b9835e98e9e380cfa6eb76802567c97a82f0d8.zip cpython-40b9835e98e9e380cfa6eb76802567c97a82f0d8.tar.gz cpython-40b9835e98e9e380cfa6eb76802567c97a82f0d8.tar.bz2 |
Always use 'anonymous' if os.environ doesn't exist
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r-- | Lib/ftplib.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py index d160303..7a414e6 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -2,6 +2,7 @@ # (FTP), by J. Postel and J. Reynolds # Changes and improvements suggested by Steve Majewski +# Modified by Jack to work on the mac. # Example: @@ -220,11 +221,15 @@ class FTP: if not user: user = 'anonymous' if user == 'anonymous' and passwd in ('', '-'): thishost = socket.gethostname() - if os.environ.has_key('LOGNAME'): - realuser = os.environ['LOGNAME'] - elif os.environ.has_key('USER'): - realuser = os.environ['USER'] - else: + try: + if os.environ.has_key('LOGNAME'): + realuser = os.environ['LOGNAME'] + elif os.environ.has_key('USER'): + realuser = os.environ['USER'] + else: + realuser = 'anonymous' + except AttributeError: + # Not all systems have os.environ.... realuser = 'anonymous' passwd = passwd + realuser + '@' + thishost resp = self.sendcmd('USER ' + user) |