Skip to content

Commit c779b3e

Browse files
authored
Merge pull request #246 from swartchris8/master
Handle unicode files in a Python 2 and 3 compatible fassion using io.open
2 parents 7f11d42 + 58439f4 commit c779b3e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

memory_profiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
import linecache
1616
import logging
1717
import os
18+
from io import open
1819
import pdb
1920
import subprocess
2021
import sys
2122
import time
2223
import traceback
2324
import warnings
2425

26+
2527
if sys.platform == "win32":
2628
# any value except signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT
2729
# can be used to kill a process unconditionally in Windows
@@ -1246,6 +1248,7 @@ def exec_with_profiler(filename, profiler, backend, passed_args=[]):
12461248
try:
12471249
if _backend == 'tracemalloc' and has_tracemalloc:
12481250
tracemalloc.start()
1251+
12491252
with open(filename, encoding='utf-8') as f:
12501253
exec(compile(f.read(), filename, 'exec'), ns, ns)
12511254
finally:

test/test_unicode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
# run only for Python 2.xx
32
@profile
43
def test_unicode(txt):
54
# test when unicode is present

0 commit comments

Comments
 (0)