Browse Source

When empty array or dictionary were passed for data, an uncatched TypeError exception was raised.

pull/5/head
david 10 years ago
parent
commit
698c3dc7e6
  1. 30
      socketio/packet.py

30
socketio/packet.py

@ -135,17 +135,25 @@ class Packet(object):
else: else:
return data return data
def _data_is_binary(self, data): def _data_is_binary(self, data):
"""Check if the data contains binary components.""" """Check if the data contains binary components."""
if isinstance(data, six.binary_type): try:
return True if isinstance(data, six.binary_type):
elif isinstance(data, list): return True
return functools.reduce( elif isinstance(data, list):
lambda a, b: a or b, [self._data_is_binary(item) return functools.reduce(
for item in data]) lambda a, b: a or b, [self._data_is_binary(item)
elif isinstance(data, dict): for item in data])
return functools.reduce( elif isinstance(data, dict):
lambda a, b: a or b, [self._data_is_binary(item) return functools.reduce(
for item in six.itervalues(data)]) lambda a, b: a or b, [self._data_is_binary(item)
else: for item in six.itervalues(data)])
else:
return False
except TypeError:
return False return False

Loading…
Cancel
Save