From 8ee8e862af5f3d652d3ffeb3e7bbf11d3dc2a824 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Tue, 2 Mar 2021 12:30:33 +0000 Subject: [PATCH] updater: remove magic number Remove the magic number, a whence value of 2 for file.seek(), and instead use the io.SEEK_END constant from the io module. Signed-off-by: Joshua Lock --- tuf/client/updater.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tuf/client/updater.py b/tuf/client/updater.py index 34968890..1897b1f5 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -128,6 +128,7 @@ import fnmatch import copy import warnings +import io import tuf import tuf.download @@ -1245,9 +1246,7 @@ def _check_file_length(self, file_object, trusted_file_length): None. """ - # seek to the end of the file; that is offset 0 from the end of the file, - # represented by a whence value of 2 - file_object.seek(0, 2) + file_object.seek(0, io.SEEK_END) observed_length = file_object.tell() # Return and log a message if the length 'file_object' is equal to