[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-10 Thread Roundup Robot
Roundup Robot added the comment: New changeset 57fc950298bb by Martin Panter in branch '2.7': Issue #22413: Document newline effect on StringIO initializer and getvalue https://hg.python.org/cpython/rev/57fc950298bb New changeset cba4bf2a1721 by Martin Panter in branch '3.4': Issue #22413:

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-10 Thread Martin Panter
Changes by Martin Panter : -- resolution: wont fix -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-09 Thread Martin Panter
Martin Panter added the comment: Thanks for the feedback. Yeah, 2.7 is an independent branch, but I will try porting the changes there. -- assignee: docs@python -> martin.panter nosy: +berker.peksag stage: patch review -> commit review ___ Python

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-05 Thread Guido van Rossum
Guido van Rossum added the comment: The patch fails to apply in the 2.7 branch. It works in 3.4. Could you look into the 2.7 issue? -- ___ Python tracker

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-05 Thread Guido van Rossum
Guido van Rossum added the comment: It looks like we don't merge 2.7 into 3.4 any more, so that will have to be a separate patch anyway. So you can commit the patch to 3.4, merge into 3.5 and 3.6. Good luck! And thanks for your perseverance. --

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-03 Thread Martin Panter
Martin Panter added the comment: Here is a suggested patch. I did include details of the initializer and getvalue(); this is the heart of the problem IMO. In a limited sense the newline flag _is_ similar to TextIOWrapper, but more broadly this implied to me that newlines should be encoded in

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-10-01 Thread Guido van Rossum
Guido van Rossum added the comment: I don't see a reason to deprecate anything. Can you write up in one paragraph how StringIO's newline flag differs from the one to TextIOWrapper? (What happens to the initial value is a separate issue AFAIC.) --

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-30 Thread Martin Panter
Martin Panter added the comment: I understand it may not be worth changing the behaviour. Would you instead accept a change to the documentation to point out that “newline” does _not_ actually work like TextIOWrapper? Or perhaps even deprecating or recommending against using “newline”?

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-27 Thread Guido van Rossum
Guido van Rossum added the comment: Agreed we shouldn't change this. It looks like the behavior is consistent if you consider `a = StringIO(stuff, newline=...)` merely a shorthand for `a = StringIO(newline=...); a.write(stuff)`. I understand you would like to have a way to set the internal

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: At this point in time, I don't think it's a good idea to change the semantics at all. Some people might unknowingly rely on the current semantics, and the consequences of a change in 3.6 might be hard to debug. The larger issue here is that the newline

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, I'm closing, then. -- resolution: -> wont fix status: open -> closed ___ Python tracker ___

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-24 Thread Martin Panter
Martin Panter added the comment: According to Serhiy and Antoine both seem to agree this behaviour is a bug. The reason why newline="\r\n" and newline="\r" cause these funny translations is that __init__() internally passes the initial buffer

[issue22413] Bizarre StringIO(newline="\r\n") translation

2015-09-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I agree with you, but I think that Antoine disagrees. My half-baked patch for issue20435 did a half of the work. It initialized the buffer directly in __init__. Here is the rebased version. There is a difference between C and Python implementations for

[issue22413] Bizarre StringIO(newline=\r\n) translation

2014-09-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue20435. -- nosy: +pitrou, serhiy.storchaka versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22413 ___

[issue22413] Bizarre StringIO(newline=\r\n) translation

2014-09-14 Thread Martin Panter
New submission from Martin Panter: I noticed that the newline translation in the io.StringIO class does not behave as I would expect: text = NL\n CRLF\r\n CR\r EOF s = StringIO(text, newline=\r\n) s.getvalue() 'NL\r\nCRLF\r\r\nCR\rEOF' # Why is this not just equal to “text”? tuple(s)