I try to html escape a string
from html import escape
project_name_unescaped = Project.get('name').encode('utf-8')
project_name = escape(project_name_unescaped)
I get the following error
Traceback (most recent call last):
File "hosts.py", line 70, in <module>
project_name = escape(bytes(project_name_unescaped))
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/__init__.py", line 19, in escape
s = s.replace("&", "&") # Must be done first!
TypeError: a bytes-like object is required, not 'str'
I also tried it with the following, but still have the same error
project_name = escape(bytes(project_name_unescaped))
The strange thing is, I'm pretty sure this had worked before. Any ideas whats wrong or what I need to change to make it work again? Also I tried it before with
from cgi import escape