Fix Python 3 leftovers

This commit contains last small fixes. In Python 3 None cannot be
compared with int. Also string can be added only to string, thus
NamedUnicodeStr should be subclass of string.

Change-Id: I3afaa24cd88861e56b906689870ca7f1b8e853bb
Implements: blueprint py3k-support
This commit is contained in:
Nataliia Uvarova 2014-06-20 11:01:52 +03:00
parent 22584f484c
commit 4090079147
3 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@
"""wsgi transport helpers."""
import falcon
import six
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging
@ -74,7 +75,9 @@ def validate_queue_identification(validate, req, resp, params):
pass
except validation.ValidationFailed:
project = params['project_id']
queue = params['queue_name'].decode('utf-8', 'replace')
queue = params['queue_name']
if six.PY2:
queue = queue.decode('utf-8', 'replace')
LOG.debug(u'Invalid queue name "%(queue)s" submitted for '
u'project: %(project)s',

View File

@ -123,7 +123,8 @@ class Validator(object):
:param content_length: Queue request's length.
:raises: ValidationFailed if the metadata is oversize.
"""
if content_length is None:
return
if content_length > self._limits_conf.max_queue_metadata:
msg = _(u'Queue metadata is too large. Max size: {0}')
raise ValidationFailed(msg, self._limits_conf.max_queue_metadata)
@ -148,6 +149,8 @@ class Validator(object):
:param content_length: Queue request's length.
:raises: ValidationFailed if the metadata is oversize.
"""
if content_length is None:
return
if content_length > self._limits_conf.max_message_size:
raise ValidationFailed(
_(u'Message collection size is too large. Max size {0}'),

View File

@ -28,7 +28,7 @@ class NamedBinaryStr(six.binary_type):
"""Wrapper for six.binary_type to facilitate overriding __name__."""
class NamedUnicodeStr(object):
class NamedUnicodeStr(six.text_type):
"""Unicode string look-alike to facilitate overriding __name__."""