[PATCH 5 of 9] inotify: removed exception args indexing (not supported by py3k)
Renato Cunha
renatoc at gmail.com
Wed Jul 14 21:18:38 CDT 2010
# HG changeset patch
# User Renato Cunha <renatoc at gmail.com>
# Date 1279159401 10800
# Branch stable
# Node ID 3a94f478b97a024269ef42d83ecd1bf4b2e5b457
# Parent 12c5cab6b8b8594f6b3df9833bee0b4fc59e49ee
inotify: removed exception args indexing (not supported by py3k)
Py3k removed __getitem__ for exception classes. The correct way of getting the
exception arguments is by using the args method.
diff --git a/hgext/inotify/client.py b/hgext/inotify/client.py
--- a/hgext/inotify/client.py
+++ b/hgext/inotify/client.py
@@ -27,11 +27,11 @@
except (OSError, socket.error), err:
autostart = self.ui.configbool('inotify', 'autostart', True)
- if err[0] == errno.ECONNREFUSED:
+ if err.args[0] == errno.ECONNREFUSED:
self.ui.warn(_('inotify-client: found dead inotify server '
'socket; removing it\n'))
os.unlink(os.path.join(self.root, '.hg', 'inotify.sock'))
- if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
+ if err.args[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
self.ui.debug('(starting inotify server)\n')
try:
try:
@@ -49,13 +49,13 @@
return function(self, *args)
except socket.error, err:
self.ui.warn(_('inotify-client: could not talk to new '
- 'inotify server: %s\n') % err[-1])
- elif err[0] in (errno.ECONNREFUSED, errno.ENOENT):
+ 'inotify server: %s\n') % err.args[-1])
+ elif err.args[0] in (errno.ECONNREFUSED, errno.ENOENT):
# silently ignore normal errors if autostart is False
self.ui.debug('(inotify server not running)\n')
else:
self.ui.warn(_('inotify-client: failed to contact inotify '
- 'server: %s\n') % err[-1])
+ 'server: %s\n') % err.args[-1])
self.ui.traceback()
raise QueryFailed('inotify query failed')
@@ -75,7 +75,7 @@
try:
self.sock.connect(sockpath)
except socket.error, err:
- if err[0] == "AF_UNIX path too long":
+ if err.args[0] == "AF_UNIX path too long":
sockpath = os.readlink(sockpath)
self.sock.connect(sockpath)
else:
diff --git a/hgext/inotify/linuxserver.py b/hgext/inotify/linuxserver.py
--- a/hgext/inotify/linuxserver.py
+++ b/hgext/inotify/linuxserver.py
@@ -117,7 +117,7 @@
try:
events = cls.poll.poll(timeout)
except select.error, err:
- if err[0] == errno.EINTR:
+ if err.args[0] == errno.EINTR:
continue
raise
if events:
diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -334,10 +334,10 @@
try:
self.sock.bind(self.sockpath)
except socket.error, err:
- if err[0] == errno.EADDRINUSE:
+ if err.args[0] == errno.EADDRINUSE:
raise AlreadyStartedException(_('cannot start: socket is '
'already bound'))
- if err[0] == "AF_UNIX path too long":
+ if err.args[0] == "AF_UNIX path too long":
if os.path.islink(self.sockpath) and \
not os.path.exists(self.sockpath):
raise util.Abort('inotify-server: cannot start: '
@@ -435,7 +435,7 @@
finally:
sock.shutdown(socket.SHUT_WR)
except socket.error, err:
- if err[0] != errno.EPIPE:
+ if err.args[0] != errno.EPIPE:
raise
if sys.platform == 'linux2':
More information about the Mercurial-devel
mailing list