[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Antoine Pitrou added the comment: It's a bug in _pyio.StringIO.getvalue(). Attaching patch. -- keywords: +patch Added file: http://bugs.python.org/file33873/stringio_getvalue.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Serhiy Storchaka added the comment: I rather think that it's a bug in _io.StringIO.getvalue(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Antoine Pitrou added the comment: With the patch, getvalue() is consistent with read() and other methods. Without the patch, _pyio.StringIO.getvalue() returns a different value from _pyio.StringIO.read() *and* from _io.StringIO.getvalue(). Changing _pyio.StringIO.getvalue() is the path of least resistance here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Antoine Pitrou added the comment: In other words, the bug is that _pyio.StringIO.getvalue() doesn't do any newline conversion; the patch fixes that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Serhiy Storchaka added the comment: But how then other values of newline except '\n' can be useful? The problem is that newline converting is applied twice, in write() and in read(). When constructor uses write() and getvalue() returns same value as read(), we have no chance to get newlines encoded or decoded only once. Current results for newline != '\n' looks meanless to me. Here is my half-baked patch. It fixes only _pyio.StringIO, but _io.StringIO are still partially broken. The patch also contains new tests. -- Added file: http://bugs.python.org/file33876/stringio_newline.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Antoine Pitrou added the comment: Current results for newline != '\n' looks meanless to me. They don't look meaningless to me, e.g.: io.StringIO(a\r\nc\rd, newline=None).getvalue() 'a\nc\nd' sio = io.StringIO(newline=None); sio.write(a\r\nc\rd); sio.getvalue() 6 'a\nc\nd' There may be other cases where they make less sense, but that's a separate issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Roundup Robot added the comment: New changeset 99168e7d4a3d by Antoine Pitrou in branch '3.3': Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings. http://hg.python.org/cpython/rev/99168e7d4a3d New changeset aadcc71a4967 by Antoine Pitrou in branch 'default': Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings. http://hg.python.org/cpython/rev/aadcc71a4967 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Roundup Robot added the comment: New changeset 3e61d8e06ef7 by Antoine Pitrou in branch '2.7': Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings. http://hg.python.org/cpython/rev/3e61d8e06ef7 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Antoine Pitrou added the comment: I've fixed the reported bug. If other problems need fixing, better open a new issue :-) -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
Serhiy Storchaka added the comment: Thank you for fixing this bug. Maybe I reported it too hastily. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20435] Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines
New submission from Serhiy Storchaka: import io, _pyio io.StringIO('a\nb\r\nc\rd', newline=None) _io.StringIO object at 0xb707c734 io.StringIO('a\nb\r\nc\rd', newline=None).getvalue() 'a\nb\nc\nd' _pyio.StringIO('a\nb\r\nc\rd', newline=None).getvalue() 'a\nb\r\nc\rd' s = io.StringIO(newline=None); s.write('a\nb\r\nc\rd'); s.getvalue() 8 'a\nb\nc\nd' s = _pyio.StringIO(newline=None); s.write('a\nb\r\nc\rd'); s.getvalue() 8 'a\nb\r\nc\rd' -- components: IO messages: 209625 nosy: benjamin.peterson, hynek, pitrou, serhiy.storchaka, stutzbach priority: normal severity: normal status: open title: Discrepancy between io.StringIO and _pyio.StringIO with univeral newlines type: behavior versions: Python 2.7, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20435 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com