Use the preferred form of raise statements in the docs.
diff --git a/Doc/library/crypt.rst b/Doc/library/crypt.rst
index 2f037c7..91464ef 100644
--- a/Doc/library/crypt.rst
+++ b/Doc/library/crypt.rst
@@ -52,7 +52,8 @@
cryptedpasswd = pwd.getpwnam(username)[1]
if cryptedpasswd:
if cryptedpasswd == 'x' or cryptedpasswd == '*':
- raise "Sorry, currently no support for shadow passwords"
+ raise NotImplementedError(
+ "Sorry, currently no support for shadow passwords")
cleartext = getpass.getpass()
return crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd
else:
diff --git a/Doc/library/imputil.rst b/Doc/library/imputil.rst
index 09a41f6..86089d2 100644
--- a/Doc/library/imputil.rst
+++ b/Doc/library/imputil.rst
@@ -160,7 +160,7 @@
parent = None
q = import_module(head, qname, parent)
if q: return q, tail
- raise ImportError, "No module named " + qname
+ raise ImportError("No module named " + qname)
def load_tail(q, tail):
m = q
@@ -171,7 +171,7 @@
mname = "%s.%s" % (m.__name__, head)
m = import_module(head, mname, m)
if not m:
- raise ImportError, "No module named " + mname
+ raise ImportError("No module named " + mname)
return m
def ensure_fromlist(m, fromlist, recursive=0):
@@ -189,7 +189,7 @@
subname = "%s.%s" % (m.__name__, sub)
submod = import_module(sub, subname, m)
if not submod:
- raise ImportError, "No module named " + subname
+ raise ImportError("No module named " + subname)
def import_module(partname, fqname, parent):
try:
diff --git a/Doc/library/rexec.rst b/Doc/library/rexec.rst
index 7736904..2ce612a 100644
--- a/Doc/library/rexec.rst
+++ b/Doc/library/rexec.rst
@@ -272,11 +272,11 @@
elif mode in ('w', 'wb', 'a', 'ab'):
# check filename : must begin with /tmp/
if file[:5]!='/tmp/':
- raise IOError, "can't write outside /tmp"
+ raise IOError("can't write outside /tmp")
elif (string.find(file, '/../') >= 0 or
file[:3] == '../' or file[-3:] == '/..'):
- raise IOError, "'..' in filename forbidden"
- else: raise IOError, "Illegal open() mode"
+ raise IOError("'..' in filename forbidden")
+ else: raise IOError("Illegal open() mode")
return open(file, mode, buf)
Notice that the above code will occasionally forbid a perfectly valid filename;
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index e09b646..ad3ab57 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -216,7 +216,7 @@
except OSError, why:
errors.extend((src, dst, str(why)))
if errors:
- raise Error, errors
+ raise Error(errors)
Another example that uses the :func:`ignore_patterns` helper::
diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst
index 3793a89..c039eee 100644
--- a/Doc/library/signal.rst
+++ b/Doc/library/signal.rst
@@ -232,7 +232,7 @@
def handler(signum, frame):
print 'Signal handler called with signal', signum
- raise IOError, "Couldn't open device!"
+ raise IOError("Couldn't open device!")
# Set the signal handler and a 5-second alarm
signal.signal(signal.SIGALRM, handler)