[Python-3000] On PEP 3116: new I/O base classes

Nick Coghlan ncoghlan at gmail.com
Fri Jun 22 14:18:10 CEST 2007


Daniel Stutzbach wrote:

> If the cookie is meant to be opaque to the caller, is there a reason 
> that the cookie must be an integer?
> 
> Specifying the return type as opaque might also reduce the temptation
>  to do perform arithmetic on them, which will work for some codecs 
> (ASCII), but break later in odd ways for others.

seek() & tell() are already documented as using opaque cookies for text
files (quote is from the documentation of file.seek()):

	If the file is opened in text mode (without 'b'), only offsets
	returned by tell() are legal. Use of other offsets causes
	undefined behavior.

(Seeking to an arbitrary byte index on a file with DOS line endings may 
put you in the middle of a \r\n sequence, which may cause weirdness)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list