oscap-anaconda-addon/SOURCES/checksum.patch
2021-09-09 23:23:57 +00:00

31 lines
1.0 KiB
Diff

From fd1684358e212521abaf3ec7662aa97181868c0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
Date: Tue, 15 Jan 2019 18:19:28 +0100
Subject: [PATCH] Fixed the checksum function to use forward-compatible rb
mode.
On python3, there is a problem as contents of r-opened file is string,
but they are treated as bytes later. rb mode is fully python2-compatible.
---
org_fedora_oscap/utils.py | 4 ++--
tests/data/file | 1 +
tests/test_utils.py | 12 ++++++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 tests/data/file
diff --git a/org_fedora_oscap/utils.py b/org_fedora_oscap/utils.py
index 6d5c157..3be8325 100644
--- a/org_fedora_oscap/utils.py
+++ b/org_fedora_oscap/utils.py
@@ -175,8 +175,8 @@ def get_file_fingerprint(fpath, hash_obj):
"""
- with open(fpath, "r") as fobj:
- bsize = 4*1024
+ with open(fpath, "rb") as fobj:
+ bsize = 4 * 1024
# process file as 4 KB blocks
buf = fobj.read(bsize)
while buf: