Skip to content

Commit f4e57cd

Browse files
committed
Return error code 1 on broken pipe, and restore compatibility with Python 2.5
1 parent 56d211c commit f4e57cd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ Changelog
22
=========
33

44

5+
1.x (unreleased)
6+
----------------
7+
8+
Bug fixes:
9+
10+
* Skip the traceback on "Broken pipe" signal. (Issue #275)
11+
12+
513
1.5.6 (2014-04-14)
614
------------------
715

pep8.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"""
4747
from __future__ import with_statement
4848

49-
__version__ = '1.5.6'
49+
__version__ = '1.5.7a0'
5050

5151
import os
5252
import sys
@@ -55,7 +55,6 @@
5555
import inspect
5656
import keyword
5757
import tokenize
58-
import errno
5958
from optparse import OptionParser
6059
from fnmatch import fnmatch
6160
try:
@@ -1673,9 +1672,6 @@ def check_files(self, paths=None):
16731672
runner(path)
16741673
except KeyboardInterrupt:
16751674
print('... stopped')
1676-
except IOError as e:
1677-
if e.errno != errno.EPIPE:
1678-
raise e
16791675
report.stop()
16801676
return report
16811677

@@ -1917,6 +1913,14 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
19171913

19181914
def _main():
19191915
"""Parse options and run checks on Python source."""
1916+
import signal
1917+
1918+
# Handle "Broken pipe" gracefully
1919+
try:
1920+
signal.signal(signal.SIGPIPE, lambda signum, frame: sys.exit(1))
1921+
except ValueError:
1922+
pass # not supported on Windows
1923+
19201924
pep8style = StyleGuide(parse_argv=True, config_file=True)
19211925
options = pep8style.options
19221926
if options.doctest or options.testsuite:

0 commit comments

Comments
 (0)