mirror of https://github.com/rq/rq.git
Merge pull request #510 from alternativshik/master
change try/except in python2/3 compatibility to to_text()
This commit is contained in:
commit
04b8ea481b
|
@ -514,16 +514,13 @@ class Job(object):
|
|||
if self.func_name is None:
|
||||
return None
|
||||
|
||||
# Python 2/3 compatibility
|
||||
try:
|
||||
arg_list = [repr(arg).decode('utf-8') for arg in self.args]
|
||||
except AttributeError:
|
||||
arg_list = [repr(arg) for arg in self.args]
|
||||
arg_list = [as_text(repr(arg)) for arg in self.args]
|
||||
|
||||
kwargs = ['{0}={1!r}'.format(k, v) for k, v in self.kwargs.items()]
|
||||
# Sort here because python 3.3 & 3.4 makes different call_string
|
||||
arg_list += sorted(kwargs)
|
||||
args = ', '.join(arg_list)
|
||||
|
||||
return '%s(%s)' % (self.func_name, args)
|
||||
|
||||
def cleanup(self, ttl=None, pipeline=None):
|
||||
|
|
|
@ -31,12 +31,12 @@ class TestJob(RQTestCase):
|
|||
kwargs=dict(snowman="☃", null=None),
|
||||
)
|
||||
|
||||
try:
|
||||
# Python 2
|
||||
test_string = u"myfunc(12, u'\\u2603', null=None, snowman=u'\\u2603')".decode('utf-8')
|
||||
except AttributeError:
|
||||
if not PY2:
|
||||
# Python 3
|
||||
test_string = "myfunc(12, '☃', null=None, snowman='☃')"
|
||||
else:
|
||||
# Python 2
|
||||
test_string = u"myfunc(12, u'\\u2603', null=None, snowman=u'\\u2603')".decode('utf-8')
|
||||
|
||||
self.assertEquals(
|
||||
job.description,
|
||||
|
|
Loading…
Reference in New Issue