Skip to content

decode bytes for svg - #308

Open
KnathanM wants to merge 1 commit into
mainfrom
KnathanM-stop-the-error-emails
Open

decode bytes for svg#308
KnathanM wants to merge 1 commit into
mainfrom
KnathanM-stop-the-error-emails

Conversation

@KnathanM

Copy link
Copy Markdown
Contributor

rmg website seems to be using Python 2 syntax, where bytes were automatically decoded to strings. When drawing a group, the svg data is returned as bytes, and in python 3 the data needs to be explicitly decoded to a string.

Original error message:

Traceback (most recent call last):
  File ".../rmgweb/main/views.py", line 381, in drawGroup
    svg_data = re.sub(r'scale\(0\.722222 0\.722222\) rotate\(0\) ', '', svg_data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: TypeError at /group/1 *1 N u0 p1 c0 {2,S} {5,S} {6,S}
2 *2 N u0 p1 c0 {1,S} {3,S} {4,S}
3 *3 N u0 p1 c0 {2,S}
4 *4 H u0 p0 c0 {2,S}
5    H u0 p0 c0 {1,S}
6    H u0 p0 c0 {1,S}
/svg
Exception Value: cannot use a string pattern on a bytes-like object 

There might be other instances of this svg bytes not being decoded error in the code, but from the error logs it looks like the error is only raised in main/views.py.

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

Successfully merging this pull request may close these issues.

1 participant