Skip to content

Commit cf297e4

Browse files
committed
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. ........
1 parent 63eecc7 commit cf297e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1454
-283
lines changed

Doc/lib/emailgenerator.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
line. This is the only guaranteed portable way to avoid having such
3434
lines be mistaken for a \UNIX{} mailbox format envelope header separator (see
3535
\ulink{WHY THE CONTENT-LENGTH FORMAT IS BAD}
36-
{http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html}
36+
{http://www.jwz.org/doc/content-length.html}
3737
for details). \var{mangle_from_} defaults to \code{True}, but you
3838
might want to set this to \code{False} if you are not writing \UNIX{}
3939
mailbox format files.

Doc/lib/libcollections.tex

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,20 @@ \subsubsection{\class{defaultdict} Examples \label{defaultdict-examples}}
311311
When a letter is first encountered, it is missing from the mapping, so the
312312
\member{default_factory} function calls \function{int()} to supply a default
313313
count of zero. The increment operation then builds up the count for each
314-
letter. This technique makes counting simpler and faster than an equivalent
315-
technique using \method{dict.get()}:
314+
letter.
316315

317-
\begin{verbatim}
318-
>>> d = {}
319-
>>> for k in s:
320-
d[k] = d.get(k, 0) + 1
316+
The function \function{int()} which always returns zero is just a special
317+
case of constant functions. A faster and more flexible way to create
318+
constant functions is to use \function{itertools.repeat()} which can supply
319+
any constant value (not just zero):
321320

322-
>>> d.items()
323-
[('i', 4), ('p', 2), ('s', 4), ('m', 1)]
321+
\begin{verbatim}
322+
>>> def constant_factory(value):
323+
... return itertools.repeat(value).next
324+
>>> d = defaultdict(constant_factory('<missing>'))
325+
>>> d.update(name='John', action='ran')
326+
>>> '%(name)s %(action)s to %(object)s' % d
327+
'John ran to <missing>'
324328
\end{verbatim}
325329

326330
Setting the \member{default_factory} to \class{set} makes the

Doc/lib/libfunctools.tex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ \section{\module{functools} ---
6666

6767
\begin{funcdesc}{update_wrapper}
6868
{wrapper, wrapped\optional{, assigned}\optional{, updated}}
69-
Update a wrapper function to look like the wrapped function. The optional
70-
arguments are tuples to specify which attributes of the original
69+
Update a \var{wrapper} function to look like the \var{wrapped} function.
70+
The optional arguments are tuples to specify which attributes of the original
7171
function are assigned directly to the matching attributes on the wrapper
7272
function and which attributes of the wrapper function are updated with
7373
the corresponding attributes from the original function. The default
7474
values for these arguments are the module level constants
75-
\var{WRAPPER_ASSIGNMENTS} (which assigns to the wrapper function's name,
76-
module and documentation string) and \var{WRAPPER_UPDATES} (which
77-
updates the wrapper function's instance dictionary).
75+
\var{WRAPPER_ASSIGNMENTS} (which assigns to the wrapper function's
76+
\var{__name__}, \var{__module__} and \var{__doc__}, the documentation string)
77+
and \var{WRAPPER_UPDATES} (which updates the wrapper function's \var{__dict__},
78+
i.e. the instance dictionary).
7879

7980
The main intended use for this function is in decorator functions
8081
which wrap the decorated function and return the wrapper. If the
@@ -98,16 +99,20 @@ \section{\module{functools} ---
9899
...
99100
>>> @my_decorator
100101
... def example():
102+
... """Docstring"""
101103
... print 'Called example function'
102104
...
103105
>>> example()
104106
Calling decorated function
105107
Called example function
106108
>>> example.__name__
107109
'example'
110+
>>> example.__doc__
111+
'Docstring'
108112
\end{verbatim}
109113
Without the use of this decorator factory, the name of the example
110-
function would have been \code{'wrapper'}.
114+
function would have been \code{'wrapper'}, and the docstring of the
115+
original \function{example()} would have been lost.
111116
\end{funcdesc}
112117

113118

Doc/lib/libheapq.tex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,18 @@ \section{\module{heapq} ---
8888
>>>
8989
\end{verbatim}
9090

91-
The module also offers two general purpose functions based on heaps.
91+
The module also offers three general purpose functions based on heaps.
92+
93+
\begin{funcdesc}{merge}{*iterables}
94+
Merge multiple sorted inputs into a single sorted output (for example, merge
95+
timestamped entries from multiple log files). Returns an iterator over
96+
over the sorted values.
97+
98+
Similar to \code{sorted(itertools.chain(*iterables))} but returns an iterable,
99+
does not pull the data into memory all at once, and assumes that each of the
100+
input streams is already sorted (smallest to largest).
101+
\versionadded{2.6}
102+
\end{funcdesc}
92103

93104
\begin{funcdesc}{nlargest}{n, iterable\optional{, key}}
94105
Return a list with the \var{n} largest elements from the dataset defined
@@ -110,7 +121,7 @@ \section{\module{heapq} ---
110121
\versionchanged[Added the optional \var{key} argument]{2.5}
111122
\end{funcdesc}
112123

113-
Both functions perform best for smaller values of \var{n}. For larger
124+
The latter two functions perform best for smaller values of \var{n}. For larger
114125
values, it is more efficient to use the \function{sorted()} function. Also,
115126
when \code{n==1}, it is more efficient to use the builtin \function{min()}
116127
and \function{max()} functions.

Doc/lib/libitertools.tex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,33 @@ \subsection{Itertool functions \label{itertools-functions}}
302302
don't care about trailing, unmatched values from the longer iterables.
303303
\end{funcdesc}
304304

305+
\begin{funcdesc}{izip_longest}{*iterables\optional{, fillvalue}}
306+
Make an iterator that aggregates elements from each of the iterables.
307+
If the iterables are of uneven length, missing values are filled-in
308+
with \var{fillvalue}. Iteration continues until the longest iterable
309+
is exhausted. Equivalent to:
310+
311+
\begin{verbatim}
312+
def izip_longest(*args, **kwds):
313+
fillvalue = kwds.get('fillvalue')
314+
def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
315+
yield counter() # yields the fillvalue, or raises IndexError
316+
fillers = repeat(fillvalue)
317+
iters = [chain(it, sentinel(), fillers) for it in args]
318+
try:
319+
for tup in izip(*iters):
320+
yield tup
321+
except IndexError:
322+
pass
323+
\end{verbatim}
324+
325+
If one of the iterables is potentially infinite, then the
326+
\function{izip_longest()} function should be wrapped with something
327+
that limits the number of calls (for example \function{islice()} or
328+
\function{take()}).
329+
\versionadded{2.6}
330+
\end{funcdesc}
331+
305332
\begin{funcdesc}{repeat}{object\optional{, times}}
306333
Make an iterator that returns \var{object} over and over again.
307334
Runs indefinitely unless the \var{times} argument is specified.

Doc/lib/liblocale.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ \subsection{Background, details, hints, tips and caveats}
481481
locale settings. When a call to the \function{setlocale()} function
482482
changes the \constant{LC_CTYPE} settings, the variables
483483
\code{string.lowercase}, \code{string.uppercase} and
484-
\code{string.letters} are recalculated. Note that this code that uses
484+
\code{string.letters} are recalculated. Note that code that uses
485485
these variable through `\keyword{from} ... \keyword{import} ...',
486486
e.g.\ \code{from string import letters}, is not affected by subsequent
487487
\function{setlocale()} calls.

Doc/lib/libos.tex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,26 @@ \subsection{Files and Directories \label{os-file-dir}}
758758
\versionadded{2.3}
759759
\end{funcdesc}
760760

761+
\begin{funcdesc}{chflags}{path, flags}
762+
Set the flags of \var{path} to the numeric \var{flags}.
763+
\var{flags} may take a combination (bitwise OR) of the following values
764+
(as defined in the \module{stat} module):
765+
\begin{itemize}
766+
\item \code{UF_NODUMP}
767+
\item \code{UF_IMMUTABLE}
768+
\item \code{UF_APPEND}
769+
\item \code{UF_OPAQUE}
770+
\item \code{UF_NOUNLINK}
771+
\item \code{SF_ARCHIVED}
772+
\item \code{SF_IMMUTABLE}
773+
\item \code{SF_APPEND}
774+
\item \code{SF_NOUNLINK}
775+
\item \code{SF_SNAPSHOT}
776+
\end{itemize}
777+
Availability: Macintosh, \UNIX.
778+
\versionadded{2.6}
779+
\end{funcdesc}
780+
761781
\begin{funcdesc}{chroot}{path}
762782
Change the root directory of the current process to \var{path}.
763783
Availability: Macintosh, \UNIX.
@@ -804,6 +824,13 @@ \subsection{Files and Directories \label{os-file-dir}}
804824
Availability: Macintosh, \UNIX.
805825
\end{funcdesc}
806826

827+
\begin{funcdesc}{lchflags}{path, flags}
828+
Set the flags of \var{path} to the numeric \var{flags}, like
829+
\function{chflags()}, but do not follow symbolic links.
830+
Availability: \UNIX.
831+
\versionadded{2.6}
832+
\end{funcdesc}
833+
807834
\begin{funcdesc}{lchown}{path, uid, gid}
808835
Change the owner and group id of \var{path} to the numeric \var{uid}
809836
and gid. This function will not follow symbolic links.

Doc/lib/libshutil.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ \section{\module{shutil} ---
4444
\end{funcdesc}
4545

4646
\begin{funcdesc}{copystat}{src, dst}
47-
Copy the permission bits, last access time, and last modification
48-
time from \var{src} to \var{dst}. The file contents, owner, and
47+
Copy the permission bits, last access time, last modification time,
48+
and flags from \var{src} to \var{dst}. The file contents, owner, and
4949
group are unaffected. \var{src} and \var{dst} are path names given
5050
as strings.
5151
\end{funcdesc}

Doc/lib/libstdtypes.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ \section{Set Types ---
12121212
\label{types-set}}
12131213
\obindex{set}
12141214

1215-
A \dfn{set} object is an unordered collection of immutable values.
1215+
A \dfn{set} object is an unordered collection of distinct hashable objects.
12161216
Common uses include membership testing, removing duplicates from a sequence,
12171217
and computing mathematical operations such as intersection, union, difference,
12181218
and symmetric difference.

Doc/lib/libstruct.tex

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ \section{\module{struct} ---
2929
exactly.
3030
\end{funcdesc}
3131

32+
\begin{funcdesc}{pack_into}{fmt, buffer, offset, v1, v2, \moreargs}
33+
Pack the values \code{\var{v1}, \var{v2}, \textrm{\ldots}} according to the given
34+
format, write the packed bytes into the writable \var{buffer} starting at
35+
\var{offset}.
36+
Note that the offset is not an optional argument.
37+
38+
\versionadded{2.5}
39+
\end{funcdesc}
40+
3241
\begin{funcdesc}{unpack}{fmt, string}
3342
Unpack the string (presumably packed by \code{pack(\var{fmt},
3443
\textrm{\ldots})}) according to the given format. The result is a
@@ -37,6 +46,16 @@ \section{\module{struct} ---
3746
(\code{len(\var{string})} must equal \code{calcsize(\var{fmt})}).
3847
\end{funcdesc}
3948

49+
\begin{funcdesc}{unpack_from}{fmt, buffer\optional{,offset \code{= 0}}}
50+
Unpack the \var{buffer} according to tthe given format.
51+
The result is a tuple even if it contains exactly one item. The
52+
\var{buffer} must contain at least the amount of data required by the
53+
format (\code{len(buffer[offset:])} must be at least
54+
\code{calcsize(\var{fmt})}).
55+
56+
\versionadded{2.5}
57+
\end{funcdesc}
58+
4059
\begin{funcdesc}{calcsize}{fmt}
4160
Return the size of the struct (and hence of the string)
4261
corresponding to the given format.
@@ -208,3 +227,43 @@ \section{\module{struct} ---
208227
\seemodule{array}{Packed binary storage of homogeneous data.}
209228
\seemodule{xdrlib}{Packing and unpacking of XDR data.}
210229
\end{seealso}
230+
231+
\subsection{Struct Objects \label{struct-objects}}
232+
233+
The \module{struct} module also defines the following type:
234+
235+
\begin{classdesc}{Struct}{format}
236+
Return a new Struct object which writes and reads binary data according to
237+
the format string \var{format}. Creating a Struct object once and calling
238+
its methods is more efficient than calling the \module{struct} functions
239+
with the same format since the format string only needs to be compiled once.
240+
241+
\versionadded{2.5}
242+
\end{classdesc}
243+
244+
Compiled Struct objects support the following methods and attributes:
245+
246+
\begin{methoddesc}[Struct]{pack}{v1, v2, \moreargs}
247+
Identical to the \function{pack()} function, using the compiled format.
248+
(\code{len(result)} will equal \member{self.size}.)
249+
\end{methoddesc}
250+
251+
\begin{methoddesc}[Struct]{pack_into}{buffer, offset, v1, v2, \moreargs}
252+
Identical to the \function{pack_into()} function, using the compiled format.
253+
\end{methoddesc}
254+
255+
\begin{methoddesc}[Struct]{unpack}{string}
256+
Identical to the \function{unpack()} function, using the compiled format.
257+
(\code{len(string)} must equal \member{self.size}).
258+
\end{methoddesc}
259+
260+
\begin{methoddesc}[Struct]{unpack_from}{buffer\optional{,offset
261+
\code{= 0}}}
262+
Identical to the \function{unpack_from()} function, using the compiled format.
263+
(\code{len(buffer[offset:])} must be at least \member{self.size}).
264+
\end{methoddesc}
265+
266+
\begin{memberdesc}[Struct]{format}
267+
The format string used to construct this Struct object.
268+
\end{memberdesc}
269+

Doc/lib/libtarfile.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ \section{\module{tarfile} --- Read and write tar archive files}
3636
\lineii{'r:'}{Open for reading exclusively without compression.}
3737
\lineii{'r:gz'}{Open for reading with gzip compression.}
3838
\lineii{'r:bz2'}{Open for reading with bzip2 compression.}
39-
\lineii{'a' or 'a:'}{Open for appending with no compression.}
39+
\lineii{'a' or 'a:'}{Open for appending with no compression. The file
40+
is created if it does not exist.}
4041
\lineii{'w' or 'w:'}{Open for uncompressed writing.}
4142
\lineii{'w:gz'}{Open for gzip compressed writing.}
4243
\lineii{'w:bz2'}{Open for bzip2 compressed writing.}
@@ -48,8 +49,8 @@ \section{\module{tarfile} --- Read and write tar archive files}
4849
avoid this. If a compression method is not supported,
4950
\exception{CompressionError} is raised.
5051

51-
If \var{fileobj} is specified, it is used as an alternative to
52-
a file object opened for \var{name}.
52+
If \var{fileobj} is specified, it is used as an alternative to a file
53+
object opened for \var{name}. It is supposed to be at position 0.
5354

5455
For special purposes, there is a second format for \var{mode}:
5556
\code{'filemode|[compression]'}. \function{open()} will return a
@@ -160,6 +161,7 @@ \subsection{TarFile Objects \label{tarfile-objects}}
160161

161162
If \var{fileobj} is given, it is used for reading or writing data.
162163
If it can be determined, \var{mode} is overridden by \var{fileobj}'s mode.
164+
\var{fileobj} will be used from position 0.
163165
\begin{notice}
164166
\var{fileobj} is not closed, when \class{TarFile} is closed.
165167
\end{notice}

Doc/lib/libzipfile.tex

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ \section{\module{zipfile} ---
1717
{PKZIP Application Note}.
1818

1919
This module does not currently handle ZIP files which have appended
20-
comments, or multi-disk ZIP files. It can handle ZIP files that use the
21-
ZIP64 extensions (that is ZIP files that are more than 4 GByte in size).
20+
comments, or multi-disk ZIP files. It can handle ZIP files that use
21+
the ZIP64 extensions (that is ZIP files that are more than 4 GByte in
22+
size). It supports decryption of encrypted files in ZIP archives, but
23+
it cannot currently create an encrypted file.
2224

2325
The available attributes of this module are:
2426

@@ -99,6 +101,8 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
99101
\end{verbatim}
100102

101103
also works, and at least \program{WinZip} can read such files.
104+
If \var{mode} is \code{a} and the file does not exist at all,
105+
it is created.
102106
\var{compression} is the ZIP compression method to use when writing
103107
the archive, and should be \constant{ZIP_STORED} or
104108
\constant{ZIP_DEFLATED}; unrecognized values will cause
@@ -112,6 +116,9 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
112116
ZIP file would require ZIP64 extensions. ZIP64 extensions are disabled by
113117
default because the default \program{zip} and \program{unzip} commands on
114118
\UNIX{} (the InfoZIP utilities) don't support these extensions.
119+
120+
\versionchanged[If the file does not exist, it is created if the
121+
mode is 'a']{2.6}
115122
\end{classdesc}
116123

117124
\begin{methoddesc}{close}{}
@@ -138,9 +145,18 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
138145
Print a table of contents for the archive to \code{sys.stdout}.
139146
\end{methoddesc}
140147

141-
\begin{methoddesc}{read}{name}
148+
\begin{methoddesc}{setpassword}{pwd}
149+
Set \var{pwd} as default password to extract encrypted files.
150+
\versionadded{2.6}
151+
\end{methoddesc}
152+
153+
\begin{methoddesc}{read}{name\optional{, pwd}}
142154
Return the bytes of the file in the archive. The archive must be
143-
open for read or append.
155+
open for read or append. \var{pwd} is the password used for encrypted
156+
files and, if specified, it will override the default password set with
157+
\method{setpassword()}.
158+
159+
\versionchanged[\var{pwd} was added]{2.6}
144160
\end{methoddesc}
145161

146162
\begin{methoddesc}{testzip}{}

Include/Python-ast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* File automatically generated by Parser/asdl_c.py */
1+
/* File automatically generated by Parser/asdl_c.py. */
22

33
#include "asdl.h"
44

Include/dictobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
100100
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
101101
PyAPI_FUNC(int) PyDict_Next(
102102
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
103+
PyAPI_FUNC(int) _PyDict_Next(
104+
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
103105
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
104106
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
105107
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
106108
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
107109
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
108110
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
111+
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);
109112

110113
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
111114
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);

0 commit comments

Comments
 (0)