[Distutils] normpath/abspath problem

Fred L. Drake, Jr. fdrake@beopen.com
Thu, 3 Aug 2000 22:21:03 -0400 (EDT)

Greg Ward writes:
 > He has an alternate version which sounds agreeable to the MacPython
 > folks, so there's a good chance it'll be in Python 2.0, and possibly
 > 1.6.  To maintain full compatibility with 1.5.2, though, we'd have to
 > include it in the Distutils and use it if necessary, eg.
 >     def mac_normpath (path):
 >         ...

  So far so good.

 >     if mac and python < 1.6:
 >         normpath = mac_normpath
 >     else:
 >         normpath = os.path.normpath

  How about:

import sys
except AttributeError:
    import macpath
    macpath = mac_normpath

  Simple, and doesn't require any platform tests.  (sys.version_info
is new starting in version 1.6.)

 > But then what about abspath(), which uses normpath()?  macpath.abspath()
 > -- like the other two abspath() implementations -- calls normpath(), but
 > it would end up calling the version in macpath.py, which will still be
 > broken.

  This solution fixes all callers of macpath.normpath without
additional magic.  Keep It Simple.  ;)


Fred L. Drake, Jr.  <fdrake at beopen.com>
BeOpen PythonLabs Team Member