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