strange interaction between open and cwd
Grant Edwards
invalid at invalid.invalid
Mon May 3 14:12:10 EDT 2010
On 2010-05-03, Baz Walter <bazwal at ftml.net> wrote:
>> You requested something that wasn't possible. It failed. What do
>> you think should have happened?
>
> path = '../abc.txt'
>
> os.path.realpath(path) -> "OSError: [Errno 2] No such file or directory"
>
> therefore:
>
> open(path) -> "IOError: [Errno 2] No such file or directory"
>
> i think that if the first of these seemingly "impossible" requests
> fails, it is reasonable to expect that the second one also fails. but
> the second one (sometimes) doesn't.
Because the second one isn't impossible in the case you posted.
> i think they should always either both succeed, or both fail.
That's not how Unix filesystems work.
Are you saying that Python should add code to it's open() builtin
which calls realpath() and then refuses to open files for which
realpath() fails? Even though the user provided a legal and openable
path?
--
Grant Edwards grant.b.edwards Yow! Did I say I was
at a sardine? Or a bus???
gmail.com
More information about the Python-list
mailing list