/usr/lib/python2.7/dist-packages/flask_wtf/_compat.py is in python-flaskext.wtf 0.12-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import sys
if sys.version_info[0] == 3:
text_type = str
string_types = (str,)
else:
text_type = unicode
string_types = (str, unicode)
def to_bytes(text):
"""Transform string to bytes."""
if isinstance(text, text_type):
text = text.encode('utf-8')
return text
def to_unicode(input_bytes, encoding='utf-8'):
"""Decodes input_bytes to text if needed."""
if not isinstance(input_bytes, string_types):
input_bytes = input_bytes.decode(encoding)
return input_bytes
|