From 569327c20b0c88d15f89edf1d86105b802567405 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Mon, 1 Feb 2016 14:26:09 +1100 Subject: [PATCH] =?utf8?q?Gracefully=20handle=20the=20absence=20of=20?= =?utf8?q?=E2=80=98pwd=E2=80=99=20module=20on=20some=20platforms.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CHANGES | 2 ++ gajja/__init__.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9bbc4a3..ed62701 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ Version NEXT :Released: FUTURE :Maintainer: +* Gracefully handle the absence of ‘pwd’ module on some platforms. + Version 0.1.1 ============= diff --git a/gajja/__init__.py b/gajja/__init__.py index f6c73f8..b7daef8 100644 --- a/gajja/__init__.py +++ b/gajja/__init__.py @@ -55,7 +55,6 @@ import os.path import io import shutil import tempfile -import pwd import errno import time import signal @@ -67,6 +66,12 @@ import collections import weakref import shlex +try: + import pwd +except ImportError: + # The ‘pwd’ module is not available on platforms other than Unix. + pwd = NotImplemented + __package__ = str("gajja") __import__(__package__) @@ -253,6 +258,10 @@ def patch_pwd_getpwuid(testcase): func_patcher.start() testcase.addCleanup(func_patcher.stop) +if pwd is NotImplemented: + # The ‘pwd’ module is not available on some platforms. + del patch_pwd_getpwuid + def patch_os_path_exists(testcase): """ Patch `os.path.exists` behaviour for this test case. -- 2.11.4.GIT