Skip to content

Name 'basestring' is not defined (django error) #43

Closed
@khajvahmac

Description

Using python 3.4.2 and django 1.7

Here is the traceback:

File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\User\Project\miraFrontEnd\manageDb\views.py" in mira_cacl
  329.     cache_chains.set(1 + cache_chains.get('count'), a, None)
File "C:\Python34\lib\site-packages\django\core\cache\backends\memcached.py" in set
  89.         self._cache.set(key, value, self.get_backend_timeout(timeout))
File "C:\Python34\lib\site-packages\pymemcache\client.py" in set
  335.         return self._store_cmd(b'set', key, expire, noreply, value)
File "C:\Python34\lib\site-packages\pymemcache\client.py" in _store_cmd
  749.             data, flags = self.serializer(key, data)
File "C:\Python34\lib\site-packages\djpymemcache\backend.py" in serialize_pickle
  27.     if isinstance(value, basestring):
Exception Type: NameError at /manageDb/mira/miracalc/
Exception Value: name 'basestring' is not defined

Possible fix:

I have added following lines in the beginning of \site-packages\djpymemcache\backend.py and it worked:

try:
    unicode = unicode
except NameError:
    # 'unicode' is undefined, must be Python 3
    str = str
    unicode = str
    bytes = bytes
    basestring = (str,bytes)
else:
    # 'unicode' exists, must be Python 2
    str = str
    unicode = unicode
    bytes = str
    basestring = basestring

Note that I didn't write those lines. I took it from here

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions