From 6e0b90be22ccd1d22f937cb16128875a2e28746f Mon Sep 17 00:00:00 2001 From: BubaVV Date: Thu, 30 Aug 2018 10:19:39 +0300 Subject: [PATCH] Fix exception raise at rpdb session Some components raise unrelated exceptions during rpdb session due to unaware attribute handling of file-like objects Change-Id: I04dd5a7d0f6ec2920671dfa612439427dffefd52 Closes-bug: #1791104 --- oslo_utils/encodeutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo_utils/encodeutils.py b/oslo_utils/encodeutils.py index 845f9160..0e177b26 100644 --- a/oslo_utils/encodeutils.py +++ b/oslo_utils/encodeutils.py @@ -42,7 +42,7 @@ def safe_decode(text, incoming=None, errors='strict'): return text if not incoming: - incoming = (sys.stdin.encoding or + incoming = (getattr(sys.stdin, 'encoding', None) or sys.getdefaultencoding()) try: @@ -85,7 +85,7 @@ def safe_encode(text, incoming=None, raise TypeError("%s can't be encoded" % type(text)) if not incoming: - incoming = (sys.stdin.encoding or + incoming = (getattr(sys.stdin, 'encoding', None) or sys.getdefaultencoding()) # Avoid case issues in comparisons