This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author akira
Recipients Douglas.Alan, abarnert, akira, amaury.forgeotdarc, benjamin.peterson, eric.araujo, facundobatista, georg.brandl, jcon, martin.panter, ncoghlan, nessus42, pconnell, pitrou, r.david.murray, ralph.corderoy, rhettinger, wolma, ysj.ray
Date 2014-07-28.08:01:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <87zjftj4is.fsf@gmail.com>
In-reply-to <1406513676.23.0.255736417899.issue1152248@psf.upfronthosting.co.za> (Andrew Barnert's message of "Mon, 28 Jul 2014 02:14:36 +0000")
Content
> Akira, your patch does this:
>
> -        self._writetranslate = newline != ''
> -        self._writenl = newline or os.linesep
> +        self._writetranslate = newline in (None, '\r', '\r\n')
> +        self._writenl = newline if newline is not None else os.linesep
>
> Any reason you made the second change? Why change the value assigned
> to _writenl for newline='\n' when you don't want to actually change
> the behavior for those cases? Just so you can double-check at write
> time that _writetranslate is never set unless _writenl is '\r',
> \r\n', or os.linesep?

If newline='\n' then writenl is '\n' with and without the patch.
If newline='\n' then write('\n\r') writes '\n\r' with and without the
patch.

If newline='\n' then writetranslate=False (with the patch). It does not
change the result for newline='\n' as it is documented now [1]:

  [newline] can be None, '', '\n', '\r', and '\r\n'.
  ...
  If newline is any of the other legal values [namely '\r', '\n',
  '\r\n'], any '\n' characters written are translated to the given
  string.

[...] are added by me for clarity.

[1] https://docs.python.org/3.4/library/io.html#io.TextIOWrapper

writetranslate=False so that if newline='\0' then write('\0\n') would
write '\0\n' i.e., embed '\n' are not corrupted if newline='\0'. That is
why it is the "no translation" patch:

+    When writing output to the stream:
+
+    - if newline is None, any '\n' characters written are translated to
+      the system default line separator, os.linesep
+    - if newline is '\r' or '\r\n', any '\n' characters written are
+      translated to the given string
+    - no translation takes place for any other newline value [any string].
History
Date User Action Args
2014-07-28 08:01:37akirasetrecipients: + akira, georg.brandl, rhettinger, facundobatista, amaury.forgeotdarc, ncoghlan, pitrou, benjamin.peterson, nessus42, eric.araujo, ralph.corderoy, r.david.murray, ysj.ray, Douglas.Alan, jcon, martin.panter, pconnell, wolma, abarnert
2014-07-28 08:01:37akiralinkissue1152248 messages
2014-07-28 08:01:35akiracreate