Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions memory_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@

if PY2:
import __builtin__ as builtins
to_str = lambda x: x
from future_builtins import filter
else:
import builtins


def unicode(x, *args):
return str(x)
to_str = lambda x: str(x)

# .. get available packages ..
try:
Expand Down Expand Up @@ -778,7 +776,7 @@ def show_results(prof, stream=None, precision=1):
mem = u''
inc = u''
tmp = template.format(lineno, mem, inc, all_lines[lineno - 1])
stream.write(unicode(tmp, 'UTF-8'))
stream.write(to_str(tmp))
stream.write(u'\n\n')


Expand Down
14 changes: 14 additions & 0 deletions test/test_stream_unicode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

from memory_profiler import profile

f = open('/dev/null', 'w')
@profile(stream=f)
def test_unicode(txt):
# test when unicode is present
txt = txt.replace (u"ی", u"ي") #Arabic Yah = ي
return txt


if __name__ == '__main__':
test_unicode (u"ایست")