Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: sequence item 0: expected str instance bytes found #25

Closed
reubano opened this issue Mar 25, 2017 · 8 comments
Closed

TypeError: sequence item 0: expected str instance bytes found #25

reubano opened this issue Mar 25, 2017 · 8 comments

Comments

@reubano
Copy link

reubano commented Mar 25, 2017

Exception possibly due to cache backend.
Traceback (most recent call last):
  File "https://github.com/sh4nks/flask-caching/blob/master/flask_caching/__init__.py"
    rv = self.cache.get(cache_key)
  File "https://github.com/sh4nks/flask-caching/blob/master/flask_caching/backends/clients.py"
    return self._get(key)
    serialized = ''.join([v for v in result if v is not None]
TypeError: sequence item 0: expected str instance, bytes found

Python 3.6.0
Flask-Cache==0.13.1

@reubano
Copy link
Author

reubano commented Mar 25, 2017

The error happens on heroku but not my laptop.

@reubano
Copy link
Author

reubano commented Mar 25, 2017

Also key_prefix is request.url.

@sh4nks
Copy link
Collaborator

sh4nks commented Apr 8, 2017

I am having a hard time to reproduce this. What did you do that this happens?

@reubano
Copy link
Author

reubano commented Apr 20, 2017

Nothing I haven't normally done. Just using @cache.cached() with the spreadsaslmemcached backend. I even tested the original plugin and got the same error. You can see how I solved the problem here. I assumed it was a py2/py3 thing. But now I suspect it's a difference in the memcache libs. Maybe heroku's version has some setting that triggers bytes.

@sh4nks
Copy link
Collaborator

sh4nks commented Apr 20, 2017

Could you provide a test that fails? btw, how is mezmorize different from Flask-Caching? Maybe we should put our resources together instead of maintaining a slightly different version of Flask-Cache?

@reubano
Copy link
Author

reubano commented Apr 20, 2017

mezmorize is basically just the memoization part of Flask-Cache and also without the flask dep. It's meant to memoize regular functions (similar to lru_cache), not to be used on routes. I haven't gotten around to writing up documentation yet. Sure, I'd be open to collaborating since it really is just a subset. It should be possible to figure out a way to support both use cases in the same codebase.

@reubano
Copy link
Author

reubano commented Apr 20, 2017

My project is fairly large so extracting a base test case may take a while. Could you post the code you tried using to reproduce the issue? I could then work from that.

@sh4nks
Copy link
Collaborator

sh4nks commented Apr 21, 2017

I am using it with redis at forums.flaskbb.org and I never ran into this issue (same for simple). I haven't tried it with memcache but I could imagine that it's a problem with the memcache libs as you have said.

I am not seeing a huge difference apart from the @cache.cached decorator. If I have a some spare time this weekend I'll try to put something together (i.e. Flask-Caching simple being a wrapper around mezmorize with an additional decorator for routes.).

@sh4nks sh4nks closed this as completed in 32715b5 Jun 23, 2017
reubano referenced this issue in reubano/mezmorize Aug 15, 2017
* features:
  Bump to version 0.20.0
  Minor refactoring
  Fix tests and lint errors
  [NEW] Add ability to set preferred mc module
  Refactor cache option setting
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants