From c4e7defc88a79952c93b151310688f6cf39d3e6d Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 11 Apr 2018 21:02:53 +0000 Subject: [PATCH] Don't force unicode strings for UUID coercion Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to fix difference between Python 2 and Python 3 values by switching from using str() to formatting into a unicode string (u"%s"). This is equivalent to changing str() to unicode(), but that is not correct for expected default string types for Python 2. This requires either using six.text_type(), or just formatting into a string, without forcing unicode ("%s"), to be correct on either runtime. Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2 Closes-bug: #1763179 (cherry picked from commit b719764ba85d5e689d8276ad40c82985c84f03f9) --- oslo_versionedobjects/fields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo_versionedobjects/fields.py b/oslo_versionedobjects/fields.py index 86a5a33..03973bc 100644 --- a/oslo_versionedobjects/fields.py +++ b/oslo_versionedobjects/fields.py @@ -349,7 +349,7 @@ class UUID(StringPattern): with warnings.catch_warnings(): warnings.simplefilter("once") try: - uuid.UUID(u"%s" % value) + uuid.UUID("%s" % value) except Exception: # This is to ensure no breaking behaviour for current # users @@ -364,7 +364,7 @@ class UUID(StringPattern): repr(value).encode('utf8'), FutureWarning) - return u"%s" % value + return "%s" % value class MACAddress(StringPattern): -- GitLab