[issue42032] Setting PYTHONPYCACHEPREFIX using ~ (tilde) creates a "~" folder

Veronica Olsen report at bugs.python.org
Wed Oct 14 11:09:42 EDT 2020


Veronica Olsen <jadzia626 at gmail.com> added the comment:

> AFAIK, tilde expansion is entirely up to your shell rather than Python

Yes, I am uncertain what exactly is going on here. Whatever ends up in the sys.pycache_prefix variable is different with the same environment variable setting on the two systems. It may simply be an OS quirk. I am running on Debian testing after all.

It is clear from the CPython source that Python does nothing with the tilde. It eventually calls os.makedirs() in the compile() function, which I guess is when my tilde folder was made.

It would perhaps be useful if the os.path.expanduser call was added in the cache_from_source() function in importlib?

As for the results from the debug checks:

1)
Debian: GNU bash, version 5.0.18(1)-release (x86_64-pc-linux-gnu)
Ubuntu: GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

2)
They both expand ~ to the home folder

3)
They both return ~/test

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42032>
_______________________________________


More information about the Python-bugs-list mailing list