Merge "Python 3: encode to UTF-8 when needed"
This commit is contained in:
commit
82031de3e0
@ -45,7 +45,9 @@ def compute_signature(message, secret):
|
||||
if not secret:
|
||||
return ''
|
||||
|
||||
digest_maker = hmac.new(secret, '', hashlib.sha256)
|
||||
if isinstance(secret, six.text_type):
|
||||
secret = secret.encode('utf-8')
|
||||
digest_maker = hmac.new(secret, b'', hashlib.sha256)
|
||||
for name, value in utils.recursive_keypairs(message):
|
||||
if name == 'message_signature':
|
||||
# Skip any existing signature value, which would not have
|
||||
|
@ -270,8 +270,10 @@ class Connection(base.Connection):
|
||||
# TODO(gordc): implement lru_cache to improve performance
|
||||
try:
|
||||
res = models.Resource.__table__
|
||||
m_hash = hashlib.md5(jsonutils.dumps(rmeta,
|
||||
sort_keys=True)).hexdigest()
|
||||
m_hash = jsonutils.dumps(rmeta, sort_keys=True)
|
||||
if six.PY3:
|
||||
m_hash = m_hash.encode('utf-8')
|
||||
m_hash = hashlib.md5(m_hash).hexdigest()
|
||||
trans = conn.begin_nested()
|
||||
if conn.dialect.name == 'sqlite':
|
||||
trans = conn.begin()
|
||||
|
@ -21,6 +21,7 @@ from oslo_context import context
|
||||
import oslo_messaging
|
||||
import oslo_messaging.conffixture
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from stevedore import extension
|
||||
import yaml
|
||||
|
||||
@ -182,6 +183,8 @@ class BaseRealNotification(tests_base.BaseTestCase):
|
||||
'transformers': [],
|
||||
'publishers': ['test://'],
|
||||
}])
|
||||
if six.PY3:
|
||||
pipeline = pipeline.encode('utf-8')
|
||||
self.expected_samples = 2
|
||||
pipeline_cfg_file = fileutils.write_to_tempfile(content=pipeline,
|
||||
prefix="pipeline",
|
||||
@ -202,6 +205,8 @@ class BaseRealNotification(tests_base.BaseTestCase):
|
||||
'publishers': ['test://']
|
||||
}]
|
||||
})
|
||||
if six.PY3:
|
||||
ev_pipeline = ev_pipeline.encode('utf-8')
|
||||
self.expected_events = 1
|
||||
ev_pipeline_cfg_file = fileutils.write_to_tempfile(
|
||||
content=ev_pipeline, prefix="event_pipeline", suffix="yaml")
|
||||
|
Loading…
Reference in New Issue
Block a user