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

Undo tab python 3 TypeError: can't concat str to bytes #300

Closed
Ezka77 opened this issue Feb 16, 2018 · 2 comments
Closed

Undo tab python 3 TypeError: can't concat str to bytes #300

Ezka77 opened this issue Feb 16, 2018 · 2 comments

Comments

@Ezka77
Copy link

Ezka77 commented Feb 16, 2018

Hi,
With python >= 3.5 there is an issue with the Undo tab, server fail with:

  File "/home/theo/.local/share/virtualenvs/starbox-R9wHKfrZ/lib/python3.6/site-packages/substanced/sdi/views/undo.py", line 158, in undo
    batch = self._undoable_transactions(first, last)
  File "/home/theo/.local/share/virtualenvs/starbox-R9wHKfrZ/lib/python3.6/site-packages/substanced/sdi/views/undo.py", line 141, in _undoable_transactions
    tid = encode64(tid) + b' ' + desc
TypeError: can't concat str to bytes

There is no str to bytes implicit conversion. Here a diff to make it work in python 2.7 and 3.5 :

diff --git a/substanced/sdi/views/undo.py b/substanced/sdi/views/undo.py
index 5d241d01..5f9fab08 100644
--- a/substanced/sdi/views/undo.py
+++ b/substanced/sdi/views/undo.py
@@ -128,7 +128,7 @@ class UndoViews(object):
             t = datetime.datetime.fromtimestamp(d['time'])
             t = tz.localize(t).strftime('%Y-%m-%d %H:%M:%S %Z')
             d['time'] = t
-            desc = d['description'] or b''
+            desc = d['description'].encode('ascii') or b''
             if not isinstance(desc, bytes): #pragma NO COVER Py3k
                 desc = desc.encode('ascii', 'surrogateescape')
             tid = d['id']
@cguardia
Copy link
Member

Hi, thanks for the ticket. Judging from the traceback, you are running the pypi released version, right? This problem has been corrected on master. I just confirmed it works on Python 3.5.2.

@Ezka77
Copy link
Author

Ezka77 commented Feb 19, 2018

Hi,
You're right, I'm using the pypie version and it's corrected on master.

@Ezka77 Ezka77 closed this as completed Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants