Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathlib in execution #12605

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions IPython/core/magics/execution.py
Expand Up @@ -18,6 +18,7 @@
import math
import re
from pdb import Restart
from pathlib import Path

import cProfile as profile
import pstats
Expand Down Expand Up @@ -356,13 +357,13 @@ def _run_with_profiler(self, code, opts, namespace):
print(sys_exit, end=' ')

dump_file = opts.D[0]
text_file = opts.T[0]
text_file = Path(opts.T[0])
if dump_file:
prof.dump_stats(dump_file)
print('\n*** Profile stats marshalled to file',\
repr(dump_file)+'.',sys_exit)
if text_file:
with open(text_file, 'w') as pfile:
with text_file.open("w") as pfile:
pfile.write(output)
print('\n*** Profile printout saved to text file',\
repr(text_file)+'.',sys_exit)
Expand Down