Skip to content

Inconsistent current directory after drive dismount/mount #126000

@k128

Description

@k128

Bug report

Bug description:

After disconnecting and reconnecting my external hard drive (with my current working directory on it), I get surprising results from the os:

>>> os.path.exists('test.csv')
False
>>> os.path.exists(os.path.join(os.getcwd(),'test.csv'))
True
>>> 'test.csv' in list(os.listdir())
True
>>> file=open('test.csv','r')
Traceback (most recent call last):
  File "<python-input-200>", line 1, in <module>
    file=open('test.csv','r')
OSError: [Errno 22] Invalid argument: 'test.csv'

Expected behavior: Keep the same working directory and only throw an error or return os.path.exists()=False if it is inaccessible at runtime.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions