file object, details of modes and some issues.

Michael Hudson mwh at python.net
Tue Aug 26 14:37:03 EDT 2003


simon place <simon_place at lineone.net> writes:

> is the code below meant to produce rubbish?

Python uses C's stdio.  According to the C standard:

>, i had expected an exception.
> 
> f=file('readme.txt','w')
> f.write(' ')
> f.read()

engages in undefined behaviour (i.e. is perfectly entitled to make
demons fly out of your nose).  You can apparently trigger hair-raising
crashes on Win98 by playing along these lines.  There's not a lot that
Python can do about this except include it's own implementation of a
stdio-a-like, and indeed some future version of Python may do just
this.

Cheers,
mwh

-- 
  <arigo> something happens, what I'm not exactly sure.
                                                 -- PyPy debugging fun




More information about the Python-list mailing list