From 973921df5aa49d98feef232c91aabedaf2c64030 Mon Sep 17 00:00:00 2001 From: Emmo Emminghaus Date: Sat, 10 Nov 2018 21:56:39 +0100 Subject: [PATCH] remove unneded code and remarks, added needed except clause --- src/borg/helpers/checks.py | 2 -- src/borg/platform/posix.pyx | 7 ++----- src/borg/platform/xattr.py | 2 +- src/borg/testsuite/__init__.py | 6 +++--- src/borg/testsuite/hashindex.py | 1 - 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/borg/helpers/checks.py b/src/borg/helpers/checks.py index 383eb37c7..a9fe262ca 100644 --- a/src/borg/helpers/checks.py +++ b/src/borg/helpers/checks.py @@ -15,8 +15,6 @@ def check_python(): required_funcs = {os.stat, os.utime, os.chown} if not os.supports_follow_symlinks.issuperset(required_funcs): raise PythonLibcTooOld - pass - class ExtensionModuleError(Error): diff --git a/src/borg/platform/posix.pyx b/src/borg/platform/posix.pyx index 979974284..6ddb3eb32 100644 --- a/src/borg/platform/posix.pyx +++ b/src/borg/platform/posix.pyx @@ -1,10 +1,8 @@ import errno import os -# begin moved form helpers/usergroup.py import grp import pwd from functools import lru_cache -# end moved from libc.errno cimport errno as c_errno @@ -67,7 +65,6 @@ def local_pid_alive(pid): # Any other error (eg. permissions) means that the process ID refers to a live process. return True -# begin moved form helpers/usergroup.py @lru_cache(maxsize=None) def uid2user(uid, default=None): @@ -114,8 +111,8 @@ def posix_acl_use_stored_uid_gid(acl): else: entries.append(entry) return safe_encode('\n'.join(entries)) -#end moved + def getosusername(): """Return the os user name.""" - return uid2user(os.getuid(), os.getuid()) + return uid2user(os.getuid()) diff --git a/src/borg/platform/xattr.py b/src/borg/platform/xattr.py index 63f9bf7e4..74e3d3ab6 100644 --- a/src/borg/platform/xattr.py +++ b/src/borg/platform/xattr.py @@ -37,7 +37,7 @@ class BufferTooSmallError(Exception): def _check(rv, path=None, detect_buffer_too_small=False): - from . import get_errno # circular reference if imported at global level! + from . import get_errno if rv < 0: e = get_errno() if detect_buffer_too_small and e == errno.ERANGE: diff --git a/src/borg/testsuite/__init__.py b/src/borg/testsuite/__init__.py index 13af4d72e..2658cff2e 100644 --- a/src/borg/testsuite/__init__.py +++ b/src/borg/testsuite/__init__.py @@ -3,8 +3,8 @@ import filecmp import functools import os try: - import posix # buildin but not everywhere -except: + import posix +except ImportError: posix = None import stat @@ -48,7 +48,7 @@ except ImportError: has_llfuse = False # The mtime get/set precision varies on different OS and Python versions -if posix != None and 'HAVE_FUTIMENS' in getattr(posix, '_have_functions', []): +if posix and 'HAVE_FUTIMENS' in getattr(posix, '_have_functions', []): st_mtime_ns_round = 0 elif 'HAVE_UTIMES' in sysconfig.get_config_vars(): st_mtime_ns_round = -6 diff --git a/src/borg/testsuite/hashindex.py b/src/borg/testsuite/hashindex.py index eb9154f84..c07e207d7 100644 --- a/src/borg/testsuite/hashindex.py +++ b/src/borg/testsuite/hashindex.py @@ -54,7 +54,6 @@ class HashIndexTestCase(BaseTestCase): for x in range(50): self.assert_raises(KeyError, idx.__delitem__, H(x)) self.assert_equal(len(idx), 50) - idx_name = tempfile.NamedTemporaryFile() with unopened_tempfile() as filepath: idx.write(filepath) del idx