blob: fcc9c84dd9e794b647f8ff0913c9b1db92c0ceb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Description: fix closed pipe handling
Author: Sascha Steinbiss <satta@debian.org>
Bug: https://github.com/jeffkaufman/icdiff/issues/156
Forwarded: https://github.com/jeffkaufman/icdiff/pull/165
Last-Update: 2019-09-25
--- a/icdiff
+++ b/icdiff
@@ -594,7 +594,22 @@
validate_has_two_arguments(parser, args)
if not options.cols:
set_cols_option(options)
- diff(options, *args)
+ try:
+ diff(options, *args)
+ except KeyboardInterrupt:
+ pass
+ except IOError as e:
+ if e.errno == errno.EPIPE:
+ pass
+ else:
+ raise
+
+ # Close stderr to prevent printing errors when icdiff is piped to
+ # something that closes before icdiff is done writing
+ #
+ # See: https://stackoverflow.com/questions/26692284/...
+ # ...how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python
+ sys.stderr.close()
def codec_print(s, options):
@@ -755,18 +770,4 @@
if __name__ == "__main__":
- try:
- start()
- except KeyboardInterrupt:
- pass
- except IOError as e:
- if e.errno == errno.EPIPE:
- pass
- else:
- raise
- # Close stderr to prevent printing errors when icdiff is piped to
- # something that closes before icdiff is done writing
- #
- # See: https://stackoverflow.com/questions/26692284/
- # how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python
- sys.stderr.close()
+ start()
|