From: Alfredo Deza Date: Thu, 10 Aug 2017 13:11:27 +0000 (-0400) Subject: ceph-volume: create a utf-8 string decoder for py3 compat X-Git-Tag: v12.1.3~5^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1ff974a32893475f7348599e6b9b5e39e098dbc;p=ceph.git ceph-volume: create a utf-8 string decoder for py3 compat Signed-off-by: Alfredo Deza (cherry picked from commit b50f1fb5527447c323fa51fb5c0ba260655dfb0d) --- diff --git a/src/ceph-volume/ceph_volume/util/__init__.py b/src/ceph-volume/ceph_volume/util/__init__.py index e69de29bb2d1..3b8c30906129 100644 --- a/src/ceph-volume/ceph_volume/util/__init__.py +++ b/src/ceph-volume/ceph_volume/util/__init__.py @@ -0,0 +1,10 @@ + +def as_string(string): + """ + Ensure that whatever type of string is incoming, it is returned as an + actual string, versus 'bytes' which Python 3 likes to use. + """ + if isinstance(string, bytes): + # we really ignore here if we can't properly decode with utf-8 + return string.decode('utf-8', 'ignore') + return string