diff --git a/config_common/file_utils.py b/config_common/file_utils.py index f334bd5..380f7a3 100644 --- a/config_common/file_utils.py +++ b/config_common/file_utils.py @@ -33,6 +33,9 @@ from config_common import utils from config_common.local_config import get as get_config from rhn.i18n import bstr, sstr +decodestring = base64.decodestring +if hasattr(base64, 'decodebytes'): + decodestring = base64.decodebytes class FileProcessor: file_struct_fields = { @@ -77,7 +80,7 @@ class FileProcessor: contents = file_struct['file_contents'] if contents and (encoding == 'base64'): - contents = base64.decodestring(bstr(contents)) + contents = decodestring(bstr(contents)) delim_start = file_struct['delim_start'] delim_end = file_struct['delim_end'] @@ -222,8 +225,8 @@ class FileProcessor: else: raise e else: - result = ''.join(diff(temp_file, path, - display_diff=get_config('display_diff'), is_binary=file_struct['is_binary'])) + result = ''.join(diff(temp_file, path, display_diff=get_config('display_diff'), + is_binary=True if file_struct['is_binary'] == 'Y' else False)) if temp_file: os.unlink(temp_file) @@ -240,8 +243,9 @@ def diff(src, dst, srcname=None, dstname=None, display_diff=False, is_binary=Fal def f_content(path, name, is_binary): statinfo = None if os.access(path, os.R_OK): - f = open(path, 'Ub' if is_binary else 'U') - content = f.readlines() + f = open(path, ('rb' if is_binary else 'r') if int(sys.version[0]) == 3 else \ + ('Ub' if is_binary else 'U')) + content = [sstr(i) for i in f.readlines()] f.close() statinfo = os.stat(path) f_time = time.ctime(statinfo.st_mtime) diff --git a/config_common/utils.py b/config_common/utils.py index 6669869..21ad4c1 100644 --- a/config_common/utils.py +++ b/config_common/utils.py @@ -32,7 +32,9 @@ from rhn.i18n import bstr hashlib_has_usedforsecurity = False -if 'usedforsecurity' in inspect.getargspec(hashlib.new)[0]: +if not hasattr(inspect, 'getfullargspec'): + inspect.getfullargspec = inspect.getargspec +if 'usedforsecurity' in inspect.getfullargspec(hashlib.new)[0]: hashlib_has_usedforsecurity = True _normpath_re = re.compile("^(%s)+" % os.sep) diff --git a/rhncfg.spec b/rhncfg.spec index f5e1833..cc2068e 100644 --- a/rhncfg.spec +++ b/rhncfg.spec @@ -15,7 +15,7 @@ Name: rhncfg Version: 5.10.120 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Spacewalk Configuration Client Libraries License: GPLv2 URL: https://github.com/spacewalkproject/spacewalk @@ -281,6 +281,10 @@ fi %endif %changelog +* Mon Feb 04 2019 Michael Mraka 5.10.120-9 +- Resolves: #1665858 - diff expects string not bytes +- Resolves: #1622961 - avoid deprecated fucntions when running on python3 + * Tue Nov 06 2018 Tomas Kasparek 5.10.120-8 - Resolves: rhbz#1645005 - unified_diff takes list, not string as a paremeter (tkasparek@redhat.com)