Message224155
> 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]. |
|
Date |
User |
Action |
Args |
2014-07-28 08:01:37 | akira | set | recipients:
+ 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:37 | akira | link | issue1152248 messages |
2014-07-28 08:01:35 | akira | create | |
|