New submission from benrg <[email protected]>:
`importlib._bootstrap_external` contains this comment:
# We need an absolute path to the py file to avoid the possibility of
# collisions within sys.pycache_prefix [...]
# [...] the idea here is that if we get `Foo\Bar`, we first
# make it absolute (`C:\Somewhere\Foo\Bar`), then make it root-relative
# (`Somewhere\Foo\Bar`), so we end up placing the bytecode file in an
# unambiguous `C:\Bytecode\Somewhere\Foo\Bar\`.
The code follows the comment, but doesn't achieve the goal:
`C:\Somewhere\Foo\Bar` and `D:\Somewhere\Foo\Bar` collide. There is also no
explicit handling of UNC paths, with the result that `\\Somewhere\Foo\Bar` maps
to the same location.
I think that on Windows the code should use a mapping like
C:\Somewhere\Foo\Bar ==> C:\Bytecode\C\Somewhere\Foo\Bar
D:\Somewhere\Foo\Bar ==> C:\Bytecode\D\Somewhere\Foo\Bar
\\Somewhere\Foo\Bar ==> C:\Bytecode\UNC\Somewhere\Foo\Bar
The lack of double-slash prefix handling also matters on Unixy platforms that
give it a special meaning. Cygwin is probably affected by this. I don't know
whether there are any others.
----------
components: Library (Lib), Windows
messages: 413878
nosy: benrg, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: py to pyc location mapping with sys.pycache_prefix isn't 1-to-1 on
Windows
type: behavior
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46842>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com