From: Kun Huang Date: Wed, 24 Jul 2013 16:19:56 +0000 (+0800) Subject: use encode('utf8') instead of str() X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c98cf2d8;p=openstack-build%2Fcinder-build.git use encode('utf8') instead of str() It is not clear for converting a unicode to string by using str(). Instead we should use var.encode('utf8') to do this. Change-Id: I8ce4c98f819c98e835a6d8298fe22f2fd0ca18b6 --- diff --git a/cinder/backup/drivers/ceph.py b/cinder/backup/drivers/ceph.py index d9c734194..c7d2c7b8e 100644 --- a/cinder/backup/drivers/ceph.py +++ b/cinder/backup/drivers/ceph.py @@ -112,9 +112,11 @@ class CephBackupDriver(BackupDriver): self.rbd_stripe_count = 0 self.rbd_stripe_unit = 0 - self._ceph_backup_user = str(CONF.backup_ceph_user) - self._ceph_backup_pool = str(CONF.backup_ceph_pool) - self._ceph_backup_conf = str(CONF.backup_ceph_conf) + _utf8 = lambda s: s if isinstance(s, str) else s.encode('utf8') + + self._ceph_backup_user = _utf8(CONF.backup_ceph_user) + self._ceph_backup_pool = _utf8(CONF.backup_ceph_pool) + self._ceph_backup_conf = _utf8(CONF.backup_ceph_conf) def _validate_string_args(self, *args): """Ensure all args are non-None and non-empty."""