Opened 4 years ago

Last modified 4 years ago

#150 new defect

python: deal with reverse /@unixroot replacement

Reported by: dmik Owned by:
Priority: major Milestone:
Component: python Version:
Severity: medium Keywords:


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) (1.5 KB) - added by dmik 4 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 4 years ago by dmik

Type: taskdefect

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 to os.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 the if = 'os2' predicate and, second, may potentially require a lot of changes.

Changed 4 years ago by dmik

Attachment: added

comment:2 Changed 4 years ago by dmik

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.

Note: See TracTickets for help on using tickets.