summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2014-04-18 20:54:58 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2014-04-18 20:54:58 +0200
commitf4e57cd75e7d949d42be58d59982f2b40bdce989 (patch)
tree7237805ceea0bec5ffc4d9d8638403c28dea9565
parent56d211c469da5d39bf8eeed74a3cc433c992048a (diff)
downloadpep8-f4e57cd75e7d949d42be58d59982f2b40bdce989.tar.gz
Return error code 1 on broken pipe, and restore compatibility with Python 2.5
-rw-r--r--CHANGES.txt8
-rwxr-xr-xpep8.py14
2 files changed, 17 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index a90262a..59256de 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,14 @@ Changelog
=========
+1.x (unreleased)
+----------------
+
+Bug fixes:
+
+* Skip the traceback on "Broken pipe" signal. (Issue #275)
+
+
1.5.6 (2014-04-14)
------------------
diff --git a/pep8.py b/pep8.py
index 1e52c3e..a254716 100755
--- a/pep8.py
+++ b/pep8.py
@@ -46,7 +46,7 @@ W warnings
"""
from __future__ import with_statement
-__version__ = '1.5.6'
+__version__ = '1.5.7a0'
import os
import sys
@@ -55,7 +55,6 @@ import time
import inspect
import keyword
import tokenize
-import errno
from optparse import OptionParser
from fnmatch import fnmatch
try:
@@ -1673,9 +1672,6 @@ class StyleGuide(object):
runner(path)
except KeyboardInterrupt:
print('... stopped')
- except IOError as e:
- if e.errno != errno.EPIPE:
- raise e
report.stop()
return report
@@ -1917,6 +1913,14 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
def _main():
"""Parse options and run checks on Python source."""
+ import signal
+
+ # Handle "Broken pipe" gracefully
+ try:
+ signal.signal(signal.SIGPIPE, lambda signum, frame: sys.exit(1))
+ except ValueError:
+ pass # not supported on Windows
+
pep8style = StyleGuide(parse_argv=True, config_file=True)
options = pep8style.options
if options.doctest or options.testsuite: