Conflict Between Python1.5.2b2 and win32all-123

Mark Hammond MHammond at skippinet.com.au
Mon Apr 5 22:24:59 EDT 1999


Jonathan Polley wrote in message <01be7fc6$af6c11e0$01656565 at fidget>...

>I have installed Python 1.5.2b2 then installed win32all-123.  When I invoke
>IDLE with a file name on the commandline, I get the following error:
>
>Traceback (innermost last):
<snip>
>  File "C:\Program Files\Python\Lib\ntpath.py", line 398, in abspath
>    return win32api.GetFullPathName(path)
>api_error: (161, 'GetFullPathName', 'The specified path is invalid.')
>
>
>If I remove pythonwin, the error goes away.  Since I don't plan on running
>IDLE with files as arguments, the current behavior is not an issue for me.

This is because of a bug in the new version of ntpath.py - I never noticed
it attempts to use win32api before.

When you install win32all, you get win32api, so the functionality of ntpath
changes.

The problem is that win32api.GetFullPathName actually fails if the path name
is invalid, whereas the version that works without win32api does not.

I suggest the following patch ntpath.py (note - against the CVS tree, not
the b2 release - but it should be obvious to apply manually):

Mark.

RCS file: /projects/cvsroot/python/dist/src/Lib/ntpath.py,v
retrieving revision 1.18
diff -c -r1.18 ntpath.py
*** ntpath.py   1999/03/19 21:03:54     1.18
--- ntpath.py   1999/04/06 02:19:25
***************
*** 388,394 ****
      """Return the absolute version of a path"""
      try:
          import win32api
!         return win32api.GetFullPathName(path)
      except ImportError:
          if not isabs(path):
              path = join(os.getcwd(), path)
--- 388,397 ----
      """Return the absolute version of a path"""
      try:
          import win32api
!         try:
!             return win32api.GetFullPathName(path)
!         except win32api.error:
!             return path # Bad path - return unchanged.
      except ImportError:
          if not isabs(path):
              path = join(os.getcwd(), path)








More information about the Python-list mailing list