]> granicus.if.org Git - python/commitdiff
Merged revisions 72558,72745,72750,72876,73042,73045-73048,73069,73089,73163,73186...
authorGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 14:19:50 +0000 (14:19 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 14:19:50 +0000 (14:19 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72558 | benjamin.peterson | 2009-05-11 01:52:09 +0200 (Mo, 11 Mai 2009) | 1 line

  sys.setdefaultencoding() strikes me as a bad example
........
  r72745 | benjamin.peterson | 2009-05-17 16:16:29 +0200 (So, 17 Mai 2009) | 1 line

  ignore .rst files in sphinx its self
........
  r72750 | benjamin.peterson | 2009-05-17 18:59:27 +0200 (So, 17 Mai 2009) | 1 line

  chop off slash
........
  r72876 | benjamin.peterson | 2009-05-23 22:59:09 +0200 (Sa, 23 Mai 2009) | 1 line

  remove mention of old ctypes version
........
  r73042 | benjamin.peterson | 2009-05-30 05:10:52 +0200 (Sa, 30 Mai 2009) | 1 line

  no fdatasync on macos
........
  r73045 | georg.brandl | 2009-05-30 09:26:04 +0200 (Sa, 30 Mai 2009) | 1 line

  #6146: fix markup bug.
........
  r73046 | georg.brandl | 2009-05-30 09:31:25 +0200 (Sa, 30 Mai 2009) | 1 line

  Use preferred form of raising exceptions.
........
  r73047 | georg.brandl | 2009-05-30 12:33:23 +0200 (Sa, 30 Mai 2009) | 1 line

  Fix some more small markup problems.
........
  r73048 | georg.brandl | 2009-05-30 12:34:25 +0200 (Sa, 30 Mai 2009) | 1 line

  Fix markup problem.
........
  r73069 | benjamin.peterson | 2009-05-31 02:42:42 +0200 (So, 31 Mai 2009) | 1 line

  fix signature
........
  r73089 | andrew.kuchling | 2009-06-01 02:14:19 +0200 (Mo, 01 Jun 2009) | 1 line

  The class for regexes isn't called RegexObject any more; correct the text
........
  r73163 | georg.brandl | 2009-06-03 09:25:35 +0200 (Mi, 03 Jun 2009) | 1 line

  Use the preferred form of raise statements in the docs.
........
  r73186 | georg.brandl | 2009-06-03 23:21:09 +0200 (Mi, 03 Jun 2009) | 1 line

  #6174: fix indentation in code example.
........
  r73213 | georg.brandl | 2009-06-04 12:15:57 +0200 (Do, 04 Jun 2009) | 1 line

  #5967: note that the C slicing APIs do not support negative indices.
........
  r73215 | georg.brandl | 2009-06-04 12:22:31 +0200 (Do, 04 Jun 2009) | 1 line

  #6176: fix man page section for flock(2).
........
  r73217 | georg.brandl | 2009-06-04 12:27:21 +0200 (Do, 04 Jun 2009) | 1 line

  #6175: document that inet_aton supports alternate input formats with less than three dots.
........
  r73257 | georg.brandl | 2009-06-06 19:50:05 +0200 (Sa, 06 Jun 2009) | 1 line

  #6211: elaborate a bit on ways to call the function.
........
  r73258 | georg.brandl | 2009-06-06 19:51:31 +0200 (Sa, 06 Jun 2009) | 1 line

  #6204: use a real reference instead of "see later".
........
  r73260 | georg.brandl | 2009-06-06 20:21:58 +0200 (Sa, 06 Jun 2009) | 1 line

  #6224: s/JPython/Jython/, and remove one link to a module nine years old.
........

30 files changed:
Doc/c-api/buffer.rst
Doc/c-api/list.rst
Doc/c-api/sequence.rst
Doc/conf.py
Doc/howto/regex.rst
Doc/howto/sockets.rst
Doc/includes/email-unpack.py
Doc/includes/mp_pool.py
Doc/includes/mp_synchronize.py
Doc/library/crypt.rst
Doc/library/ctypes.rst
Doc/library/easydialogs.rst
Doc/library/exceptions.rst
Doc/library/fcntl.rst
Doc/library/imputil.rst
Doc/library/os.rst
Doc/library/platform.rst
Doc/library/rexec.rst
Doc/library/rlcompleter.rst
Doc/library/shutil.rst
Doc/library/signal.rst
Doc/library/socket.rst
Doc/library/tkinter.rst
Doc/reference/simple_stmts.rst
Doc/tools/roman.py
Doc/tools/sphinxext/suspicious.py
Doc/tutorial/controlflow.rst
Doc/whatsnew/2.6.rst
Lib/imputil.py
Objects/unicodeobject.c

index 1969ad3f096dc8ba55958efa0d84b372b1972262..ad7253f561c4216d699631a9ded2d96cd9c53e0f 100644 (file)
@@ -140,7 +140,7 @@ Buffer related functions
    Return 1 if *obj* supports the buffer interface otherwise 0.
 
 
-.. cfunction:: int PyObject_GetBuffer(PyObject *obj, PyObject *view, int flags)
+.. cfunction:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
 
       Export *obj* into a :ctype:`Py_buffer`, *view*.  These arguments must
       never be *NULL*.  The *flags* argument is a bit field indicating what
index 2ce5ade875b88eb065137c41d3b4a3102919fdbd..ebbab13b92fef952f0b2a8a3cafc9419715f7e52 100644 (file)
@@ -149,9 +149,10 @@ List Objects
 
 .. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
 
-   Return a list of the objects in *list* containing the objects *between*
-   *low* and *high*.  Return *NULL* and set an exception if unsuccessful.
-   Analogous to ``list[low:high]``.
+   Return a list of the objects in *list* containing the objects *between* *low*
+   and *high*.  Return *NULL* and set an exception if unsuccessful.  Analogous
+   to ``list[low:high]``.  Negative indices, as when slicing from Python, are not
+   supported.
 
    .. versionchanged:: 2.5
       This function used an :ctype:`int` for *low* and *high*. This might
@@ -163,7 +164,8 @@ List Objects
    Set the slice of *list* between *low* and *high* to the contents of
    *itemlist*.  Analogous to ``list[low:high] = itemlist``. The *itemlist* may
    be *NULL*, indicating the assignment of an empty list (slice deletion).
-   Return ``0`` on success, ``-1`` on failure.
+   Return ``0`` on success, ``-1`` on failure.  Negative indices, as when
+   slicing from Python, are not supported.
 
    .. versionchanged:: 2.5
       This function used an :ctype:`int` for *low* and *high*. This might
index 0b220904468a038c10670b9e1f5d3f91f5550f19..2808a884a93f757901ab3eeede36335b17f68756 100644 (file)
@@ -62,7 +62,7 @@ Sequence Protocol
 
 .. cfunction:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
 
-   Return the *i*th element of *o*, or *NULL* on failure. This is the equivalent of
+   Return the *i*th element of *o*, or *NULL* on failure. This is the equivalent of
    the Python expression ``o[i]``.
 
    .. versionchanged:: 2.5
@@ -82,7 +82,7 @@ Sequence Protocol
 
 .. cfunction:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
 
-   Assign object *v* to the *i*th element of *o*.  Returns ``-1`` on failure.  This
+   Assign object *v* to the *i*th element of *o*.  Returns ``-1`` on failure.  This
    is the equivalent of the Python statement ``o[i] = v``.  This function *does
    not* steal a reference to *v*.
 
@@ -93,7 +93,7 @@ Sequence Protocol
 
 .. cfunction:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
 
-   Delete the *i*th element of object *o*.  Returns ``-1`` on failure.  This is the
+   Delete the *i*th element of object *o*.  Returns ``-1`` on failure.  This is the
    equivalent of the Python statement ``del o[i]``.
 
    .. versionchanged:: 2.5
@@ -175,7 +175,7 @@ Sequence Protocol
 
 .. cfunction:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
 
-   Return the *i*th element of *o*, assuming that *o* was returned by
+   Return the *i*th element of *o*, assuming that *o* was returned by
    :cfunc:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds.
 
    .. versionchanged:: 2.5
@@ -197,7 +197,7 @@ Sequence Protocol
 
 .. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
 
-   Return the *i*th element of *o* or *NULL* on failure. Macro form of
+   Return the *i*th element of *o* or *NULL* on failure. Macro form of
    :cfunc:`PySequence_GetItem` but without checking that
    :cfunc:`PySequence_Check(o)` is true and without adjustment for negative
    indices.
index 76415b06a93530e3b78ea4340eca2d3e1d2e9eb4..ffa5968071f240764130012b23fa3ed1ac239feb 100644 (file)
@@ -46,6 +46,9 @@ unused_docs = [
     'library/xml.etree',
 ]
 
+# Ignore .rst in Sphinx its self.
+exclude_trees = ['tools/sphinx']
+
 # Relative filename of the reference count data file.
 refcount_file = 'data/refcounts.dat'
 
index 71ff56d3f4119abfc3007f110fa45d232c9de711..1ab291a6e87ab39488a8581e08e9914f97b41333 100644 (file)
@@ -257,7 +257,7 @@ matches with them.
 Compiling Regular Expressions
 -----------------------------
 
-Regular expressions are compiled into :class:`RegexObject` instances, which have
+Regular expressions are compiled into pattern objects, which have
 methods for various operations such as searching for pattern matches or
 performing string substitutions. ::
 
@@ -336,7 +336,7 @@ Performing Matches
 ------------------
 
 Once you have an object representing a compiled regular expression, what do you
-do with it?  :class:`RegexObject` instances have several methods and attributes.
+do with it?  Pattern objects have several methods and attributes.
 Only the most significant ones will be covered here; consult the :mod:`re` docs
 for a complete listing.
 
@@ -427,8 +427,8 @@ Trying these methods will soon clarify their meaning::
 and :meth:`end` return the starting and ending index of the match. :meth:`span`
 returns both start and end indexes in a single tuple.  Since the :meth:`match`
 method only checks if the RE matches at the start of a string, :meth:`start`
-will always be zero.  However, the :meth:`search` method of :class:`RegexObject`
-instances scans through the string, so  the match may not start at zero in that
+will always be zero.  However, the :meth:`search` method of patterns
+scans through the string, so  the match may not start at zero in that
 case. ::
 
    >>> print p.match('::: message')
@@ -450,7 +450,7 @@ in a variable, and then check if it was ``None``.  This usually looks like::
    else:
        print 'No match'
 
-Two :class:`RegexObject` methods return all of the matches for a pattern.
+Two pattern methods return all of the matches for a pattern.
 :meth:`findall` returns a list of matching strings::
 
    >>> p = re.compile('\d+')
@@ -475,10 +475,10 @@ instances as an :term:`iterator`. [#]_ ::
 Module-Level Functions
 ----------------------
 
-You don't have to create a :class:`RegexObject` and call its methods; the
+You don't have to create a pattern object and call its methods; the
 :mod:`re` module also provides top-level functions called :func:`match`,
 :func:`search`, :func:`findall`, :func:`sub`, and so forth.  These functions
-take the same arguments as the corresponding :class:`RegexObject` method, with
+take the same arguments as the corresponding pattern method, with
 the RE string added as the first argument, and still return either ``None`` or a
 :class:`MatchObject` instance. ::
 
@@ -487,12 +487,12 @@ the RE string added as the first argument, and still return either ``None`` or a
    >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')
    <re.MatchObject instance at 80c5978>
 
-Under the hood, these functions simply produce a :class:`RegexObject` for you
+Under the hood, these functions simply create a pattern object for you
 and call the appropriate method on it.  They also store the compiled object in a
 cache, so future calls using the same RE are faster.
 
 Should you use these module-level functions, or should you get the
-:class:`RegexObject` and call its methods yourself?  That choice depends on how
+pattern and call its methods yourself?  That choice depends on how
 frequently the RE will be used, and on your personal coding style.  If the RE is
 being used at only one point in the code, then the module functions are probably
 more convenient.  If a program contains a lot of regular expressions, or re-uses
@@ -1030,7 +1030,7 @@ Modifying Strings
 
 Up to this point, we've simply performed searches against a static string.
 Regular expressions are also commonly used to modify strings in various ways,
-using the following :class:`RegexObject` methods:
+using the following pattern methods:
 
 +------------------+-----------------------------------------------+
 | Method/Attribute | Purpose                                       |
@@ -1050,7 +1050,7 @@ using the following :class:`RegexObject` methods:
 Splitting Strings
 -----------------
 
-The :meth:`split` method of a :class:`RegexObject` splits a string apart
+The :meth:`split` method of a pattern splits a string apart
 wherever the RE matches, returning a list of the pieces. It's similar to the
 :meth:`split` method of strings but provides much more generality in the
 delimiters that you can split by; :meth:`split` only supports splitting by
@@ -1195,10 +1195,10 @@ hexadecimal::
    'Call 0xffd2 for printing, 0xc000 for user code.'
 
 When using the module-level :func:`re.sub` function, the pattern is passed as
-the first argument.  The pattern may be a string or a :class:`RegexObject`; if
+the first argument.  The pattern may be provided as an object or as a string; if
 you need to specify regular expression flags, you must either use a
-:class:`RegexObject` as the first parameter, or use embedded modifiers in the
-pattern, e.g.  ``sub("(?i)b+", "x", "bbbb BBBB")`` returns ``'x x'``.
+pattern object as the first parameter, or use embedded modifiers in the
+pattern string, e.g. ``sub("(?i)b+", "x", "bbbb BBBB")`` returns ``'x x'``.
 
 
 Common Problems
index 3cba020bb84171f64f2b7ec5adca52e63d554735..1928c2adfd9eaaa43b2a59639ae13fb2b61470cc 100644 (file)
@@ -204,8 +204,7 @@ length message::
            while totalsent < MSGLEN:
                sent = self.sock.send(msg[totalsent:])
                if sent == 0:
-                   raise RuntimeError, \
-                       "socket connection broken"
+                   raise RuntimeError("socket connection broken")
                totalsent = totalsent + sent
 
        def myreceive(self):
@@ -213,8 +212,7 @@ length message::
            while len(msg) < MSGLEN:
                chunk = self.sock.recv(MSGLEN-len(msg))
                if chunk == '':
-                   raise RuntimeError, \
-                       "socket connection broken"
+                   raise RuntimeError("socket connection broken")
                msg = msg + chunk
            return msg
 
index daf24708a49bb7bb8f0776fe5566c11d857ba261..8f99ded22c3a67a6d32cc18370dd1c913c61c21b 100644 (file)
@@ -37,7 +37,7 @@ Usage: %prog [options] msgfile
         os.mkdir(opts.directory)
     except OSError, e:
         # Ignore directory exists error
-        if e.errno <> errno.EEXIST:
+        if e.errno != errno.EEXIST:
             raise
 
     fp = open(msgfile)
index 9e89cbc607ff31af1f509da71f4b05504d9cd818..0a3d92ad544dc3b028ab517d9b0d45ff0da53471 100644 (file)
@@ -149,21 +149,21 @@ def test():
     except ZeroDivisionError:
         print '\tGot ZeroDivisionError as expected from pool.apply()'
     else:
-        raise AssertionError, 'expected ZeroDivisionError'
+        raise AssertionError('expected ZeroDivisionError')
 
     try:
         print pool.map(f, range(10))
     except ZeroDivisionError:
         print '\tGot ZeroDivisionError as expected from pool.map()'
     else:
-        raise AssertionError, 'expected ZeroDivisionError'
+        raise AssertionError('expected ZeroDivisionError')
 
     try:
         print list(pool.imap(f, range(10)))
     except ZeroDivisionError:
         print '\tGot ZeroDivisionError as expected from list(pool.imap())'
     else:
-        raise AssertionError, 'expected ZeroDivisionError'
+        raise AssertionError('expected ZeroDivisionError')
 
     it = pool.imap(f, range(10))
     for i in range(10):
@@ -176,7 +176,7 @@ def test():
             break
         else:
             if i == 5:
-                raise AssertionError, 'expected ZeroDivisionError'
+                raise AssertionError('expected ZeroDivisionError')
 
     assert i == 9
     print '\tGot ZeroDivisionError as expected from IMapIterator.next()'
index 2f43ad8d95712675debe8ac7712974bb1ed81b56..fd2ae77d870fafae321a381c1f859a5b903f2e3f 100644 (file)
@@ -249,7 +249,7 @@ def test(namespace=multiprocessing):
         info = multiprocessing._debug_info()
         if info:
             print info
-            raise ValueError, 'there should be no positive refcounts left'
+            raise ValueError('there should be no positive refcounts left')
 
 
 if __name__ == '__main__':
@@ -271,6 +271,6 @@ if __name__ == '__main__':
         import multiprocessing.dummy as namespace
     else:
         print 'Usage:\n\t%s [processes | manager | threads]' % sys.argv[0]
-        raise SystemExit, 2
+        raise SystemExit(2)
 
     test(namespace)
index 2f037c7e0e946959e03bed687282b05e19aa5bb7..91464efa8fdbf257b6cac88bca2513663cd99e70 100644 (file)
@@ -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:
index 9a1acd6f34305917f85dcd4291d23411c0c9c827..eca14d6a60023aca475f9836d7d8f5666032f614 100644 (file)
@@ -1210,8 +1210,7 @@ constructs a new Python object each time!
 Variable-sized data types
 ^^^^^^^^^^^^^^^^^^^^^^^^^
 
-``ctypes`` provides some support for variable-sized arrays and structures (this
-was added in version 0.9.9.7).
+``ctypes`` provides some support for variable-sized arrays and structures.
 
 The ``resize`` function can be used to resize the memory buffer of an existing
 ctypes object.  The function takes the object as first argument, and the
index f672af6e144c57aaf3ed697ceacb83c7eaf24a71..2cea693d39832e19e1e493e76c3e5dc3a22ff684 100644 (file)
@@ -100,7 +100,7 @@ The :mod:`EasyDialogs` module defines the following functions:
    +----------------------+------------------------------------------+
 
    *commandlist* is a list of items of the form *cmdstr* or ``(cmdstr, descr)``,
-   where *descr* is as above.  The *cmdstr*s will appear in a popup menu.  When
+   where *descr* is as above.  The *cmdstr*s will appear in a popup menu.  When
    chosen, the text of *cmdstr* will be appended to the command line as is, except
    that a trailing ``':'`` or ``'='`` (if present) will be trimmed off.
 
index 9116bdaec7c407acfc20643fd46abc1e28ba21fd..4679e70ad4464c6ac183232a145b2a0466c23ed3 100644 (file)
@@ -84,9 +84,9 @@ The following exceptions are only used as base classes for other exceptions.
 
 .. exception:: LookupError
 
-   The base class for the exceptions that are raised when a key or index used on a
-   mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`.  This can be
-   raised directly by :func:`sys.setdefaultencoding`.
+   The base class for the exceptions that are raised when a key or index used on
+   a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`.  This
+   can be raised directly by :func:`codecs.lookup`.
 
 
 .. exception:: EnvironmentError
index b3b977f9345d9223b48fe5169e0582c8b45de5d8..fa0b3cba976fd851845bd4c9fb5ae55f40ff206f 100644 (file)
@@ -96,7 +96,7 @@ The module defines the following functions:
 
    Perform the lock operation *op* on file descriptor *fd* (file objects providing
    a :meth:`fileno` method are accepted as well). See the Unix manual
-   :manpage:`flock(3)` for details.  (On some systems, this function is emulated
+   :manpage:`flock(2)` for details.  (On some systems, this function is emulated
    using :cfunc:`fcntl`.)
 
 
index 09a41f69c6d6997c06b26d171bdff9b309f34e83..86089d241f18a09602ee2843807edbec688871dd 100644 (file)
@@ -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:
index fa179df5b445e4afc8440739c4817f935913b2bf..24c2191defab8e70831559a3b45aa46ddecc4ebd 100644 (file)
@@ -528,6 +528,9 @@ by file descriptors.
    Force write of file with filedescriptor *fd* to disk. Does not force update of
    metadata. Availability: Unix.
 
+   .. note::
+      This function is not available on MacOS.
+
 
 .. function:: fpathconf(fd, name)
 
index cd90c389c3c17fac7ed66ab8425e97dfa9c9c296..9900278022b492036b712fa82d7cacc3a488422e 100644 (file)
@@ -169,7 +169,7 @@ Java Platform
 
 .. function:: java_ver(release='', vendor='', vminfo=('','',''), osinfo=('','',''))
 
-   Version interface for JPython.
+   Version interface for Jython.
 
    Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a
    tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple
index 773690437fb4b28e48acd8620036f96de04b6f94..2ce612aba7b2ca67d56fe45a5d049fb7cd6e05cb 100644 (file)
@@ -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;
index 50f1afd3484989471e4484f0bcc943ba21541331..85a9d79260dfb294067ab2f82ac65eb06fefbc93 100644 (file)
@@ -52,7 +52,7 @@ Completer objects have the following method:
 
 .. method:: Completer.complete(text, state)
 
-   Return the *state*th completion for *text*.
+   Return the *state*th completion for *text*.
 
    If called for *text* that doesn't include a period character (``'.'``), it will
    complete from names currently defined in :mod:`__main__`, :mod:`__builtin__` and
index e09b646e161f188e8b61e0bab61fb7311bc71fea..ad3ab57882a685e8332f4ac1b38fe1fd02b05a2b 100644 (file)
@@ -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::
 
index 3793a89b03a909bb0cbf143db057bc40ba553d1c..c039eee7169b1d04e0d0d18bc295768b63daaaf0 100644 (file)
@@ -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)
index d1b107ecc63253f9c6b15cbbd55b98929cf3ff89..97fe268a55bdd5e50ef5149cd10d872b93132ef4 100644 (file)
@@ -401,6 +401,9 @@ The module :mod:`socket` exports the following constants and functions:
    library and needs objects of type :ctype:`struct in_addr`, which is the C type
    for the 32-bit packed binary this function returns.
 
+   :func:`inet_aton` also accepts strings with less than three dots; see the
+   Unix manual page :manpage:`inet(3)` for details.
+
    If the IPv4 address string passed to this function is invalid,
    :exc:`socket.error` will be raised. Note that exactly what is valid depends on
    the underlying C implementation of :cfunc:`inet_aton`.
index ce8085d973bc33f4c3b46af5fd9f16e61bc5a0a1..b1a179194026e5f3fa5a315ea68f7408022220fe 100644 (file)
@@ -29,9 +29,6 @@ is maintained at ActiveState.)
    `Tkinter reference: a GUI for Python <http://infohost.nmt.edu/tcc/help/pubs/lang.html>`_
       On-line reference material.
 
-   `Tkinter for JPython <http://jtkinter.sourceforge.net>`_
-      The Jython interface to Tkinter.
-
    `Python and Tkinter Programming <http://www.amazon.com/exec/obidos/ASIN/1884777813>`_
       The book by John Grayson (ISBN 1-884777-81-3).
 
index 020c893f021323c1fca1a88223d94f583a79cce5..0e8ba67a04afedf29c501d2d45a45ba0da8b6284 100644 (file)
@@ -288,7 +288,7 @@ The simple form, ``assert expression``, is equivalent to ::
 The extended form, ``assert expression1, expression2``, is equivalent to ::
 
    if __debug__:
-      if not expression1: raise AssertionError, expression2
+      if not expression1: raise AssertionError(expression2)
 
 .. index::
    single: __debug__
index 33f6db7ed3a79bc14070350bc83c138ebc221dd6..89ef617e6e71729262aa0704d025512c67ea5133 100644 (file)
@@ -40,9 +40,9 @@ romanNumeralMap = (('M',  1000),
 def toRoman(n):
     """convert integer to Roman numeral"""
     if not (0 < n < 5000):
-        raise OutOfRangeError, "number out of range (must be 1..4999)"
-    if int(n) <> n:
-        raise NotIntegerError, "decimals can not be converted"
+        raise OutOfRangeError("number out of range (must be 1..4999)")
+    if int(n) != n:
+        raise NotIntegerError("decimals can not be converted")
 
     result = ""
     for numeral, integer in romanNumeralMap:
@@ -67,9 +67,9 @@ romanNumeralPattern = re.compile("""
 def fromRoman(s):
     """convert Roman numeral to integer"""
     if not s:
-        raise InvalidRomanNumeralError, 'Input can not be blank'
+        raise InvalidRomanNumeralError('Input can not be blank')
     if not romanNumeralPattern.search(s):
-        raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
+        raise InvalidRomanNumeralError('Invalid Roman numeral: %s' % s)
 
     result = 0
     index = 0
index 245a759bed921fe4d59a23129a77d635e1c722b4..7684f65cfec0bfaa6e6223cb9fbf94569cb59f5f 100644 (file)
@@ -164,7 +164,7 @@ class CheckSuspiciousMarkupBuilder(Builder):
         except IOError: return
         for i, row in enumerate(csv.reader(f)):
             if len(row) != 4:
-                raise ValueError, "wrong format in %s, line %d: %s" % (filename, i+1, row)
+                raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row))
             docname, lineno, issue, text = row
             docname = docname.decode('utf-8')
             if lineno: lineno = int(lineno)
index 95a6ea4d2cba3cc4020bb782e0397072a103cbf3..55462d9cf3fb38adb761b97f90d1886d3e5b88f8 100644 (file)
@@ -285,7 +285,7 @@ This example, as usual, demonstrates some new Python features:
   and ``methodname`` is the name of a method that is defined by the object's type.
   Different types define different methods.  Methods of different types may have
   the same name without causing ambiguity.  (It is possible to define your own
-  object types and methods, using *classes*, as discussed later in this tutorial.)
+  object types and methods, using *classes*, see :ref:`tut-classes`)
   The method :meth:`append` shown in the example is defined for list objects; it
   adds a new element at the end of the list.  In this example it is equivalent to
   ``result = result + [b]``, but more efficient.
@@ -312,14 +312,23 @@ defined to allow.  For example::
    def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
        while True:
            ok = raw_input(prompt)
-           if ok in ('y', 'ye', 'yes'): return True
-           if ok in ('n', 'no', 'nop', 'nope'): return False
+           if ok in ('y', 'ye', 'yes'):
+               return True
+           if ok in ('n', 'no', 'nop', 'nope'):
+               return False
            retries = retries - 1
-           if retries < 0: raise IOError, 'refusenik user'
+           if retries < 0:
+               raise IOError('refusenik user')
            print complaint
 
-This function can be called either like this: ``ask_ok('Do you really want to
-quit?')`` or like this: ``ask_ok('OK to overwrite the file?', 2)``.
+This function can be called in several ways:
+
+* giving only the mandatory argument:
+  ``ask_ok('Do you really want to quit?')``
+* giving one of the optional arguments:
+  ``ask_ok('OK to overwrite the file?', 2)``
+* or even giving all arguments:
+  ``ask_ok('OK to overwrite the file?', 2, 'Come on, only yes or no!')``
 
 This example also introduces the :keyword:`in` keyword. This tests whether or
 not a sequence contains a certain value.
index 1ffad387f8d903009e95d5735fa57e5444d3a75e..fb2f6fee89dc43225431825709364cb6617b461f 100644 (file)
@@ -678,15 +678,15 @@ and :meth:`Semaphore` to create shared locks.)
         for N in range(1, 1000, 10):
             p.apply_async(factorial, (N, d))
 
-    # Mark pool as closed -- no more tasks can be added.
-    p.close()
+        # Mark pool as closed -- no more tasks can be added.
+        p.close()
 
-    # Wait for tasks to exit
-    p.join()
+        # Wait for tasks to exit
+        p.join()
 
-    # Output results
-    for k, v in sorted(d.items()):
-        print k, v
+        # Output results
+        for k, v in sorted(d.items()):
+            print k, v
 
 This will produce the output::
 
index 0eba43544e07c5e611bdaff93c0cb5f532355304..8b37ef4f78cd772cf34e029aa3eb6a99fb428e44 100644 (file)
@@ -14,7 +14,7 @@ warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2)
 del warnpy3k
 
 # note: avoid importing non-builtin modules
-import imp                      ### not available in JPython?
+import imp                      ### not available in Jython?
 import sys
 import __builtin__
 
@@ -25,7 +25,7 @@ import marshal
 __all__ = ["ImportManager","Importer","BuiltinImporter"]
 
 _StringType = type('')
-_ModuleType = type(sys)         ### doesn't work in JPython...
+_ModuleType = type(sys)         ### doesn't work in Jython...
 
 class ImportManager:
     "Manage the import process."
@@ -639,8 +639,8 @@ def _test_revamp():
 # TODO
 #
 # from Finn Bock:
-#   type(sys) is not a module in JPython. what to use instead?
-#   imp.C_EXTENSION is not in JPython. same for get_suffixes and new_module
+#   type(sys) is not a module in Jython. what to use instead?
+#   imp.C_EXTENSION is not in Jython. same for get_suffixes and new_module
 #
 #   given foo.py of:
 #      import sys
index dbb2b4900f41fcc88296bab38964fc573007b802..3e5f9bcaf964bdf8572d3e7b28d49259dbec21be 100644 (file)
@@ -6194,7 +6194,7 @@ unicode_center(PyUnicodeObject *self, PyObject *args)
 
 /* This code should go into some future Unicode collation support
    module. The basic comparison should compare ordinals on a naive
-   basis (this is what Java does and thus JPython too). */
+   basis (this is what Java does and thus Jython too). */
 
 /* speedy UTF-16 code point order comparison */
 /* gleaned from: */