##// END OF EJS Templates
use Exception(args)-style raising consistently (py3k compatibility)
Peter Ruibal -
r7008:8fee8ff1 default
parent child Browse files
Show More
@@ -110,7 +110,7 b' class RangeableFileObject:'
110 in self.fo. This includes methods."""
110 in self.fo. This includes methods."""
111 if hasattr(self.fo, name):
111 if hasattr(self.fo, name):
112 return getattr(self.fo, name)
112 return getattr(self.fo, name)
113 raise AttributeError, name
113 raise AttributeError(name)
114
114
115 def tell(self):
115 def tell(self):
116 """Return the position within the range.
116 """Return the position within the range.
@@ -257,7 +257,7 b' class FTPRangeHandler(urllib2.FTPHandler'
257 def ftp_open(self, req):
257 def ftp_open(self, req):
258 host = req.get_host()
258 host = req.get_host()
259 if not host:
259 if not host:
260 raise IOError, ('ftp error', 'no host given')
260 raise IOError('ftp error', 'no host given')
261 host, port = splitport(host)
261 host, port = splitport(host)
262 if port is None:
262 if port is None:
263 port = ftplib.FTP_PORT
263 port = ftplib.FTP_PORT
@@ -329,7 +329,7 b' class FTPRangeHandler(urllib2.FTPHandler'
329 headers = mimetools.Message(sf)
329 headers = mimetools.Message(sf)
330 return addinfourl(fp, headers, req.get_full_url())
330 return addinfourl(fp, headers, req.get_full_url())
331 except ftplib.all_errors, msg:
331 except ftplib.all_errors, msg:
332 raise IOError, ('ftp error', msg), sys.exc_info()[2]
332 raise IOError('ftp error', msg), sys.exc_info()[2]
333
333
334 def connect_ftp(self, user, passwd, host, port, dirs):
334 def connect_ftp(self, user, passwd, host, port, dirs):
335 fw = ftpwrapper(user, passwd, host, port, dirs)
335 fw = ftpwrapper(user, passwd, host, port, dirs)
@@ -359,7 +359,7 b' class ftpwrapper(urllib.ftpwrapper):'
359 try:
359 try:
360 self.ftp.nlst(file)
360 self.ftp.nlst(file)
361 except ftplib.error_perm, reason:
361 except ftplib.error_perm, reason:
362 raise IOError, ('ftp error', reason), sys.exc_info()[2]
362 raise IOError('ftp error', reason), sys.exc_info()[2]
363 # Restore the transfer mode!
363 # Restore the transfer mode!
364 self.ftp.voidcmd(cmd)
364 self.ftp.voidcmd(cmd)
365 # Try to retrieve as a file
365 # Try to retrieve as a file
@@ -373,7 +373,7 b' class ftpwrapper(urllib.ftpwrapper):'
373 fp = RangeableFileObject(fp, (rest,''))
373 fp = RangeableFileObject(fp, (rest,''))
374 return (fp, retrlen)
374 return (fp, retrlen)
375 elif not str(reason).startswith('550'):
375 elif not str(reason).startswith('550'):
376 raise IOError, ('ftp error', reason), sys.exc_info()[2]
376 raise IOError('ftp error', reason), sys.exc_info()[2]
377 if not conn:
377 if not conn:
378 # Set transfer mode to ASCII!
378 # Set transfer mode to ASCII!
379 self.ftp.voidcmd('TYPE A')
379 self.ftp.voidcmd('TYPE A')
@@ -65,7 +65,7 b' class changectx(object):'
65 self._parents = [changectx(self._repo, x) for x in p]
65 self._parents = [changectx(self._repo, x) for x in p]
66 return self._parents
66 return self._parents
67 else:
67 else:
68 raise AttributeError, name
68 raise AttributeError(name)
69
69
70 def __contains__(self, key):
70 def __contains__(self, key):
71 return key in self._manifest
71 return key in self._manifest
@@ -215,7 +215,7 b' class filectx(object):'
215 self._repopath = self._path
215 self._repopath = self._path
216 return self._repopath
216 return self._repopath
217 else:
217 else:
218 raise AttributeError, name
218 raise AttributeError(name)
219
219
220 def __nonzero__(self):
220 def __nonzero__(self):
221 try:
221 try:
@@ -521,7 +521,7 b' class workingctx(changectx):'
521 self._parents = [changectx(self._repo, x) for x in p]
521 self._parents = [changectx(self._repo, x) for x in p]
522 return self._parents
522 return self._parents
523 else:
523 else:
524 raise AttributeError, name
524 raise AttributeError(name)
525
525
526 def _buildmanifest(self):
526 def _buildmanifest(self):
527 """generate a manifest corresponding to the working directory"""
527 """generate a manifest corresponding to the working directory"""
@@ -630,7 +630,7 b' class workingfilectx(filectx):'
630 self._filelog = self._repo.file(self._repopath)
630 self._filelog = self._repo.file(self._repopath)
631 return self._filelog
631 return self._filelog
632 else:
632 else:
633 raise AttributeError, name
633 raise AttributeError(name)
634
634
635 def __nonzero__(self):
635 def __nonzero__(self):
636 return True
636 return True
@@ -97,7 +97,7 b' class dirstate(object):'
97 self.normalize = lambda x: x
97 self.normalize = lambda x: x
98 return self.normalize
98 return self.normalize
99 else:
99 else:
100 raise AttributeError, name
100 raise AttributeError(name)
101
101
102 def _join(self, f):
102 def _join(self, f):
103 # much faster than os.path.join()
103 # much faster than os.path.join()
@@ -53,7 +53,7 b' def launch(application):'
53 try:
53 try:
54 if headers_sent:
54 if headers_sent:
55 # Re-raise original exception if headers sent
55 # Re-raise original exception if headers sent
56 raise exc_info[0], exc_info[1], exc_info[2]
56 raise exc_info[0](exc_info[1], exc_info[2])
57 finally:
57 finally:
58 exc_info = None # avoid dangling circular ref
58 exc_info = None # avoid dangling circular ref
59 elif headers_set:
59 elif headers_set:
@@ -96,7 +96,7 b' class localrepository(repo.repository):'
96 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
96 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
97 return self.dirstate
97 return self.dirstate
98 else:
98 else:
99 raise AttributeError, name
99 raise AttributeError(name)
100
100
101 def __getitem__(self, changeid):
101 def __getitem__(self, changeid):
102 if changeid == None:
102 if changeid == None:
@@ -25,7 +25,7 b' class Stats(object):'
25 def sort(self, crit="inlinetime"):
25 def sort(self, crit="inlinetime"):
26 """XXX docstring"""
26 """XXX docstring"""
27 if crit not in profiler_entry.__dict__:
27 if crit not in profiler_entry.__dict__:
28 raise ValueError, "Can't sort by %s" % crit
28 raise ValueError("Can't sort by %s" % crit)
29 self.data.sort(lambda b, a: cmp(getattr(a, crit),
29 self.data.sort(lambda b, a: cmp(getattr(a, crit),
30 getattr(b, crit)))
30 getattr(b, crit)))
31 for e in self.data:
31 for e in self.data:
@@ -7,7 +7,7 b''
7
7
8 import sys
8 import sys
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
10 raise SystemExit, "Mercurial requires python 2.3 or later."
10 raise SystemExit("Mercurial requires python 2.3 or later.")
11
11
12 import os
12 import os
13 import shutil
13 import shutil
General Comments 0
You need to be logged in to leave comments. Login now