Remove unnecessary unicode prefixes

Change-Id: I0910f62e7feaf928fe0afe4721c5b271d4748449
This commit is contained in:
songwenping 2022-04-19 19:47:53 +08:00
parent bcbd6adbc3
commit 0f5451555b
5 changed files with 48 additions and 48 deletions

View File

@ -43,8 +43,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'oslo.serialization'
copyright = u'2014, OpenStack Foundation'
project = 'oslo.serialization'
copyright = '2014, OpenStack Foundation'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
@ -74,6 +74,6 @@ htmlhelp_basename = '%sdoc' % project
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
'%s Documentation' % project,
'OpenStack Foundation', 'manual'),
]

View File

@ -227,17 +227,17 @@ class DateTimeHandler(object):
def serialize(self, dt):
dct = {
u'day': dt.day,
u'month': dt.month,
u'year': dt.year,
u'hour': dt.hour,
u'minute': dt.minute,
u'second': dt.second,
u'microsecond': dt.microsecond,
'day': dt.day,
'month': dt.month,
'year': dt.year,
'hour': dt.hour,
'minute': dt.minute,
'second': dt.second,
'microsecond': dt.microsecond,
}
if dt.tzinfo:
tz = dt.tzinfo.tzname(None)
dct[u'tz'] = tz
dct['tz'] = tz
return dumps(dct, registry=self._registry)
def deserialize(self, blob):
@ -365,9 +365,9 @@ class DateHandler(object):
def serialize(self, d):
dct = {
u'year': d.year,
u'month': d.month,
u'day': d.day,
'year': d.year,
'month': d.month,
'day': d.day,
}
return dumps(dct, registry=self._registry)

View File

@ -23,27 +23,27 @@ class Base64Tests(test_base.BaseTestCase):
self.assertEqual(b'dGV4dA==',
base64.encode_as_bytes(b'text'))
self.assertEqual(b'dGV4dA==',
base64.encode_as_bytes(u'text'))
base64.encode_as_bytes('text'))
self.assertEqual(b'ZTrDqQ==',
base64.encode_as_bytes(u'e:\xe9'))
base64.encode_as_bytes('e:\xe9'))
self.assertEqual(b'ZTrp',
base64.encode_as_bytes(u'e:\xe9', encoding='latin1'))
base64.encode_as_bytes('e:\xe9', encoding='latin1'))
def test_encode_as_text(self):
self.assertEqual(u'dGV4dA==',
self.assertEqual('dGV4dA==',
base64.encode_as_text(b'text'))
self.assertEqual(u'dGV4dA==',
base64.encode_as_text(u'text'))
self.assertEqual(u'ZTrDqQ==',
base64.encode_as_text(u'e:\xe9'))
self.assertEqual(u'ZTrp',
base64.encode_as_text(u'e:\xe9', encoding='latin1'))
self.assertEqual('dGV4dA==',
base64.encode_as_text('text'))
self.assertEqual('ZTrDqQ==',
base64.encode_as_text('e:\xe9'))
self.assertEqual('ZTrp',
base64.encode_as_text('e:\xe9', encoding='latin1'))
def test_decode_as_bytes(self):
self.assertEqual(b'text',
base64.decode_as_bytes(b'dGV4dA=='))
self.assertEqual(b'text',
base64.decode_as_bytes(u'dGV4dA=='))
base64.decode_as_bytes('dGV4dA=='))
def test_decode_as_bytes__error(self):
self.assertRaises(TypeError,
@ -51,11 +51,11 @@ class Base64Tests(test_base.BaseTestCase):
'hello world')
def test_decode_as_text(self):
self.assertEqual(u'text',
self.assertEqual('text',
base64.decode_as_text(b'dGV4dA=='))
self.assertEqual(u'text',
base64.decode_as_text(u'dGV4dA=='))
self.assertEqual(u'e:\xe9',
base64.decode_as_text(u'ZTrDqQ=='))
self.assertEqual(u'e:\xe9',
base64.decode_as_text(u'ZTrp', encoding='latin1'))
self.assertEqual('text',
base64.decode_as_text('dGV4dA=='))
self.assertEqual('e:\xe9',
base64.decode_as_text('ZTrDqQ=='))
self.assertEqual('e:\xe9',
base64.decode_as_text('ZTrp', encoding='latin1'))

View File

@ -89,24 +89,24 @@ class JSONUtilsTestMixin(object):
def test_loads_unicode(self):
self.assertIsInstance(jsonutils.loads(b'"foo"'), str)
self.assertIsInstance(jsonutils.loads(u'"foo"'), str)
self.assertIsInstance(jsonutils.loads('"foo"'), str)
# 'test' in Ukrainian
i18n_str_unicode = u'"\u0442\u0435\u0441\u0442"'
i18n_str_unicode = '"\u0442\u0435\u0441\u0442"'
self.assertIsInstance(jsonutils.loads(i18n_str_unicode), str)
i18n_str = i18n_str_unicode.encode('utf-8')
self.assertIsInstance(jsonutils.loads(i18n_str), str)
def test_loads_with_kwargs(self):
jsontext = u'{"foo": 3}'
jsontext = '{"foo": 3}'
result = jsonutils.loads(jsontext, parse_int=lambda x: 5)
self.assertEqual(5, result['foo'])
def test_load(self):
jsontext = u'{"a": "\u0442\u044d\u0441\u0442"}'
expected = {u'a': u'\u0442\u044d\u0441\u0442'}
jsontext = '{"a": "\u0442\u044d\u0441\u0442"}'
expected = {'a': '\u0442\u044d\u0441\u0442'}
for encoding in ('utf-8', 'cp1251'):
fp = io.BytesIO(jsontext.encode(encoding))
@ -325,12 +325,12 @@ class ToPrimitiveTestCase(test_base.BaseTestCase):
self.assertEqual({'ip_addr': '1.2.3.4'}, ret)
def test_ipaddr_using_ipaddress_v4(self):
thing = {'ip_addr': ipaddress.ip_address(u'192.168.0.1')}
thing = {'ip_addr': ipaddress.ip_address('192.168.0.1')}
ret = jsonutils.to_primitive(thing)
self.assertEqual({'ip_addr': '192.168.0.1'}, ret)
def test_ipaddr_using_ipaddress_v6(self):
thing = {'ip_addr': ipaddress.ip_address(u'2001:db8::')}
thing = {'ip_addr': ipaddress.ip_address('2001:db8::')}
ret = jsonutils.to_primitive(thing)
self.assertEqual({'ip_addr': '2001:db8::'}, ret)

View File

@ -60,8 +60,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'oslo.serialization Release Notes'
copyright = u'2016, oslo.serialization Developers'
project = 'oslo.serialization Release Notes'
copyright = '2016, oslo.serialization Developers'
# Release notes do not need a version in the title, they span
# multiple versions.
@ -208,8 +208,8 @@ latex_elements = {
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'oslo.serializationReleaseNotes.tex',
u'oslo.serialization Release Notes Documentation',
u'oslo.serialization Developers', 'manual'),
'oslo.serialization Release Notes Documentation',
'oslo.serialization Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -239,8 +239,8 @@ latex_documents = [
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'oslo.serializationReleaseNotes',
u'oslo.serialization Release Notes Documentation',
[u'oslo.serialization Developers'], 1)
'oslo.serialization Release Notes Documentation',
['oslo.serialization Developers'], 1)
]
# If true, show URL addresses after external links.
@ -254,8 +254,8 @@ man_pages = [
# dir menu entry, description, category)
texinfo_documents = [
('index', 'oslo.serializationReleaseNotes',
u'oslo.serialization Release Notes Documentation',
u'oslo.serialization Developers', 'oslo.serializationReleaseNotes',
'oslo.serialization Release Notes Documentation',
'oslo.serialization Developers', 'oslo.serializationReleaseNotes',
'One line description of project.',
'Miscellaneous'),
]