summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-06-03 07:25:35 (GMT)
committerGeorg Brandl <georg@python.org>2009-06-03 07:25:35 (GMT)
commitc1edec3374bb03ca936be3cd0b968140ec58e819 (patch)
tree4160a66a97eab66e3cc6d533566e8368a9cc9b8f /Doc/library
parentdad7b7b1cb83d6ead5e8af5c747256a1aaa3f6cf (diff)
downloadcpython-c1edec3374bb03ca936be3cd0b968140ec58e819.zip
cpython-c1edec3374bb03ca936be3cd0b968140ec58e819.tar.gz
cpython-c1edec3374bb03ca936be3cd0b968140ec58e819.tar.bz2
Use the preferred form of raise statements in the docs.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/crypt.rst3
-rw-r--r--Doc/library/imputil.rst6
-rw-r--r--Doc/library/rexec.rst6
-rw-r--r--Doc/library/shutil.rst2
-rw-r--r--Doc/library/signal.rst2
5 files changed, 10 insertions, 9 deletions
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 @@ A simple example illustrating typical use::
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 @@ This code is intended to be read, not executed. However, it does work
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 @@ This code is intended to be read, not executed. However, it does work
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 @@ This code is intended to be read, not executed. However, it does work
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 @@ Let us say that we want a slightly more relaxed policy than the standard
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 @@ provided by this module. ::
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 @@ be sent, and the handler raises an exception. ::
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)