summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lee <IanLee1521@gmail.com>2015-01-26 22:43:46 -0800
committerIan Lee <IanLee1521@gmail.com>2015-01-26 22:43:46 -0800
commitbcd5d2bae39bc2b43c02f394fea9950f40099199 (patch)
tree568c464f4e883a3fbdfb1d2b21b919f4045e8151
parentf7a9648da6245738b72fcd664a20168d54953ee7 (diff)
parent4579585f1441dc4bb4a9b44f58b2fbe2ef3c77dd (diff)
downloadpep8-bcd5d2bae39bc2b43c02f394fea9950f40099199.tar.gz
Merge branch 'issue-363' into master
-rw-r--r--CHANGES.txt3
-rwxr-xr-xpep8.py8
-rw-r--r--testsuite/support.py3
3 files changed, 14 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 96cf062..1caba39 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -51,6 +51,9 @@ Bug fixes:
* Do not skip physical checks if the newline is escaped. (Issue #319)
+* Flush sys.stdout to avoid race conditions with printing. See flake8 bug:
+ https://gitlab.com/pycqa/flake8/issues/17 for more details. (Issue #363)
+
1.5.7 (2014-05-29)
------------------
diff --git a/pep8.py b/pep8.py
index df39802..79497e2 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1704,6 +1704,14 @@ class StandardReport(BaseReport):
print(re.sub(r'\S', ' ', line[:offset]) + '^')
if self._show_pep8 and doc:
print(' ' + doc.strip())
+
+ # stdout is block buffered when not stdout.isatty().
+ # line can be broken where buffer boundary since other processes
+ # write to same file.
+ # flush() after print() to avoid buffer boundary.
+ # Typical buffer size is 8192. line written safely when
+ # len(line) < 8192.
+ sys.stdout.flush()
return self.file_errors
diff --git a/testsuite/support.py b/testsuite/support.py
index 5185005..6bc795d 100644
--- a/testsuite/support.py
+++ b/testsuite/support.py
@@ -16,6 +16,9 @@ class PseudoFile(list):
def getvalue(self):
return ''.join(self)
+ def flush(self):
+ pass
+
class TestReport(StandardReport):
"""Collect the results for the tests."""