[rhel7/master/f21 1/2 V2] Create missing parent directories for user's home directory (#1163775)

Anne Mulhern amulhern at redhat.com
Tue Nov 18 21:00:40 UTC 2014



> > 
> > Would be nicer to use os.path.join() here.
> 
> I hate os.path.join, it doesn't do what you expect when trailing
> elements start with a / (not the case here, but still shouldn't be
> used).

Yes, I'm aware of that behavior.

But it's only in our friendly *nix world that / gets to so conveniently
be a separator or the unique root, depending on context.

In NT world, you could end up with something like
dir1 = c:\home\junk
dir2 = d:\bin\z

possibly corresponding to in *nix
dir1 = /home/junk
dir2 = /bin/z

and it's hard to see justifying ntpath.join(dir1, dir2) evaluating to c:\home\junk\bin\z.

So, in an effort to be consistent, I think posixpath.join(dir1, dir2) has to avoid
evaluating to /home/junk/bin/z.

Picking the last argument is better than returning nothing and may be better than raising an exception.
Nobody told me the reasoning behind that decision.

Or course, it doesn't really matter whether join or simple string manipulations are used, so long as
the code only ever runs on POSIX systems. posixpath.join() is only 9 very simple lines and inserting
fragments of it in our code over and over again is not a big deal.

- mulhern


More information about the anaconda-patches mailing list