strange interaction between open and cwd

Grant Edwards invalid at invalid.invalid
Mon May 3 13:12:09 EDT 2010


On 2010-05-03, Baz Walter <bazwal at ftml.net> wrote:

> it's a fact that realpath/abspath/normpath etc can fail for paths
> that don't when used with os.stat or the builtin open function.

True.

> i think it's reasonable to expect that a path that can be used to
> successfully open a file wont then produce "No such file or
> directory" errors when used with an os.path function like realpath.

Yes, I understand that's what you think.  That's not, however, a
reasonable expectation in some cases.

> it shouldn't be necessary to have detailed knowledge of the
> underlying filesytem to be able to use os.path - it's supposed to be
> generic.

If you ask for the path of a file that has no path (or for which the
path can't be determined from the provided information), what do you
propose should happen?

>>> there are files which can be opened for which it is impossible to
>>> resolve their full paths (on some platforms).
>>
>> Sort of.  The file in question _has_ a full path, you just can't tell
>> what it is based on the path you used to open it.
>
> yes, that's exactly what i was trying to demonstrate in my OP. i can
> use python to open a file; but under certain circumstances, there
> seems to be no guarantee that i can then use python to locate that
> file in the filesystem.

Exactly.

In your example, it's simply not possible to determine the file's
absolute path within the filesystem given the relative path you
provided.

You requested something that wasn't possible.  It failed.  What do you
think should have happened?

-- 
Grant Edwards               grant.b.edwards        Yow! There's enough money
                                  at               here to buy 5000 cans of
                              gmail.com            Noodle-Roni!



More information about the Python-list mailing list