'str' object has no attribute 'decode'
I am trying to use user caching, after setting "cache-storage=db" I am getting
File "/usr/lib/python3/dist-packages/xclib/utf8.py", line 19, in unutf8
return u.decode('utf-8', opts)
AttributeError: 'str' object has no attribute 'decode'
It seems like the object is already decoded. With this fix I was able to successfully enable user caching.
Codecov Report
Merging #76 into master will decrease coverage by
0.03%. The diff coverage is75%.
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
- Coverage 78.01% 77.98% -0.04%
==========================================
Files 18 18
Lines 928 931 +3
==========================================
+ Hits 724 726 +2
- Misses 204 205 +1
| Impacted Files | Coverage Δ | |
|---|---|---|
| xclib/utf8.py | 95.23% <75%> (-4.77%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 6a62dbc...28d96a1. Read the comment docs.
Thanks for the PR.
This triggered me to notice that I had disabled caching some time ago. I will reenable it and try to reproduce the problem (and add a test case).
At first glance, it looks like there should be a return u instead of the pass.
Also, during the refactoring, clearly distinguishing between str and bytes helped catch quite a few bugs. So I would like to avoid having an automatic conversion in this generic routine. This function is used throughout the code, and not only for accessing the cache. Therefore, I would suggest to this in the caller's code instead.
Would you like to try this?