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

View File

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

View File

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

View File

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

View File

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