Skip to content

Commit

Permalink
Merged revisions 53623-53858 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/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.
........
  • Loading branch information
Yhg1s committed Feb 23, 2007
1 parent 63eecc7 commit cf297e4
Show file tree
Hide file tree
Showing 69 changed files with 1,454 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Doc/lib/emailgenerator.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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.
Expand Down
20 changes: 12 additions & 8 deletions Doc/lib/libcollections.tex
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,20 @@ \subsubsection{\class{defaultdict} Examples \label{defaultdict-examples}}
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
Expand Down
17 changes: 11 additions & 6 deletions Doc/lib/libfunctools.tex
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ \section{\module{functools} ---

\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
Expand All @@ -98,16 +99,20 @@ \section{\module{functools} ---
...
>>> @my_decorator
... def example():
... """Docstring"""
... print 'Called example function'
...
>>> example()
Calling decorated function
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}


Expand Down
15 changes: 13 additions & 2 deletions Doc/lib/libheapq.tex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,18 @@ \section{\module{heapq} ---
>>>
\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
Expand All @@ -110,7 +121,7 @@ \section{\module{heapq} ---
\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.
Expand Down
27 changes: 27 additions & 0 deletions Doc/lib/libitertools.tex
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,33 @@ \subsection{Itertool functions \label{itertools-functions}}
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.
Expand Down
2 changes: 1 addition & 1 deletion Doc/lib/liblocale.tex
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ \subsection{Background, details, hints, tips and caveats}
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.
Expand Down
27 changes: 27 additions & 0 deletions Doc/lib/libos.tex
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,26 @@ \subsection{Files and Directories \label{os-file-dir}}
\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.
Expand Down Expand Up @@ -804,6 +824,13 @@ \subsection{Files and Directories \label{os-file-dir}}
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.
Expand Down
4 changes: 2 additions & 2 deletions Doc/lib/libshutil.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ \section{\module{shutil} ---
\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}
Expand Down
2 changes: 1 addition & 1 deletion Doc/lib/libstdtypes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ \section{Set Types ---
\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.
Expand Down
59 changes: 59 additions & 0 deletions Doc/lib/libstruct.tex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ \section{\module{struct} ---
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
Expand All @@ -37,6 +46,16 @@ \section{\module{struct} ---
(\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.
Expand Down Expand Up @@ -208,3 +227,43 @@ \section{\module{struct} ---
\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}

8 changes: 5 additions & 3 deletions Doc/lib/libtarfile.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ \section{\module{tarfile} --- Read and write tar archive files}
\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.}
Expand All @@ -48,8 +49,8 @@ \section{\module{tarfile} --- Read and write tar archive files}
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
Expand Down Expand Up @@ -160,6 +161,7 @@ \subsection{TarFile Objects \label{tarfile-objects}}

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}
Expand Down
24 changes: 20 additions & 4 deletions Doc/lib/libzipfile.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ \section{\module{zipfile} ---
{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:

Expand Down Expand Up @@ -99,6 +101,8 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
\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
Expand All @@ -112,6 +116,9 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
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}{}
Expand All @@ -138,9 +145,18 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
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}{}
Expand Down
2 changes: 1 addition & 1 deletion Include/Python-ast.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* File automatically generated by Parser/asdl_c.py */
/* File automatically generated by Parser/asdl_c.py. */

#include "asdl.h"

Expand Down
3 changes: 3 additions & 0 deletions Include/dictobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
PyAPI_FUNC(int) PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
PyAPI_FUNC(int) _PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);

/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
Expand Down
Loading

0 comments on commit cf297e4

Please sign in to comment.