Skip to content
Browse files

Revert "Fix for unicode handling and test thereof"

This reverts commit 9d73fb2.
  • Loading branch information...
1 parent 61f1eb5 commit 245c3da5419b936f41cceedf09b049c1f801ef0b Eskil Olsen committed Sep 4, 2012
Showing with 4 additions and 19 deletions.
  1. +2 −5 gearman/protocol.py
  2. +2 −14 tests/protocol_tests.py
View
7 gearman/protocol.py
@@ -50,7 +50,7 @@
GEARMAN_COMMAND_SUBMIT_JOB_LOW = 33
GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG = 34
-# Fake command code
+# Fake command code
GEARMAN_COMMAND_TEXT_COMMAND = 9999
GEARMAN_PARAMS_FOR_COMMAND = {
@@ -242,10 +242,7 @@ def pack_binary_command(cmd_type, cmd_args, is_response=False):
if compat.any(not isinstance(param_value, basestring) or '\0' in param_value for param_value in cmd_args.itervalues()):
raise ProtocolError('Received un-encodable arguments: %r' % cmd_args)
- try:
- data_items = [cmd_args[param].encode('ascii') for param in expected_cmd_params]
- except:
- raise ProtocolError('Received un-encodable arguments: %r' % cmd_args)
+ data_items = [cmd_args[param].encode('ascii') for param in expected_cmd_params]
binary_payload = NULL_CHAR.join(data_items)
# Pack the header in the !4sII format then append the binary payload
View
16 tests/protocol_tests.py
@@ -130,7 +130,7 @@ def test_packing_errors(self):
# Assert we get a non-string argument (expecting BYTES)
cmd_type = protocol.GEARMAN_COMMAND_JOB_CREATED
- cmd_args = dict(job_handle=u'Let it \u2744')
+ cmd_args = dict(job_handle=unicode(12345))
self.assertRaises(ProtocolError, protocol.pack_binary_command, cmd_type, cmd_args)
def test_packing_response(self):
@@ -161,18 +161,6 @@ def test_packing_single_arg(self):
packed_command_buffer = protocol.pack_binary_command(cmd_type, cmd_args)
self.assertEquals(packed_command_buffer, expected_command_buffer)
- def test_packing_encodable_unicode(self):
- cmd_type = protocol.GEARMAN_COMMAND_ECHO_REQ
- string = 'abcde'
- cmd_args = dict(data=u'%s' % string)
-
- expected_payload_size = len(cmd_args['data'])
- expected_format = '!4sII%ds' % expected_payload_size
-
- expected_command_buffer = struct.pack(expected_format, protocol.MAGIC_REQ_STRING, cmd_type, expected_payload_size, string)
- packed_command_buffer = protocol.pack_binary_command(cmd_type, cmd_args)
- self.assertEquals(packed_command_buffer, expected_command_buffer)
-
def test_packing_multiple_args(self):
cmd_type = protocol.GEARMAN_COMMAND_SUBMIT_JOB
cmd_args = dict(task='function', unique='12345', data='abcd')
@@ -284,4 +272,4 @@ def assert_sent_command(self, expected_cmd_type, **expected_cmd_args):
if __name__ == '__main__':
- unittest.main()
+ unittest.main()

0 comments on commit 245c3da

Please sign in to comment.
Something went wrong with that request. Please try again.