From a3c242c19d1cb87414a65e6094baa9425e8ec887 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 27 Oct 2009 14:19:50 +0000 Subject: Merged revisions 72558,72745,72750,72876,73042,73045-73048,73069,73089,73163,73186,73213,73215,73217,73257-73258,73260 via svnmerge from 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. ........ --- Doc/c-api/buffer.rst | 2 +- Doc/c-api/list.rst | 10 ++++++---- Doc/c-api/sequence.rst | 10 +++++----- Doc/conf.py | 3 +++ Doc/howto/regex.rst | 28 ++++++++++++++-------------- Doc/howto/sockets.rst | 6 ++---- Doc/includes/email-unpack.py | 2 +- Doc/includes/mp_pool.py | 8 ++++---- Doc/includes/mp_synchronize.py | 4 ++-- Doc/library/crypt.rst | 3 ++- Doc/library/ctypes.rst | 3 +-- Doc/library/easydialogs.rst | 2 +- Doc/library/exceptions.rst | 6 +++--- Doc/library/fcntl.rst | 2 +- Doc/library/imputil.rst | 6 +++--- Doc/library/os.rst | 3 +++ Doc/library/platform.rst | 2 +- Doc/library/rexec.rst | 6 +++--- Doc/library/rlcompleter.rst | 2 +- Doc/library/shutil.rst | 2 +- Doc/library/signal.rst | 2 +- Doc/library/socket.rst | 3 +++ Doc/library/tkinter.rst | 3 --- Doc/reference/simple_stmts.rst | 2 +- Doc/tools/roman.py | 10 +++++----- Doc/tools/sphinxext/suspicious.py | 2 +- Doc/tutorial/controlflow.rst | 21 +++++++++++++++------ Doc/whatsnew/2.6.rst | 14 +++++++------- Lib/imputil.py | 8 ++++---- Objects/unicodeobject.c | 2 +- 30 files changed, 96 insertions(+), 81 deletions(-) diff --git a/Doc/c-api/buffer.rst b/Doc/c-api/buffer.rst index 1969ad3..ad7253f 100644 --- a/Doc/c-api/buffer.rst +++ b/Doc/c-api/buffer.rst @@ -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 diff --git a/Doc/c-api/list.rst b/Doc/c-api/list.rst index 2ce5ade..ebbab13 100644 --- a/Doc/c-api/list.rst +++ b/Doc/c-api/list.rst @@ -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 diff --git a/Doc/c-api/sequence.rst b/Doc/c-api/sequence.rst index 0b22090..2808a88 100644 --- a/Doc/c-api/sequence.rst +++ b/Doc/c-api/sequence.rst @@ -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. diff --git a/Doc/conf.py b/Doc/conf.py index 76415b0..ffa5968 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -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' diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 71ff56d..1ab291a 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -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') -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 diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst index 3cba020..1928c2a 100644 --- a/Doc/howto/sockets.rst +++ b/Doc/howto/sockets.rst @@ -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 diff --git a/Doc/includes/email-unpack.py b/Doc/includes/email-unpack.py index daf2470..8f99ded 100644 --- a/Doc/includes/email-unpack.py +++ b/Doc/includes/email-unpack.py @@ -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) diff --git a/Doc/includes/mp_pool.py b/Doc/includes/mp_pool.py index 9e89cbc..0a3d92a 100644 --- a/Doc/includes/mp_pool.py +++ b/Doc/includes/mp_pool.py @@ -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()' diff --git a/Doc/includes/mp_synchronize.py b/Doc/includes/mp_synchronize.py index 2f43ad8..fd2ae77 100644 --- a/Doc/includes/mp_synchronize.py +++ b/Doc/includes/mp_synchronize.py @@ -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) 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/ctypes.rst b/Doc/library/ctypes.rst index 9a1acd6..eca14d6 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -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 diff --git a/Doc/library/easydialogs.rst b/Doc/library/easydialogs.rst index f672af6..2cea693 100644 --- a/Doc/library/easydialogs.rst +++ b/Doc/library/easydialogs.rst @@ -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. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 9116bda..4679e70 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -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 diff --git a/Doc/library/fcntl.rst b/Doc/library/fcntl.rst index b3b977f..fa0b3cb 100644 --- a/Doc/library/fcntl.rst +++ b/Doc/library/fcntl.rst @@ -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`.) 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/os.rst b/Doc/library/os.rst index fa179df..24c2191 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -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) diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst index cd90c38..9900278 100644 --- a/Doc/library/platform.rst +++ b/Doc/library/platform.rst @@ -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 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/rlcompleter.rst b/Doc/library/rlcompleter.rst index 50f1afd..85a9d79 100644 --- a/Doc/library/rlcompleter.rst +++ b/Doc/library/rlcompleter.rst @@ -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 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) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index d1b107e..97fe268 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -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`. diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index ce8085d..b1a1791 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -29,9 +29,6 @@ is maintained at ActiveState.) `Tkinter reference: a GUI for Python `_ On-line reference material. - `Tkinter for JPython `_ - The Jython interface to Tkinter. - `Python and Tkinter Programming `_ The book by John Grayson (ISBN 1-884777-81-3). diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 020c893..0e8ba67 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -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__ diff --git a/Doc/tools/roman.py b/Doc/tools/roman.py index 33f6db7..89ef617 100644 --- a/Doc/tools/roman.py +++ b/Doc/tools/roman.py @@ -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 diff --git a/Doc/tools/sphinxext/suspicious.py b/Doc/tools/sphinxext/suspicious.py index 245a759..7684f65 100644 --- a/Doc/tools/sphinxext/suspicious.py +++ b/Doc/tools/sphinxext/suspicious.py @@ -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) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 95a6ea4..55462d9 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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. diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index 1ffad38..fb2f6fe 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -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:: diff --git a/Lib/imputil.py b/Lib/imputil.py index 0eba435..8b37ef4 100644 --- a/Lib/imputil.py +++ b/Lib/imputil.py @@ -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 diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index dbb2b49..3e5f9bc 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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: */ -- cgit v0.12