From 722b38fb72a10957f81554d39668de9b6a5571e6 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Tue, 27 Nov 2018 13:31:18 -0800 Subject: [PATCH] move getpass import inside try/except for win32 support fixes fabric/fabric#983 --- fabric/state.py | 2 +- sites/www/changelog.rst | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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>`