summaryrefslogtreecommitdiffstats
path: root/Lib/cProfile.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2020-10-18 20:48:31 (GMT)
committerGitHub <noreply@github.com>2020-10-18 20:48:31 (GMT)
commit3c0ac18504cfeed822439024339d5717f42bdd66 (patch)
tree5856fb42353bd419b9c39f6d2790dec194f3d5fc /Lib/cProfile.py
parentb81c833ab51fb7d7f0f8eaace37f60ef7455aa85 (diff)
downloadcpython-3c0ac18504cfeed822439024339d5717f42bdd66.zip
cpython-3c0ac18504cfeed822439024339d5717f42bdd66.tar.gz
cpython-3c0ac18504cfeed822439024339d5717f42bdd66.tar.bz2
bpo-40492: Fix --outfile with relative path when the program changes it working dir (GH-19910)
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-xLib/cProfile.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 4f20203..59b4699 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -152,6 +152,11 @@ def main():
(options, args) = parser.parse_args()
sys.argv[:] = args
+ # The script that we're profiling may chdir, so capture the absolute path
+ # to the output file at startup.
+ if options.outfile is not None:
+ options.outfile = os.path.abspath(options.outfile)
+
if len(args) > 0:
if options.module:
code = "run_module(modname, run_name='__main__')"