diff --git a/fabric/state.py b/fabric/state.py index 9b2c0e9e..fe549a71 100644 --- a/fabric/state.py +++ b/fabric/state.py @@ -32,9 +32,9 @@ def _get_system_username(): """ Obtain name of current system user, which will be default connection user. """ - import getpass username = None try: + import getpass username = getpass.getuser() # getpass.getuser supported on both Unix and Windows systems. # getpass.getuser may call pwd.getpwuid which in turns may raise KeyError diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 334a54f3..19ed3f97 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -6,6 +6,9 @@ Changelog `~fabric.contrib.files.upload_template` when backing up the target file, preventing issues on simpler remote shells. Patch courtesy of Paul Chakravarti. +* :bug:`983` Move a ``getpass`` import inside a Windows-oriented + ``try``/``except ImportError`` so password prompting is less likely to + explode on certain systems. Thanks to ``@dongweiming`` for the patch. * :support:`- backported` Update packaging metadata so wheel archives include the ``LICENSE`` file. * :release:`1.14.0 <2017-08-25>`