/usr/lib/pypy/dist-packages/flaky/utils.py is in pypy-flaky 3.1.0-1.
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 22 23 24 25 26 27 28 29 | # coding: utf-8
from __future__ import unicode_literals
# pylint:disable=invalid-name
try:
unicode_type = unicode
except NameError:
unicode_type = str
def ensure_unicode_string(obj):
"""
Return a unicode string representation of the given obj.
:param obj:
The obj we want to represent in unicode
:type obj:
varies
:rtype:
`unicode`
"""
try:
return unicode_type(obj)
except UnicodeDecodeError:
if hasattr(obj, 'decode'):
return obj.decode('utf-8', 'replace')
else:
return str(obj).decode('utf-8', 'replace')
|