Mercurial > public > mercurial-scm > hg
comparison mercurial/windows.py @ 45158:ed58ecd59030
windows: don?t set `softspace` attribute in `winstdout`
Python 2 file objects have the `softspace` attribute
(https://docs.python.org/2/library/stdtypes.html#file.softspace), which is used
by the print statement to track its internal state. The documentation demands
from file-like objects only that the attribute is writable and initialized to
0. Method `file.write()` sets it to 0, but this is not documented.
Historically, sys.stdout was replaced by an instance of the `winstdout` class,
so it needed to behave exactly the same (the softspace fix was introduced in
705278e70457). Nowadays we don?t replace sys.stdout and don?t use the print
statement on `winstdout` instances, so we can safely drop it.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sat, 18 Jul 2020 12:35:55 +0200 |
parents | 74b486226480 |
children | 89a2afe31e82 |
comparison
equal
deleted
inserted
replaced
45157:74b486226480 | 45158:ed58ecd59030 |
---|---|
215 self.fp.close() | 215 self.fp.close() |
216 except IOError: | 216 except IOError: |
217 pass | 217 pass |
218 | 218 |
219 def write(self, s): | 219 def write(self, s): |
220 if not pycompat.ispy3: | |
221 self.softspace = 0 | |
222 try: | 220 try: |
223 if not self.throttle: | 221 if not self.throttle: |
224 return self.fp.write(s) | 222 return self.fp.write(s) |
225 # This is workaround for "Not enough space" error on | 223 # This is workaround for "Not enough space" error on |
226 # writing large size of data to console. | 224 # writing large size of data to console. |