[Twisted-Python] Re: plus mode was Re: how winnt fileops work and what to do about it
Paul G
paul-lists at perforge.com
Sat Dec 31 15:21:45 EST 2005
----- Original Message -----
From: "Cory Dodt" <corydodt at twistedmatrix.com>
To: "Twisted general discussion" <twisted-python at twistedmatrix.com>
Sent: Saturday, December 31, 2005 1:46 PM
Subject: [Twisted-Python] Re: plus mode was Re: how winnt fileops work and
what to do about it
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Paul, flush fixes one kind of insanity and seek fixes another:
>
> One ===========
> $ echo abcdef > foo
> $ python
>>>> f = file('foo', 'r+b')
>>>> f.write('ghi')
>>>> f.flush()
>>>> f.read()
> 'def\n'
>>>> # hooray!
>
>
> Two ===========
> $ echo abcdef > foo
> $ python
>>>> f = file('foo','r+b')
>>>> f.read()
> 'abcdef\n'
>>>> f.seek(7, 0)
>>>> f.write('xyz')
>>>> ^D
> $ cat foo
> abcdef
> xyz
> $ # hooray
>
> Paul - Do you still think this is a Python bug?
depends on what you call a bug. this behaviour is, afaik, specific to
microsoft libc's (aka c runtime) implementation of file streams. since
their implementation exhibits arcanely and somewhat subtly (subtle in terms
of cause, as opposed to effect - the effect is quite apparent) divergent
behaviour, it definitely violates the users' expectations, so it is a bug in
that sense. with that said, they never claimed to be $standard compliant and
they do document this, iirc, so it is not quite a bug in that sense. in
practical terms, their implementation is not likely to 'get fixed', so the
failure to deal with this quirk is a python bug. there are two options for
python:
1. say that python expects users to be aware of quirks on specific platforms
and the responsibility of dealing with them lies with the user. in this
case, this quirk needs to be mentioned in the python docs, since it is not
reasonable to expect people to figure out that they need to look at msdn c
runtime api docs.
2. say that across all platforms python supports given functionality on,
said functionality needs to have functionally identical results given
identical input. in this case, the flush+seek workaround needs to be
utilized on all cpythons linked with msvscrt in a manner transparent to the
user.
make sense?
-p
More information about the Twisted-Python
mailing list