New submission from Anthony Sottile <asott...@umich.edu>:

just spent quite a bit of time debugging this, here's a minimal example:

```bash
# rm -rf a (if you want to reset)
cd /tmp
mkdir -p a/b
echo 'import os; os.chdir("..")' > a/b/c.py
cd a/b
python3 -m cProfile -o log.pstats c.py
ls -al
ls -al ..
```

example output:

```console
$ cd /tmp
$ mkdir -p a/b
$ echo 'import os; os.chdir("..")' > a/b/c.py
$ cd a/b
$ python3 -m cProfile -o log.pstats c.py
$ ls -al
total 12
drwxr-xr-x 2 asottile asottile 4096 May  3 20:35 .
drwxr-xr-x 3 asottile asottile 4096 May  3 20:35 ..
-rw-r--r-- 1 asottile asottile   26 May  3 20:35 c.py
$ ls -al ..
total 16
drwxr-xr-x  3 asottile asottile 4096 May  3 20:35 .
drwxrwxrwt 28 root     root     4096 May  3 20:35 ..
drwxr-xr-x  2 asottile asottile 4096 May  3 20:35 b
-rw-r--r--  1 asottile asottile  395 May  3 20:35 log.pstats
```

happy to work on a patch if this seems like a good idea to fix

----------
components: Library (Lib)
messages: 368008
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: -m cProfile -o f.pstats with a script that does chdir() writes to the 
changed directory and not `.`
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40492>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to