Commit 5931129f authored by Seyeong Kim's avatar Seyeong Kim Committed by Corey Bryant
Browse files

Fixing UUID coerce function for unicode non uuid form

If we use non uuid unicode user id in py27 env,
unicode error pop up when function is called.

Closes-bug: #1760918

Change-Id: Ic6b6308fb1960ec40407e6efde30137b64543e72
(cherry picked from commit b1d0b5d8)
parent c86c6ed8
......@@ -349,7 +349,7 @@ class UUID(StringPattern):
with warnings.catch_warnings():
warnings.simplefilter("once")
try:
uuid.UUID(str(value))
uuid.UUID(u"%s" % value)
except Exception:
# This is to ensure no breaking behaviour for current
# users
......@@ -360,9 +360,11 @@ class UUID(StringPattern):
"code to input valid UUIDs or accept "
"ValueErrors for invalid UUIDs. See "
"https://docs.openstack.org/oslo.versionedobjects/latest/reference/fields.html#oslo_versionedobjects.fields.UUIDField " # noqa
"for further details" % value, FutureWarning)
"for further details" %
repr(value).encode('utf8'),
FutureWarning)
return str(value)
return u"%s" % value
class MACAddress(StringPattern):
......
# -*- coding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
......@@ -284,6 +285,9 @@ class TestUUID(TestField):
('da66a411-af0e-4829-9b67-475017ddz152',
'da66a411-af0e-4829-9b67-475017ddz152'),
('fake_uuid', 'fake_uuid'),
(u'fake_uāid', u'fake_uāid'),
(b'fake_u\xe1id'.decode('latin_1'),
b'fake_u\xe1id'.decode('latin_1')),
('1', '1'),
(1, '1')
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment