diff options
| author | Barry Warsaw | 2015-12-26 23:16:01 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-12-26 23:16:01 -0500 |
| commit | 39fd2905cc34221ca2907f14f3f018190a3f62c5 (patch) | |
| tree | 01c0208e40ebcea025b933619714e08ea0b58912 /src/mailman/utilities/uid.py | |
| parent | 0e11f68b74beef848255272a8010cad3ea96af91 (diff) | |
| download | mailman-39fd2905cc34221ca2907f14f3f018190a3f62c5.tar.gz mailman-39fd2905cc34221ca2907f14f3f018190a3f62c5.tar.zst mailman-39fd2905cc34221ca2907f14f3f018190a3f62c5.zip | |
Diffstat (limited to 'src/mailman/utilities/uid.py')
| -rw-r--r-- | src/mailman/utilities/uid.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mailman/utilities/uid.py b/src/mailman/utilities/uid.py index 9f24cef68..007f7e8f5 100644 --- a/src/mailman/utilities/uid.py +++ b/src/mailman/utilities/uid.py @@ -30,7 +30,6 @@ __all__ = [ import os import time import uuid -import errno import random import hashlib @@ -64,7 +63,7 @@ class _PredictableIDGenerator: # These will get automatically cleaned up by the test # infrastructure. self._uid_file = os.path.join(config.VAR_DIR, '.uid') - if self._context: + if self._context is not None: self._uid_file += '.' + self._context self._lock_file = self._uid_file + '.lock' self._lockobj = Lock(self._lock_file) @@ -90,7 +89,7 @@ class _PredictableIDGenerator: The type of the returned id is intended to be the type that makes sense for the subclass overriding this method. """ - raise NotImplementedError + raise NotImplementedError # pragma: no cover def _next_predictable_id(self): """Generate a predictable id for when Mailman being tested. @@ -98,20 +97,18 @@ class _PredictableIDGenerator: The type of the returned id is intended to be the type that makes sense for the subclass overriding this method. """ - raise NotImplementedError + raise NotImplementedError # pragma: no cover def _next_id(self): with self._lock: try: with open(self._uid_file) as fp: uid = int(fp.read().strip()) - next_uid = uid + 1 + next_uid = uid + 1 # pragma: no branch with open(self._uid_file, 'w') as fp: - fp.write(str(next_uid)) + fp.write(str(next_uid)) # pragma: no branch return uid - except IOError as error: - if error.errno != errno.ENOENT: - raise + except FileNotFoundError: with open(self._uid_file, 'w') as fp: fp.write('2') return 1 |
