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:
|
if self.func_name is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Python 2/3 compatibility
|
arg_list = [as_text(repr(arg)) for arg in self.args]
|
||||||
try:
|
|
||||||
arg_list = [repr(arg).decode('utf-8') for arg in self.args]
|
|
||||||
except AttributeError:
|
|
||||||
arg_list = [repr(arg) for arg in self.args]
|
|
||||||
|
|
||||||
kwargs = ['{0}={1!r}'.format(k, v) for k, v in self.kwargs.items()]
|
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
|
# Sort here because python 3.3 & 3.4 makes different call_string
|
||||||
arg_list += sorted(kwargs)
|
arg_list += sorted(kwargs)
|
||||||
args = ', '.join(arg_list)
|
args = ', '.join(arg_list)
|
||||||
|
|
||||||
return '%s(%s)' % (self.func_name, args)
|
return '%s(%s)' % (self.func_name, args)
|
||||||
|
|
||||||
def cleanup(self, ttl=None, pipeline=None):
|
def cleanup(self, ttl=None, pipeline=None):
|
||||||
|
|
|
@ -31,12 +31,12 @@ class TestJob(RQTestCase):
|
||||||
kwargs=dict(snowman="☃", null=None),
|
kwargs=dict(snowman="☃", null=None),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
if not PY2:
|
||||||
# Python 2
|
|
||||||
test_string = u"myfunc(12, u'\\u2603', null=None, snowman=u'\\u2603')".decode('utf-8')
|
|
||||||
except AttributeError:
|
|
||||||
# Python 3
|
# Python 3
|
||||||
test_string = "myfunc(12, '☃', null=None, snowman='☃')"
|
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(
|
self.assertEquals(
|
||||||
job.description,
|
job.description,
|
||||||
|
|
Loading…
Reference in New Issue