python-memcached
python-memcached copied to clipboard
"'str' does not support the buffer interface" in serverHashFunction()
We found a problem in versions 1.56 and 1.57. The code below (memcache.py:399) sometimes (maybe always) store str into serverhash variable and cmemcache_hash/serverHashFunction function is failing because of that. The version 1.54 is ok.
def _get_server(self, key):
if isinstance(key, tuple):
serverhash, key = key
else:
serverhash = serverHashFunction(key)
...
Traceback (most recent call last):
File "/srv/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/srv/venv/lib/python3.4/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/srv/venv/lib/python3.4/site-packages/newrelic-2.54.0.41/newrelic/hooks/component_djangorestframework.py", line 8, in _nr_wrapper_APIView_dispatch_
return wrapped(*args, **kwargs)
File "/srv/venv/lib/python3.4/site-packages/rest_framework/views.py", line 456, in dispatch
response = self.handle_exception(exc)
File "/srv/venv/lib/python3.4/site-packages/rest_framework/views.py", line 453, in dispatch
response = handler(request, *args, **kwargs)
File "/srv/app/api/views/base.py", line 163, in post
return self.data_valid(serializer.validated_data)
File "/srv/app/api/views/get_suppliers_list.py", line 50, in data_valid
suppliers = cache.get(key)
File "/srv/venv/lib/python3.4/site-packages/django/core/cache/backends/memcached.py", line 85, in get
val = self._cache.get(key)
File "/srv/venv/lib/python3.4/site-packages/newrelic-2.54.0.41/newrelic/api/datastore_trace.py", line 43, in _nr_datastore_trace_wrapper_
return wrapped(*args, **kwargs)
File "/srv/venv/lib/python3.4/site-packages/memcache.py", line 1092, in get
return self._get('get', key)
File "/srv/venv/lib/python3.4/site-packages/memcache.py", line 1037, in _get
server, key = self._get_server(key)
File "/srv/venv/lib/python3.4/site-packages/memcache.py", line 416, in _get_server
serverhash = serverHashFunction(str(serverhash) + str(i))
File "/srv/venv/lib/python3.4/site-packages/memcache.py", line 66, in cmemcache_hash
(((binascii.crc32(key) & 0xffffffff)
TypeError: 'str' does not support the buffer interface
I'd like to had this location as well
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f00537e9f28>
Traceback (most recent call last):
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/media/francesco/A6528DA1528D76B9/Programmazione/Python/Spark/team_comp_site/teamcomp/apps.py", line 19, in ready
client.get_stats()
File "/home/francesco/virtualenvs/TeamCompSite/lib/python3.4/site-packages/memcache.py", line 338, in get_stats
stats = line.split(' ', 2)
TypeError: 'str' does not support the buffer interface