[Python-checkins] r51624 - in python/trunk/Lib: genericpath.py macpath.py ntpath.py os2emxpath.py posixpath.py test/test_genericpath.py
Jack Diederich
jackdied at jackdied.com
Sun Aug 27 04:19:05 CEST 2006
On Sun, Aug 27, 2006 at 11:47:06AM +1100, Andrew MacIntyre wrote:
> jack.diederich wrote:
> > Author: jack.diederich
> > Date: Sat Aug 26 20:42:06 2006
> > New Revision: 51624
> >
> > Added:
> > python/trunk/Lib/genericpath.py
> > python/trunk/Lib/test/test_genericpath.py
> > Modified:
> > python/trunk/Lib/macpath.py
> > python/trunk/Lib/ntpath.py
> > python/trunk/Lib/os2emxpath.py
> > python/trunk/Lib/posixpath.py
> > Log:
> > - Move functions common to all path modules into genericpath.py and have the
> > OS speicifc path modules import them.
> > - Have os2emxpath import common functions fron ntpath instead of using copies
>
> When the EMX support was added, I asked about doing this (having
> os2emxpath import stuff from ntpath), and Guido's conclusion at the
> time was that the os2emxpath module should be independant of ntpath
> - even if there was significant duplication.
>
> I have no problem with the genericpath rationalisation, but request that
> the ntpath related changes to os2emxpath be reverted unless other advice
> to the contrary is forthcoming.
>
Thanks for the pointer, I found Guido's message
http://mail.python.org/pipermail/python-dev/2002-January/019427.html
The various modules ntpath, posixpath, macpath etc. are not just their
to support their own platform on itself. They are also there to
support foreign pathname twiddling. E.g. On Windows I might have a
need to munge posix paths -- I can do that by explicitly importing
posixpath. Likewise the reverse.
So I think changing ntpath.py to use os.set etc. would be wrong, and
creating a new file os2emxpath.py is the right thing to do -- despite
the endless cloning of the same code. :-( (Maybe a different way to
share more code between the XXXpath modules could be devised.)
Guido was objecting to having only one module that behaved differently
depending on which platform it was used. NT and EMX now only share the
functions that behave the same. ie you can import ntpath on an EMX and
use it to make NT style path names.
In that same Tim Peters replied
Create _commonpath.py and put shared routines there. Then a blahpath.py can
do
from _commonpath import f, g, h
to re-export them.
So I'm only three years or so behind in thinking of it.
FWIW Guido greenlit removing the code duplication on the py3k list
http://mail.python.org/pipermail/python-3000/2006-August/003218.html
Sounds like a great 2.6 project. Beware of things that are
intentionally different between platforms of course!
-Jack
More information about the Python-checkins
mailing list