--- a/hgext/patchbomb.py Tue May 31 04:18:22 2022 +0200
+++ b/hgext/patchbomb.py Tue May 31 16:54:58 2022 +0200
@@ -76,7 +76,6 @@
import email.mime.base as emimebase
import email.mime.multipart as emimemultipart
import email.utils as eutil
-import errno
import os
import socket
@@ -984,9 +983,8 @@
try:
generator.flatten(m, False)
ui.write(b'\n')
- except IOError as inst:
- if inst.errno != errno.EPIPE:
- raise
+ except BrokenPipeError:
+ pass
else:
if not sendmail:
sendmail = mail.connect(ui, mbox=mbox)
--- a/mercurial/commandserver.py Tue May 31 04:18:22 2022 +0200
+++ b/mercurial/commandserver.py Tue May 31 16:54:58 2022 +0200
@@ -6,7 +6,6 @@
# GNU General Public License version 2 or any later version.
-import errno
import gc
import os
import random
@@ -494,9 +493,8 @@
# known exceptions are caught by dispatch.
except error.Abort as inst:
ui.error(_(b'abort: %s\n') % inst.message)
- except IOError as inst:
- if inst.errno != errno.EPIPE:
- raise
+ except BrokenPipeError:
+ pass
except KeyboardInterrupt:
pass
finally:
@@ -514,9 +512,8 @@
fin.close()
try:
fout.close() # implicit flush() may cause another EPIPE
- except IOError as inst:
- if inst.errno != errno.EPIPE:
- raise
+ except BrokenPipeError:
+ pass
class unixservicehandler:
--- a/mercurial/dispatch.py Tue May 31 04:18:22 2022 +0200
+++ b/mercurial/dispatch.py Tue May 31 16:54:58 2022 +0200
@@ -290,9 +290,8 @@
# maybe pager would quit without consuming all the output, and
# SIGPIPE was raised. we cannot print anything in this case.
pass
- except IOError as inst:
- if inst.errno != errno.EPIPE:
- raise
+ except BrokenPipeError:
+ pass
ret = -1
finally:
duration = util.timer() - starttime
--- a/mercurial/hgweb/server.py Tue May 31 04:18:22 2022 +0200
+++ b/mercurial/hgweb/server.py Tue May 31 16:54:58 2022 +0200
@@ -115,9 +115,8 @@
def do_write(self):
try:
self.do_hgweb()
- except socket.error as inst:
- if inst.errno != errno.EPIPE:
- raise
+ except BrokenPipeError:
+ pass
def do_POST(self):
try:
--- a/mercurial/keepalive.py Tue May 31 04:18:22 2022 +0200
+++ b/mercurial/keepalive.py Tue May 31 16:54:58 2022 +0200
@@ -84,7 +84,6 @@
import collections
-import errno
import hashlib
import socket
import sys
@@ -657,14 +656,14 @@
else:
self.sock.sendall(str)
self.sentbytescount += len(str)
- except socket.error as v:
- reraise = True
- if v.args[0] == errno.EPIPE: # Broken pipe
- if self._HTTPConnection__state == httplib._CS_REQ_SENT:
- self._broken_pipe_resp = None
- self._broken_pipe_resp = self.getresponse()
- reraise = False
- self.close()
+ except BrokenPipeError:
+ if self._HTTPConnection__state == httplib._CS_REQ_SENT:
+ self._broken_pipe_resp = None
+ self._broken_pipe_resp = self.getresponse()
+ reraise = False
+ else:
+ reraise = True
+ self.close()
if reraise:
raise