#150 closed defect (wontfix)
python: deal with reverse /@unixroot replacement
Reported by: | dmik | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | python | Version: | |
Severity: | medium | Keywords: | |
Cc: |
Description
When doing some path absolutization, python causes /@unixroot
in paths to be replaced with the actual value of $UNIXROOT (e.g. "C:"). This gives for paths like /@unixroot/usr/bin/python.exe
paths like C:/USR/BIN/python.exe
. The main problem with these paths is that they are not portable across different installations (i.e. installations using different UNIXROOT settings, e.g. different drive letters or such).
One such problem is shown in r529. But there are surely more of these.
Attachments (1)
Change History (4)
comment:1 by , 9 years ago
Type: | task → defect |
---|
by , 9 years ago
Attachment: | os2knixpath.py.diff added |
---|
comment:2 by , 9 years ago
After some more thinking I suppose it's a bad idea. As Yuri already mentioned, the user may supply some path completely unrelated to our FHS tree (e.g. something like C:/programs/blabla
) and it will also be changed. Second, such a replacement is not expected behavior anyway. So we should better provide os.path.normcase_unixroot
for replacing the value of $UNIXROOT with /@unixroot
(and only for FHS paths like /@unxroot/usr, /@unixroot/etc, etc) and, perhaps, the reverse operation os.path.normcase_nounixroot
, which will replace /@unxroot/
with the real value of $UNIXROOT.
comment:3 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
is this still valid? if yes please add a issue at the python github project. https://github.com/bitwiseworks/python-os2
While looking around, I came across
os.path.normcase
which is intended to normalize the path. On Windows and OS/2 it makes it lowercase and also translates all separators toos.path.sep
. Normalization is by nature a thing intended to make objects comparable and transferrable - so something really close to what we need. So we may insert a replacement similar to r529 right in this function.I tried to set it on my machine and give it some test In my environment that intensively uses python (e.g. for building Mozilla), the diff is attached.
The only possible drawback so far is that the normcased string may be passed to some non-kLIBC based application but I can't recall any practical case when it takes place. All current unix tools are kLIBC-based (and those which are not must be made such). Native programs are a bit out of the question here since
normcase
returns paths with/
and many of them can't stand it anyway.To be on the safe side, we can introduce
os.path.normcase_unixroot
instead and call it in places where we are sure such normalization is necessary. But this will, first, require us to use theif os.name = 'os2'
predicate and, second, may potentially require a lot of changes.