New os.path.exists() behavior - bug or feature?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • klappnase

    #1

    New os.path.exists() behavior - bug or feature?

    Hi all,
    yesterday I installed Python-2.5 and python-2.4.4 on my windows2k box.
    When trying to use os.path.exists( ) to detect which drives are present
    on the system I noticed that
    these behave differently:

    Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
    on win32
    Type "copyright" , "credits" or "license()" for more information.
    >>import os
    >>for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
    if os.path.exists( '%s:\\' % char):
    print '%s:\\' % char


    A:\
    C:\
    D:\
    E:\
    >>>
    ############### ############### #############

    Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
    (Intel)] on win32
    Type "copyright" , "credits" or "license()" for more information.
    >>import os
    >>for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
    if os.path.exists( '%s:\\' % char):
    print '%s:\\' % char


    C:\
    >>>
    When I insert a floppy into A: os.path.exists( 'A:\\') will return True
    on Python-2.5, too.
    Does anyone know, is this inconsistent behavior a bug or a new feature?

    I also noticed that the Tix binaries are no longer present in 2.5, does
    anyone know if it is
    planned to remove them pemanently?

    Thanks in advance

    Michael

  • =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

    #2
    Re: New os.path.exists( ) behavior - bug or feature?

    klappnase schrieb:
    When I insert a floppy into A: os.path.exists( 'A:\\') will return True
    on Python-2.5, too.
    Does anyone know, is this inconsistent behavior a bug or a new feature?
    Neither, nor. In both cases, the operating system is asked, and gives
    this answer. However, in the Windows API, there is no "exists" function
    (nor is there on Unix); instead, exists is implemented by calling
    several underlying functions. The precise set of functions used did
    change between 2.4 and 2.5.

    It is quite difficult to investigate the precise nature of the change
    that leads to this change in observable behavior. If you think this is
    a bug, it would be best if you could also investigate a patch.
    I also noticed that the Tix binaries are no longer present in 2.5, does
    anyone know if it is
    planned to remove them pemanently?
    That was a mistake, I'll add it back in 2.5.1.

    Regards,
    Martin

    Comment

    • klappnase

      #3
      Re: New os.path.exists( ) behavior - bug or feature?


      Martin v. Löwis schrieb:
      >
      Neither, nor. In both cases, the operating system is asked, and gives
      this answer. However, in the Windows API, there is no "exists" function
      (nor is there on Unix); instead, exists is implemented by calling
      several underlying functions. The precise set of functions used did
      change between 2.4 and 2.5.
      >
      It is quite difficult to investigate the precise nature of the change
      that leads to this change in observable behavior. If you think this is
      a bug, it would be best if you could also investigate a patch.
      >
      I don't know if it is a bug; at least it is backwards incompatible,
      which I think is never a good thing.
      Unfortunately, I am afraid writing a patch is beyond my expertise :(

      Regards

      Michael

      Comment

      • Martin Miller

        #4
        Re: New os.path.exists( ) behavior - bug or feature?

        FWIW, your code works correctly for me in all respects with Python 2.5
        on Windows XP Pro.
        I no longer have Python 2.4.x installed, so can't easily do a
        comparison.

        Perhaps the problem has something to do with Python 2.5 with Windows
        2K.

        -Martin


        On Dec 17 2006, 4:29 pm, "klappnase" <klappn...@web. dewrote:
        Hi all,
        yesterday I installed Python-2.5 and python-2.4.4 on my windows2k box.
        When trying to use os.path.exists( ) to detect which drives are present
        on the system I noticed that
        these behave differently:
        >
        Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
        on win32
        Type "copyright" , "credits" or "license()" for more information.
        >
        >import os
        >for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ': if os.path.exists( '%s:\\' % char):
        print '%s:\\' % char
        >
        A:\
        C:\
        D:\
        E:\
        >
        ############### ############### #############
        >
        Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
        (Intel)] on win32
        Type "copyright" , "credits" or "license()" for more information.
        >
        >import os
        >for char in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ': if os.path.exists( '%s:\\' % char):
        print '%s:\\' % char
        >
        C:\
        >
        When I insert a floppy into A: os.path.exists( 'A:\\') will return True
        on Python-2.5, too.
        Does anyone know, is this inconsistent behavior a bug or a new feature?
        >
        I also noticed that theTixbinaries are no longer present in 2.5, does
        anyone know if it is
        planned to remove them pemanently?
        >
        Thanks in advance
        >
        Michael

        Comment

        Working...