On Tue, 19 Mar 2013 21:44:15 -0700
Michael Foord <fuzzy...@voidspace.org.uk> wrote:
> 
> mock_open makes it easy to put a StringIO in place if that's what you want. 
> It's just a simple helper function for providing some known data *along with 
> the Mock api* to make asserts that it was used correctly. It isn't presenting 
> a full file-system. My suggestion to the implementor of the patch was that 
> read / readline / readlines be disconnected - but the patch provided allows 
> them to be interleaved and I saw no reason to undo that.
> 
> If users want more complex behaviour (like universal newline support) they 
> can use mock_open along with a StringIO.

This is not about complex behaviour but simply correct behaviour.
For the record, universal newlines are enabled by default in Python 3:

>>> with open("foo", "wb") as f: f.write(b"a\r\nb\rc\n")
... 
7
>>> with open("foo", "r") as f: print(list(f))
... 
['a\n', 'b\n', 'c\n']


Regards

Antoine.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to