summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2007-02-23 15:07:44 (GMT)
committerThomas Wouters <thomas@python.org>2007-02-23 15:07:44 (GMT)
commitcf297e46b85257396560774e5492e9d71a40f32e (patch)
tree1dcf4bb9f75f4d2baacccd49b7dec711d5004a06 /Doc/lib
parent63eecc7eee12e473701c834592db00ff1bf43423 (diff)
downloadcpython-cf297e46b85257396560774e5492e9d71a40f32e.zip
cpython-cf297e46b85257396560774e5492e9d71a40f32e.tar.gz
cpython-cf297e46b85257396560774e5492e9d71a40f32e.tar.bz2
Merged revisions 53623-53858 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r53624 | peter.astrand | 2007-02-02 20:06:36 +0100 (Fri, 02 Feb 2007) | 1 line We had several if statements checking the value of a fd. This is unsafe, since valid fds might be zero. We should check for not None instead. ........ r53635 | kurt.kaiser | 2007-02-05 07:03:18 +0100 (Mon, 05 Feb 2007) | 2 lines Add 'raw' support to configHandler. Patch 1650174 Tal Einat. ........ r53641 | kurt.kaiser | 2007-02-06 00:02:16 +0100 (Tue, 06 Feb 2007) | 5 lines 1. Calltips now 'handle' tuples in the argument list (display '<tuple>' :) Suggested solution by Christos Georgiou, Bug 791968. 2. Clean up tests, were not failing when they should have been. 4. Remove some camelcase and an unneeded try/except block. ........ r53644 | kurt.kaiser | 2007-02-06 04:21:40 +0100 (Tue, 06 Feb 2007) | 2 lines Clean up ModifiedInterpreter.runcode() structure ........ r53646 | peter.astrand | 2007-02-06 16:37:50 +0100 (Tue, 06 Feb 2007) | 1 line Applied patch 1124861.3.patch to solve bug #1124861: Automatically create pipes on Windows, if GetStdHandle fails. Will backport. ........ r53648 | lars.gustaebel | 2007-02-06 19:38:13 +0100 (Tue, 06 Feb 2007) | 4 lines Patch #1652681: create nonexistent files in append mode and allow appending to empty files. ........ r53649 | kurt.kaiser | 2007-02-06 20:09:43 +0100 (Tue, 06 Feb 2007) | 4 lines Updated patch (CodeContext.061217.patch) to [ 1362975 ] CodeContext - Improved text indentation Tal Einat 16Dec06 ........ r53650 | kurt.kaiser | 2007-02-06 20:21:19 +0100 (Tue, 06 Feb 2007) | 2 lines narrow exception per [ 1540849 ] except too broad ........ r53653 | kurt.kaiser | 2007-02-07 04:39:41 +0100 (Wed, 07 Feb 2007) | 4 lines [ 1621265 ] Auto-completion list placement Move AC window below input line unless not enough space, then put it above. Patch: Tal Einat ........ r53654 | kurt.kaiser | 2007-02-07 09:07:13 +0100 (Wed, 07 Feb 2007) | 2 lines Handle AttributeError during calltip lookup ........ r53656 | raymond.hettinger | 2007-02-07 21:08:22 +0100 (Wed, 07 Feb 2007) | 3 lines SF #1615701: make d.update(m) honor __getitem__() and keys() in dict subclasses ........ r53658 | raymond.hettinger | 2007-02-07 22:04:20 +0100 (Wed, 07 Feb 2007) | 1 line SF: 1397711 Set docs conflated immutable and hashable ........ r53660 | raymond.hettinger | 2007-02-07 22:42:17 +0100 (Wed, 07 Feb 2007) | 1 line Check for a common user error with defaultdict(). ........ r53662 | raymond.hettinger | 2007-02-07 23:24:07 +0100 (Wed, 07 Feb 2007) | 1 line Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict. ........ r53664 | raymond.hettinger | 2007-02-08 00:49:03 +0100 (Thu, 08 Feb 2007) | 1 line Silence compiler warning ........ r53666 | raymond.hettinger | 2007-02-08 01:07:32 +0100 (Thu, 08 Feb 2007) | 1 line Do not let overflows in enumerate() and count() pass silently. ........ r53668 | raymond.hettinger | 2007-02-08 01:50:39 +0100 (Thu, 08 Feb 2007) | 1 line Bypass set specific optimizations for set and frozenset subclasses. ........ r53670 | raymond.hettinger | 2007-02-08 02:42:35 +0100 (Thu, 08 Feb 2007) | 1 line Fix docstring bug ........ r53671 | martin.v.loewis | 2007-02-08 10:13:36 +0100 (Thu, 08 Feb 2007) | 3 lines Bug #1653736: Complain about keyword arguments to time.isoformat. Will backport to 2.5. ........ r53679 | kurt.kaiser | 2007-02-08 23:58:18 +0100 (Thu, 08 Feb 2007) | 6 lines Corrected some bugs in AutoComplete. Also, Page Up/Down in ACW implemented; mouse and cursor selection in ACWindow implemented; double Tab inserts current selection and closes ACW (similar to double-click and Return); scroll wheel now works in ACW. Added AutoComplete instructions to IDLE Help. ........ r53689 | martin.v.loewis | 2007-02-09 13:19:32 +0100 (Fri, 09 Feb 2007) | 3 lines Bug #1653736: Properly discard third argument to slot_nb_inplace_power. Will backport. ........ r53691 | martin.v.loewis | 2007-02-09 13:36:48 +0100 (Fri, 09 Feb 2007) | 4 lines Bug #1600860: Search for shared python library in LIBDIR, not lib/python/config, on "linux" and "gnu" systems. Will backport. ........ r53693 | martin.v.loewis | 2007-02-09 13:58:49 +0100 (Fri, 09 Feb 2007) | 2 lines Update broken link. Will backport to 2.5. ........ r53697 | georg.brandl | 2007-02-09 19:48:41 +0100 (Fri, 09 Feb 2007) | 2 lines Bug #1656078: typo in in profile docs. ........ r53731 | brett.cannon | 2007-02-11 06:36:00 +0100 (Sun, 11 Feb 2007) | 3 lines Change a very minor inconsistency (that is purely cosmetic) in the AST definition. ........ r53735 | skip.montanaro | 2007-02-11 19:24:37 +0100 (Sun, 11 Feb 2007) | 1 line fix trace.py --ignore-dir ........ r53741 | brett.cannon | 2007-02-11 20:44:41 +0100 (Sun, 11 Feb 2007) | 3 lines Check in changed Python-ast.c from a cosmetic change to Python.asdl (in r53731). ........ r53751 | brett.cannon | 2007-02-12 04:51:02 +0100 (Mon, 12 Feb 2007) | 5 lines Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c is specified at the top of the file. Also add a note that Python/Python-ast.c needs to be committed separately after a change to the AST grammar to capture the revision number of the change (which is what __version__ is set to). ........ r53752 | lars.gustaebel | 2007-02-12 10:25:53 +0100 (Mon, 12 Feb 2007) | 3 lines Bug #1656581: Point out that external file objects are supposed to be at position 0. ........ r53754 | martin.v.loewis | 2007-02-12 13:21:10 +0100 (Mon, 12 Feb 2007) | 3 lines Patch 1463026: Support default namespace in XMLGenerator. Fixes #847665. Will backport. ........ r53757 | armin.rigo | 2007-02-12 17:23:24 +0100 (Mon, 12 Feb 2007) | 4 lines Fix the line to what is my guess at the original author's meaning. (The line has no effect anyway, but is present because it's customary call the base class __init__). ........ r53763 | martin.v.loewis | 2007-02-13 09:34:45 +0100 (Tue, 13 Feb 2007) | 3 lines Patch #685268: Consider a package's __path__ in imputil. Will backport. ........ r53765 | martin.v.loewis | 2007-02-13 10:49:38 +0100 (Tue, 13 Feb 2007) | 2 lines Patch #698833: Support file decryption in zipfile. ........ r53766 | martin.v.loewis | 2007-02-13 11:10:39 +0100 (Tue, 13 Feb 2007) | 3 lines Patch #1517891: Make 'a' create the file if it doesn't exist. Fixes #1514451. ........ r53767 | martin.v.loewis | 2007-02-13 13:08:24 +0100 (Tue, 13 Feb 2007) | 3 lines Bug #1658794: Remove extraneous 'this'. Will backport to 2.5. ........ r53769 | martin.v.loewis | 2007-02-13 13:14:19 +0100 (Tue, 13 Feb 2007) | 3 lines Patch #1657276: Make NETLINK_DNRTMSG conditional. Will backport. ........ r53771 | lars.gustaebel | 2007-02-13 17:09:24 +0100 (Tue, 13 Feb 2007) | 4 lines Patch #1647484: Renamed GzipFile's filename attribute to name. The filename attribute is still accessible as a property that emits a DeprecationWarning. ........ r53772 | lars.gustaebel | 2007-02-13 17:24:00 +0100 (Tue, 13 Feb 2007) | 3 lines Strip the '.gz' extension from the filename that is written to the gzip header. ........ r53774 | martin.v.loewis | 2007-02-14 11:07:37 +0100 (Wed, 14 Feb 2007) | 2 lines Patch #1432399: Add HCI sockets. ........ r53775 | martin.v.loewis | 2007-02-14 12:30:07 +0100 (Wed, 14 Feb 2007) | 2 lines Update 1432399 to removal of _BT_SOCKADDR_MEMB. ........ r53776 | martin.v.loewis | 2007-02-14 12:30:56 +0100 (Wed, 14 Feb 2007) | 3 lines Ignore directory time stamps when considering whether to rerun libffi configure. ........ r53778 | lars.gustaebel | 2007-02-14 15:45:12 +0100 (Wed, 14 Feb 2007) | 4 lines A missing binary mode in AppendTest caused failures in Windows Buildbot. ........ r53782 | martin.v.loewis | 2007-02-15 10:51:35 +0100 (Thu, 15 Feb 2007) | 2 lines Patch #1397848: add the reasoning behind no-resize-on-shrinkage. ........ r53783 | georg.brandl | 2007-02-15 11:37:59 +0100 (Thu, 15 Feb 2007) | 2 lines Make functools.wraps() docs a bit clearer. ........ r53785 | georg.brandl | 2007-02-15 12:29:04 +0100 (Thu, 15 Feb 2007) | 2 lines Patch #1494140: Add documentation for the new struct.Struct object. ........ r53787 | georg.brandl | 2007-02-15 12:29:55 +0100 (Thu, 15 Feb 2007) | 2 lines Add missing \versionadded. ........ r53800 | brett.cannon | 2007-02-15 23:54:39 +0100 (Thu, 15 Feb 2007) | 11 lines Update the encoding package's search function to use absolute imports when calling __import__. This helps make the expected search locations for encoding modules be more explicit. One could use an explicit value for __path__ when making the call to __import__ to force the exact location searched for encodings. This would give the most strict search path possible if one is worried about malicious code being imported. The unfortunate side-effect of that is that if __path__ was modified on 'encodings' on purpose in a safe way it would not be picked up in future __import__ calls. ........ r53801 | brett.cannon | 2007-02-16 20:33:01 +0100 (Fri, 16 Feb 2007) | 2 lines Make the __import__ call in encodings.__init__ absolute with a level 0 call. ........ r53809 | vinay.sajip | 2007-02-16 23:36:24 +0100 (Fri, 16 Feb 2007) | 1 line Minor fix for currentframe (SF #1652788). ........ r53818 | raymond.hettinger | 2007-02-19 03:03:19 +0100 (Mon, 19 Feb 2007) | 3 lines Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash(). ........ r53820 | raymond.hettinger | 2007-02-19 05:08:43 +0100 (Mon, 19 Feb 2007) | 1 line Add merge() function to heapq. ........ r53821 | raymond.hettinger | 2007-02-19 06:28:28 +0100 (Mon, 19 Feb 2007) | 1 line Add tie-breaker count to preserve sort stability. ........ r53822 | raymond.hettinger | 2007-02-19 07:59:32 +0100 (Mon, 19 Feb 2007) | 1 line Use C heapreplace() instead of slower _siftup() in pure python. ........ r53823 | raymond.hettinger | 2007-02-19 08:30:21 +0100 (Mon, 19 Feb 2007) | 1 line Add test for merge stability ........ r53824 | raymond.hettinger | 2007-02-19 10:14:10 +0100 (Mon, 19 Feb 2007) | 1 line Provide an example of defaultdict with non-zero constant factory function. ........ r53825 | lars.gustaebel | 2007-02-19 10:54:47 +0100 (Mon, 19 Feb 2007) | 2 lines Moved misplaced news item. ........ r53826 | martin.v.loewis | 2007-02-19 11:55:19 +0100 (Mon, 19 Feb 2007) | 3 lines Patch #1490190: posixmodule now includes os.chflags() and os.lchflags() functions on platforms where the underlying system calls are available. ........ r53827 | raymond.hettinger | 2007-02-19 19:15:04 +0100 (Mon, 19 Feb 2007) | 1 line Fixup docstrings for merge(). ........ r53829 | raymond.hettinger | 2007-02-19 21:44:04 +0100 (Mon, 19 Feb 2007) | 1 line Fixup set/dict interoperability. ........ r53837 | raymond.hettinger | 2007-02-21 06:20:38 +0100 (Wed, 21 Feb 2007) | 1 line Add itertools.izip_longest(). ........ r53838 | raymond.hettinger | 2007-02-21 18:22:05 +0100 (Wed, 21 Feb 2007) | 1 line Remove filler struct item and fix leak. ........
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/emailgenerator.tex2
-rw-r--r--Doc/lib/libcollections.tex20
-rw-r--r--Doc/lib/libfunctools.tex17
-rw-r--r--Doc/lib/libheapq.tex15
-rw-r--r--Doc/lib/libitertools.tex27
-rw-r--r--Doc/lib/liblocale.tex2
-rw-r--r--Doc/lib/libos.tex27
-rw-r--r--Doc/lib/libshutil.tex4
-rw-r--r--Doc/lib/libstdtypes.tex2
-rw-r--r--Doc/lib/libstruct.tex59
-rw-r--r--Doc/lib/libtarfile.tex8
-rw-r--r--Doc/lib/libzipfile.tex24
12 files changed, 179 insertions, 28 deletions
diff --git a/Doc/lib/emailgenerator.tex b/Doc/lib/emailgenerator.tex
index b236673..7ab0a53 100644
--- a/Doc/lib/emailgenerator.tex
+++ b/Doc/lib/emailgenerator.tex
@@ -33,7 +33,7 @@ Optional \var{mangle_from_} is a flag that, when \code{True}, puts a
line. This is the only guaranteed portable way to avoid having such
lines be mistaken for a \UNIX{} mailbox format envelope header separator (see
\ulink{WHY THE CONTENT-LENGTH FORMAT IS BAD}
-{http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html}
+{http://www.jwz.org/doc/content-length.html}
for details). \var{mangle_from_} defaults to \code{True}, but you
might want to set this to \code{False} if you are not writing \UNIX{}
mailbox format files.
diff --git a/Doc/lib/libcollections.tex b/Doc/lib/libcollections.tex
index 3e56a3e..a763e31 100644
--- a/Doc/lib/libcollections.tex
+++ b/Doc/lib/libcollections.tex
@@ -311,16 +311,20 @@ languages):
When a letter is first encountered, it is missing from the mapping, so the
\member{default_factory} function calls \function{int()} to supply a default
count of zero. The increment operation then builds up the count for each
-letter. This technique makes counting simpler and faster than an equivalent
-technique using \method{dict.get()}:
+letter.
-\begin{verbatim}
->>> d = {}
->>> for k in s:
- d[k] = d.get(k, 0) + 1
+The function \function{int()} which always returns zero is just a special
+case of constant functions. A faster and more flexible way to create
+constant functions is to use \function{itertools.repeat()} which can supply
+any constant value (not just zero):
->>> d.items()
-[('i', 4), ('p', 2), ('s', 4), ('m', 1)]
+\begin{verbatim}
+>>> def constant_factory(value):
+... return itertools.repeat(value).next
+>>> d = defaultdict(constant_factory('<missing>'))
+>>> d.update(name='John', action='ran')
+>>> '%(name)s %(action)s to %(object)s' % d
+'John ran to <missing>'
\end{verbatim}
Setting the \member{default_factory} to \class{set} makes the
diff --git a/Doc/lib/libfunctools.tex b/Doc/lib/libfunctools.tex
index 034143a..654a5b1 100644
--- a/Doc/lib/libfunctools.tex
+++ b/Doc/lib/libfunctools.tex
@@ -66,15 +66,16 @@ two:
\begin{funcdesc}{update_wrapper}
{wrapper, wrapped\optional{, assigned}\optional{, updated}}
-Update a wrapper function to look like the wrapped function. The optional
-arguments are tuples to specify which attributes of the original
+Update a \var{wrapper} function to look like the \var{wrapped} function.
+The optional arguments are tuples to specify which attributes of the original
function are assigned directly to the matching attributes on the wrapper
function and which attributes of the wrapper function are updated with
the corresponding attributes from the original function. The default
values for these arguments are the module level constants
-\var{WRAPPER_ASSIGNMENTS} (which assigns to the wrapper function's name,
-module and documentation string) and \var{WRAPPER_UPDATES} (which
-updates the wrapper function's instance dictionary).
+\var{WRAPPER_ASSIGNMENTS} (which assigns to the wrapper function's
+\var{__name__}, \var{__module__} and \var{__doc__}, the documentation string)
+and \var{WRAPPER_UPDATES} (which updates the wrapper function's \var{__dict__},
+i.e. the instance dictionary).
The main intended use for this function is in decorator functions
which wrap the decorated function and return the wrapper. If the
@@ -98,6 +99,7 @@ as a function decorator when defining a wrapper function. For example:
...
>>> @my_decorator
... def example():
+ ... """Docstring"""
... print 'Called example function'
...
>>> example()
@@ -105,9 +107,12 @@ as a function decorator when defining a wrapper function. For example:
Called example function
>>> example.__name__
'example'
+ >>> example.__doc__
+ 'Docstring'
\end{verbatim}
Without the use of this decorator factory, the name of the example
-function would have been \code{'wrapper'}.
+function would have been \code{'wrapper'}, and the docstring of the
+original \function{example()} would have been lost.
\end{funcdesc}
diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex
index 5f3d8c5..e403a3a 100644
--- a/Doc/lib/libheapq.tex
+++ b/Doc/lib/libheapq.tex
@@ -88,7 +88,18 @@ True
>>>
\end{verbatim}
-The module also offers two general purpose functions based on heaps.
+The module also offers three general purpose functions based on heaps.
+
+\begin{funcdesc}{merge}{*iterables}
+Merge multiple sorted inputs into a single sorted output (for example, merge
+timestamped entries from multiple log files). Returns an iterator over
+over the sorted values.
+
+Similar to \code{sorted(itertools.chain(*iterables))} but returns an iterable,
+does not pull the data into memory all at once, and assumes that each of the
+input streams is already sorted (smallest to largest).
+\versionadded{2.6}
+\end{funcdesc}
\begin{funcdesc}{nlargest}{n, iterable\optional{, key}}
Return a list with the \var{n} largest elements from the dataset defined
@@ -110,7 +121,7 @@ Equivalent to: \samp{sorted(iterable, key=key)[:n]}
\versionchanged[Added the optional \var{key} argument]{2.5}
\end{funcdesc}
-Both functions perform best for smaller values of \var{n}. For larger
+The latter two functions perform best for smaller values of \var{n}. For larger
values, it is more efficient to use the \function{sorted()} function. Also,
when \code{n==1}, it is more efficient to use the builtin \function{min()}
and \function{max()} functions.
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex
index 59fbd98..ac6028b 100644
--- a/Doc/lib/libitertools.tex
+++ b/Doc/lib/libitertools.tex
@@ -302,6 +302,33 @@ by functions or loops that truncate the stream.
don't care about trailing, unmatched values from the longer iterables.
\end{funcdesc}
+\begin{funcdesc}{izip_longest}{*iterables\optional{, fillvalue}}
+ Make an iterator that aggregates elements from each of the iterables.
+ If the iterables are of uneven length, missing values are filled-in
+ with \var{fillvalue}. Iteration continues until the longest iterable
+ is exhausted. Equivalent to:
+
+ \begin{verbatim}
+ def izip_longest(*args, **kwds):
+ fillvalue = kwds.get('fillvalue')
+ def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
+ yield counter() # yields the fillvalue, or raises IndexError
+ fillers = repeat(fillvalue)
+ iters = [chain(it, sentinel(), fillers) for it in args]
+ try:
+ for tup in izip(*iters):
+ yield tup
+ except IndexError:
+ pass
+ \end{verbatim}
+
+ If one of the iterables is potentially infinite, then the
+ \function{izip_longest()} function should be wrapped with something
+ that limits the number of calls (for example \function{islice()} or
+ \function{take()}).
+ \versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{repeat}{object\optional{, times}}
Make an iterator that returns \var{object} over and over again.
Runs indefinitely unless the \var{times} argument is specified.
diff --git a/Doc/lib/liblocale.tex b/Doc/lib/liblocale.tex
index 688ccb0..319d893 100644
--- a/Doc/lib/liblocale.tex
+++ b/Doc/lib/liblocale.tex
@@ -481,7 +481,7 @@ The case conversion functions in the
locale settings. When a call to the \function{setlocale()} function
changes the \constant{LC_CTYPE} settings, the variables
\code{string.lowercase}, \code{string.uppercase} and
-\code{string.letters} are recalculated. Note that this code that uses
+\code{string.letters} are recalculated. Note that code that uses
these variable through `\keyword{from} ... \keyword{import} ...',
e.g.\ \code{from string import letters}, is not affected by subsequent
\function{setlocale()} calls.
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex
index 355d8fa..cbb35f3 100644
--- a/Doc/lib/libos.tex
+++ b/Doc/lib/libos.tex
@@ -758,6 +758,26 @@ Availability: Macintosh, \UNIX, Windows.
\versionadded{2.3}
\end{funcdesc}
+\begin{funcdesc}{chflags}{path, flags}
+Set the flags of \var{path} to the numeric \var{flags}.
+\var{flags} may take a combination (bitwise OR) of the following values
+(as defined in the \module{stat} module):
+\begin{itemize}
+ \item \code{UF_NODUMP}
+ \item \code{UF_IMMUTABLE}
+ \item \code{UF_APPEND}
+ \item \code{UF_OPAQUE}
+ \item \code{UF_NOUNLINK}
+ \item \code{SF_ARCHIVED}
+ \item \code{SF_IMMUTABLE}
+ \item \code{SF_APPEND}
+ \item \code{SF_NOUNLINK}
+ \item \code{SF_SNAPSHOT}
+\end{itemize}
+Availability: Macintosh, \UNIX.
+\versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{chroot}{path}
Change the root directory of the current process to \var{path}.
Availability: Macintosh, \UNIX.
@@ -804,6 +824,13 @@ and \var{gid}. To leave one of the ids unchanged, set it to -1.
Availability: Macintosh, \UNIX.
\end{funcdesc}
+\begin{funcdesc}{lchflags}{path, flags}
+Set the flags of \var{path} to the numeric \var{flags}, like
+\function{chflags()}, but do not follow symbolic links.
+Availability: \UNIX.
+\versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{lchown}{path, uid, gid}
Change the owner and group id of \var{path} to the numeric \var{uid}
and gid. This function will not follow symbolic links.
diff --git a/Doc/lib/libshutil.tex b/Doc/lib/libshutil.tex
index 3037e0b..ee3b535 100644
--- a/Doc/lib/libshutil.tex
+++ b/Doc/lib/libshutil.tex
@@ -44,8 +44,8 @@ file type and creator codes will not be correct.
\end{funcdesc}
\begin{funcdesc}{copystat}{src, dst}
- Copy the permission bits, last access time, and last modification
- time from \var{src} to \var{dst}. The file contents, owner, and
+ Copy the permission bits, last access time, last modification time,
+ and flags from \var{src} to \var{dst}. The file contents, owner, and
group are unaffected. \var{src} and \var{dst} are path names given
as strings.
\end{funcdesc}
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index a07e7d7..cc117ab 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -1212,7 +1212,7 @@ Notes:
\label{types-set}}
\obindex{set}
-A \dfn{set} object is an unordered collection of immutable values.
+A \dfn{set} object is an unordered collection of distinct hashable objects.
Common uses include membership testing, removing duplicates from a sequence,
and computing mathematical operations such as intersection, union, difference,
and symmetric difference.
diff --git a/Doc/lib/libstruct.tex b/Doc/lib/libstruct.tex
index 539e937..68c5c9a 100644
--- a/Doc/lib/libstruct.tex
+++ b/Doc/lib/libstruct.tex
@@ -29,6 +29,15 @@ The module defines the following exception and functions:
exactly.
\end{funcdesc}
+\begin{funcdesc}{pack_into}{fmt, buffer, offset, v1, v2, \moreargs}
+ Pack the values \code{\var{v1}, \var{v2}, \textrm{\ldots}} according to the given
+ format, write the packed bytes into the writable \var{buffer} starting at
+ \var{offset}.
+ Note that the offset is not an optional argument.
+
+ \versionadded{2.5}
+\end{funcdesc}
+
\begin{funcdesc}{unpack}{fmt, string}
Unpack the string (presumably packed by \code{pack(\var{fmt},
\textrm{\ldots})}) according to the given format. The result is a
@@ -37,6 +46,16 @@ The module defines the following exception and functions:
(\code{len(\var{string})} must equal \code{calcsize(\var{fmt})}).
\end{funcdesc}
+\begin{funcdesc}{unpack_from}{fmt, buffer\optional{,offset \code{= 0}}}
+ Unpack the \var{buffer} according to tthe given format.
+ The result is a tuple even if it contains exactly one item. The
+ \var{buffer} must contain at least the amount of data required by the
+ format (\code{len(buffer[offset:])} must be at least
+ \code{calcsize(\var{fmt})}).
+
+ \versionadded{2.5}
+\end{funcdesc}
+
\begin{funcdesc}{calcsize}{fmt}
Return the size of the struct (and hence of the string)
corresponding to the given format.
@@ -208,3 +227,43 @@ in effect; standard size and alignment does not enforce any alignment.
\seemodule{array}{Packed binary storage of homogeneous data.}
\seemodule{xdrlib}{Packing and unpacking of XDR data.}
\end{seealso}
+
+\subsection{Struct Objects \label{struct-objects}}
+
+The \module{struct} module also defines the following type:
+
+\begin{classdesc}{Struct}{format}
+ Return a new Struct object which writes and reads binary data according to
+ the format string \var{format}. Creating a Struct object once and calling
+ its methods is more efficient than calling the \module{struct} functions
+ with the same format since the format string only needs to be compiled once.
+
+ \versionadded{2.5}
+\end{classdesc}
+
+Compiled Struct objects support the following methods and attributes:
+
+\begin{methoddesc}[Struct]{pack}{v1, v2, \moreargs}
+ Identical to the \function{pack()} function, using the compiled format.
+ (\code{len(result)} will equal \member{self.size}.)
+\end{methoddesc}
+
+\begin{methoddesc}[Struct]{pack_into}{buffer, offset, v1, v2, \moreargs}
+ Identical to the \function{pack_into()} function, using the compiled format.
+\end{methoddesc}
+
+\begin{methoddesc}[Struct]{unpack}{string}
+ Identical to the \function{unpack()} function, using the compiled format.
+ (\code{len(string)} must equal \member{self.size}).
+\end{methoddesc}
+
+\begin{methoddesc}[Struct]{unpack_from}{buffer\optional{,offset
+ \code{= 0}}}
+ Identical to the \function{unpack_from()} function, using the compiled format.
+ (\code{len(buffer[offset:])} must be at least \member{self.size}).
+\end{methoddesc}
+
+\begin{memberdesc}[Struct]{format}
+ The format string used to construct this Struct object.
+\end{memberdesc}
+
diff --git a/Doc/lib/libtarfile.tex b/Doc/lib/libtarfile.tex
index 5f277da..96f835f 100644
--- a/Doc/lib/libtarfile.tex
+++ b/Doc/lib/libtarfile.tex
@@ -36,7 +36,8 @@ Some facts and figures:
\lineii{'r:'}{Open for reading exclusively without compression.}
\lineii{'r:gz'}{Open for reading with gzip compression.}
\lineii{'r:bz2'}{Open for reading with bzip2 compression.}
- \lineii{'a' or 'a:'}{Open for appending with no compression.}
+ \lineii{'a' or 'a:'}{Open for appending with no compression. The file
+ is created if it does not exist.}
\lineii{'w' or 'w:'}{Open for uncompressed writing.}
\lineii{'w:gz'}{Open for gzip compressed writing.}
\lineii{'w:bz2'}{Open for bzip2 compressed writing.}
@@ -48,8 +49,8 @@ Some facts and figures:
avoid this. If a compression method is not supported,
\exception{CompressionError} is raised.
- If \var{fileobj} is specified, it is used as an alternative to
- a file object opened for \var{name}.
+ If \var{fileobj} is specified, it is used as an alternative to a file
+ object opened for \var{name}. It is supposed to be at position 0.
For special purposes, there is a second format for \var{mode}:
\code{'filemode|[compression]'}. \function{open()} will return a
@@ -160,6 +161,7 @@ tar archive several times. Each archive member is represented by a
If \var{fileobj} is given, it is used for reading or writing data.
If it can be determined, \var{mode} is overridden by \var{fileobj}'s mode.
+ \var{fileobj} will be used from position 0.
\begin{notice}
\var{fileobj} is not closed, when \class{TarFile} is closed.
\end{notice}
diff --git a/Doc/lib/libzipfile.tex b/Doc/lib/libzipfile.tex
index 3d81e50..06a236c 100644
--- a/Doc/lib/libzipfile.tex
+++ b/Doc/lib/libzipfile.tex
@@ -17,8 +17,10 @@ understanding of the format, as defined in
{PKZIP Application Note}.
This module does not currently handle ZIP files which have appended
-comments, or multi-disk ZIP files. It can handle ZIP files that use the
-ZIP64 extensions (that is ZIP files that are more than 4 GByte in size).
+comments, or multi-disk ZIP files. It can handle ZIP files that use
+the ZIP64 extensions (that is ZIP files that are more than 4 GByte in
+size). It supports decryption of encrypted files in ZIP archives, but
+it cannot currently create an encrypted file.
The available attributes of this module are:
@@ -99,6 +101,8 @@ cat myzip.zip >> python.exe
\end{verbatim}
also works, and at least \program{WinZip} can read such files.
+ If \var{mode} is \code{a} and the file does not exist at all,
+ it is created.
\var{compression} is the ZIP compression method to use when writing
the archive, and should be \constant{ZIP_STORED} or
\constant{ZIP_DEFLATED}; unrecognized values will cause
@@ -112,6 +116,9 @@ cat myzip.zip >> python.exe
ZIP file would require ZIP64 extensions. ZIP64 extensions are disabled by
default because the default \program{zip} and \program{unzip} commands on
\UNIX{} (the InfoZIP utilities) don't support these extensions.
+
+ \versionchanged[If the file does not exist, it is created if the
+ mode is 'a']{2.6}
\end{classdesc}
\begin{methoddesc}{close}{}
@@ -138,9 +145,18 @@ cat myzip.zip >> python.exe
Print a table of contents for the archive to \code{sys.stdout}.
\end{methoddesc}
-\begin{methoddesc}{read}{name}
+\begin{methoddesc}{setpassword}{pwd}
+ Set \var{pwd} as default password to extract encrypted files.
+ \versionadded{2.6}
+\end{methoddesc}
+
+\begin{methoddesc}{read}{name\optional{, pwd}}
Return the bytes of the file in the archive. The archive must be
- open for read or append.
+ open for read or append. \var{pwd} is the password used for encrypted
+ files and, if specified, it will override the default password set with
+ \method{setpassword()}.
+
+ \versionchanged[\var{pwd} was added]{2.6}
\end{methoddesc}
\begin{methoddesc}{testzip}{}