[Python-Dev] os.path.normcase() in site.py

Just van Rossum just@letterror.com
Mon, 25 Jun 2001 18:47:30 +0200


Guido van Rossum writes:
> I can't think of any function besides the attempt to avoid duplicates.

Fred L. Drake, Jr. wrote:
>   There were two reasons for adding this code:
> 
>     1.  Avoid duplicates (speeds imports if there are duplicates and
>         the modules are found on an entry after the dupes).
>
>     2.  Avoid breakage when a script uses os.chdir().  This is
>         probably unusual for large applications, but fairly common for
>         little admin helper scripts.

1) normcase(). Bad.
2) abspath(). Good.

I think #2 is a ligitimate problem, but I'm not so sure of #1: is it really so
common for sys.path to contain duplicates, to worry about it at all?

>  > I'll leave it to Fred, Jack or Just to fix this.
> 
>   I certainly agree that this can be improved; if Jack or Just would
> like to assign it to me on SourceForge, I'd be glad to fix it.

Here's my proposed fix:

Index: site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v
retrieving revision 1.27
diff -c -3 -r1.27 site.py
*** site.py 2001/06/12 16:48:52 1.27
--- site.py 2001/06/25 16:42:33
***************
*** 67,73 ****
  
  def makepath(*paths):
      dir = os.path.join(*paths)
!     return os.path.normcase(os.path.abspath(dir))
  
  L = sys.modules.values()
  for m in L:
--- 67,73 ----
  
  def makepath(*paths):
      dir = os.path.join(*paths)
!     return os.path.abspath(dir)
  
  L = sys.modules.values()
  for m in L:


Just