Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
systemsmanagement:saltstack:products:testing
py26-compat-salt
backport-46867-string-arg-normalization-bsc-109...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File backport-46867-string-arg-normalization-bsc-1094960.patch of Package py26-compat-salt
From 087080c12f9cb422527971dd8bb5b3205dc91da0 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Tue, 29 May 2018 16:33:01 +0200 Subject: [PATCH] Backport #46867 string arg normalization (bsc#1094960) use unicode key for the logging Add unicode literals to cp module --- salt/log/setup.py | 30 ++++++++++++++++++++---------- salt/modules/cp.py | 2 +- salt/modules/file.py | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/salt/log/setup.py b/salt/log/setup.py index b321f22477..a367fdb943 100644 --- a/salt/log/setup.py +++ b/salt/log/setup.py @@ -320,15 +320,16 @@ class SaltLoggingClass(six.with_metaclass(LoggingMixInMeta, LOGGING_LOGGER_CLASS # If nothing else is in extra, make it None extra = None + salt_system_encoding = __salt_system_encoding__ + if salt_system_encoding == 'ascii': + # Encoding detection most likely failed, let's use the utf-8 + # value which we defaulted before __salt_system_encoding__ was + # implemented + salt_system_encoding = 'utf-8' + # Let's try to make every logging message unicode if isinstance(msg, six.string_types) \ and not isinstance(msg, six.text_type): - salt_system_encoding = __salt_system_encoding__ - if salt_system_encoding == 'ascii': - # Encoding detection most likely failed, let's use the utf-8 - # value which we defaulted before __salt_system_encoding__ was - # implemented - salt_system_encoding = 'utf-8' try: _msg = msg.decode(salt_system_encoding, 'replace') except UnicodeDecodeError: @@ -336,12 +337,21 @@ class SaltLoggingClass(six.with_metaclass(LoggingMixInMeta, LOGGING_LOGGER_CLASS else: _msg = msg + _args = [] + for item in args: + if isinstance(item, six.string_types) and not isinstance(item, six.text_type): + try: + _args.append(item.decode(salt_system_encoding, 'replace')) + except UnicodeDecodeError: + _args.append(item.decode(salt_system_encoding, 'ignore')) + else: + _args.append(item) + _args = tuple(_args) + if six.PY3: - logrecord = _LOG_RECORD_FACTORY(name, level, fn, lno, _msg, args, - exc_info, func, sinfo) + logrecord = _LOG_RECORD_FACTORY(name, level, fn, lno, _msg, _args, exc_info, func, sinfo) else: - logrecord = _LOG_RECORD_FACTORY(name, level, fn, lno, _msg, args, - exc_info, func) + logrecord = _LOG_RECORD_FACTORY(name, level, fn, lno, _msg, _args, exc_info, func) if extra is not None: for key in extra: diff --git a/salt/modules/cp.py b/salt/modules/cp.py index 3f3fe1a989..d4000655e9 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -4,7 +4,7 @@ Minion side functions for salt-cp ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import base64 import errno import os diff --git a/salt/modules/file.py b/salt/modules/file.py index 9186de9166..8e45c5166d 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3545,7 +3545,7 @@ def source_list(source, source_hash, saltenv): salt '*' file.source_list salt://http/httpd.conf '{hash_type: 'md5', 'hsum': <md5sum>}' base ''' - contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv) + contextkey = u'{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv) if contextkey in __context__: return __context__[contextkey] -- 2.17.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor