/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

(jameinel) Bug #660174,
 trap accidental import of pwd on Windows where it doesn't exist. (Alexander
 Belchenko)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2369
2369
    except UnicodeDecodeError:
2370
2370
        raise errors.BzrError("Can't decode username as %s." % \
2371
2371
                user_encoding)
 
2372
    except ImportError, e:
 
2373
        if sys.platform != 'win32':
 
2374
            raise
 
2375
        if str(e) != 'No module named pwd':
 
2376
            raise
 
2377
        # https://bugs.launchpad.net/bzr/+bug/660174
 
2378
        # getpass.getuser() is unable to return username on Windows
 
2379
        # if there is no USERNAME environment variable set.
 
2380
        # That could be true if bzr is running as a service,
 
2381
        # e.g. running `bzr serve` as a service on Windows.
 
2382
        # We should not fail with traceback in this case.
 
2383
        username = u'UNKNOWN'
2372
2384
    return username
2373
2385
 
2374
2386