Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5a755e

Browse files
committed
Merged revisions 56301-56442 via svnmerge from
svn+ssh://[email protected]/python/branches/p3yk ................ r56322 | kurt.kaiser | 2007-07-12 11:35:03 -0700 (Thu, 12 Jul 2007) | 2 lines Replace obscure code which was failing in py3k. ................ r56323 | kurt.kaiser | 2007-07-12 11:44:12 -0700 (Thu, 12 Jul 2007) | 3 lines 1. Remove new division option 2. Update IDLE version to 3.0x ................ r56327 | kurt.kaiser | 2007-07-12 12:20:20 -0700 (Thu, 12 Jul 2007) | 5 lines Fix another instance of this defect in Tkinter, and one in IDLE. Patch 1724999 by Ali Gholami Rudi -- avoid complaints about dict size change during iter in destroy call. ................ r56339 | georg.brandl | 2007-07-13 03:07:25 -0700 (Fri, 13 Jul 2007) | 2 lines Fix #1753310: regrtest -x doesn't work anymore ................ r56361 | kurt.kaiser | 2007-07-13 18:25:24 -0700 (Fri, 13 Jul 2007) | 2 lines convert a map() iterator to a list to get this working. ................ r56362 | kurt.kaiser | 2007-07-13 18:53:45 -0700 (Fri, 13 Jul 2007) | 2 lines Was modifying dict during iteration. ................ r56376 | collin.winter | 2007-07-14 11:56:19 -0700 (Sat, 14 Jul 2007) | 1 line Add an example of class decorators to test_grammar. ................ r56377 | collin.winter | 2007-07-14 12:00:17 -0700 (Sat, 14 Jul 2007) | 1 line Add a basic example of dictcomps to test_grammar. ................ r56413 | neal.norwitz | 2007-07-17 00:21:18 -0700 (Tue, 17 Jul 2007) | 149 lines Merged revisions 56202-56412 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r56204 | ronald.oussoren | 2007-07-08 23:02:21 -0700 (Sun, 08 Jul 2007) | 2 lines Patch 1693258: Fix for duplicate "preferences" menu-OS X ........ r56207 | ronald.oussoren | 2007-07-09 01:41:15 -0700 (Mon, 09 Jul 2007) | 4 lines Patch 1673122: be explicit about which libtool to use, to avoid name clashes when a users install GNU libtool early in his PATH ........ r56280 | georg.brandl | 2007-07-11 12:41:49 -0700 (Wed, 11 Jul 2007) | 2 lines Fix #1752132: wrong comment in opcode description. ........ r56293 | georg.brandl | 2007-07-12 01:05:45 -0700 (Thu, 12 Jul 2007) | 3 lines Patch #1752270, #1750931: complain if urllib2 add_handler called without handler. ........ r56296 | georg.brandl | 2007-07-12 01:11:29 -0700 (Thu, 12 Jul 2007) | 2 lines Patch #1739696: use code.co_code only if really necessary ........ r56298 | georg.brandl | 2007-07-12 01:38:00 -0700 (Thu, 12 Jul 2007) | 3 lines Patch #1673759: add a missing overflow check when formatting floats with %G. ........ r56302 | georg.brandl | 2007-07-12 02:06:41 -0700 (Thu, 12 Jul 2007) | 2 lines Patch #1731659: improve time.strptime docs. ........ r56304 | georg.brandl | 2007-07-12 02:24:04 -0700 (Thu, 12 Jul 2007) | 2 lines Patch #1731169: clean up expected skips list. ........ r56306 | georg.brandl | 2007-07-12 02:37:49 -0700 (Thu, 12 Jul 2007) | 3 lines Bug #1637365: add subsection about "__name__ == __main__" to the Python tutorial. ........ r56308 | georg.brandl | 2007-07-12 02:59:22 -0700 (Thu, 12 Jul 2007) | 5 lines Patch #1675424: Added tests for uncovered code in the zipfile module. The KeyError raised by Zipfile.getinfo for nonexistent names now has a descriptive message. ........ r56340 | facundo.batista | 2007-07-13 03:43:44 -0700 (Fri, 13 Jul 2007) | 6 lines Added tests for basic behavior of DateTime, Binary, and Fault classes and the escape function. Check that marshalling recursive sequences & dicts raises TypeError. Check that marshalling out-of-range ints raises OverflowError [Alan McIntyre - GSoC] ........ r56345 | raymond.hettinger | 2007-07-13 05:09:41 -0700 (Fri, 13 Jul 2007) | 1 line Correct the docs for takewhile(). Improve the recipe for nth(). Should be backported ........ r56348 | thomas.heller | 2007-07-13 06:59:39 -0700 (Fri, 13 Jul 2007) | 4 lines Repair COMError. Since exceptions are new style classes now, setting the methods and docstring after the type creation does not work, they must be in the dictionary before creating the type. ........ r56349 | thomas.heller | 2007-07-13 07:18:06 -0700 (Fri, 13 Jul 2007) | 1 line Add tests for _ctypes.COMError. ........ r56350 | thomas.heller | 2007-07-13 09:50:43 -0700 (Fri, 13 Jul 2007) | 4 lines Do not try to load the GLUT library in the ctypes tests. This test adds little value, but has a large problem on OS X, as explained in SF# 1581906. ........ r56352 | thomas.heller | 2007-07-13 10:12:23 -0700 (Fri, 13 Jul 2007) | 3 lines Fix for SF# 1701409: segfault in c_char_p of ctypes. The repr output of c_char_p and c_wchar_p has changed as a sideeffect. ........ r56355 | thomas.heller | 2007-07-13 10:46:54 -0700 (Fri, 13 Jul 2007) | 3 lines Fix for SF# 1649098: avoid zero-sized array declaration in structure. ........ r56357 | thomas.heller | 2007-07-13 12:51:55 -0700 (Fri, 13 Jul 2007) | 3 lines PyType_stgdict() returns a borrowed reference which must not be Py_DECREF'd. ........ r56360 | barry.warsaw | 2007-07-13 15:12:58 -0700 (Fri, 13 Jul 2007) | 10 lines In response to this SF bug: [ 1752723 ] email.message_from_string: initial line gets discarded I added a test to assert that when the first line of text passed to message_from_string() contains a leading space, the message ends up with the appropriate FirstHeaderLineIsContinuationDefect on its defects list. The bug is invalid. ........ r56364 | georg.brandl | 2007-07-14 10:12:23 -0700 (Sat, 14 Jul 2007) | 2 lines Bug #1753406: missing \versionadded for subprocess.check_call. ........ r56366 | georg.brandl | 2007-07-14 10:32:41 -0700 (Sat, 14 Jul 2007) | 2 lines Clarify webbrowser.open description. ........ r56380 | andrew.kuchling | 2007-07-14 13:58:21 -0700 (Sat, 14 Jul 2007) | 1 line Typo fix ........ r56382 | andrew.kuchling | 2007-07-14 14:56:19 -0700 (Sat, 14 Jul 2007) | 7 lines Avoid exception if there's a stray directory inside a Maildir folder. The Maildir specification doesn't seem to say anything about this situation, and it can happen if you're keeping a Maildir mailbox in Subversion (.svn directories) or some similar system. The patch just ignores directories in the cur/, new/, tmp/ folders. ........ r56392 | facundo.batista | 2007-07-14 15:41:45 -0700 (Sat, 14 Jul 2007) | 6 lines First version. Includes tests for helper functions: read, write, _exception, readwrite, closeall, compact_traceback; and for classes dispatcher, dispatcher_with_send, and file_wrapper. [Alan McIntyre - GSoC] ........ r56399 | facundo.batista | 2007-07-15 13:30:39 -0700 (Sun, 15 Jul 2007) | 5 lines Changed the used port and commented out some tests that uses a non documented function that appers to uses resources not present in Windows. ........ r56412 | facundo.batista | 2007-07-16 19:19:39 -0700 (Mon, 16 Jul 2007) | 6 lines Prevent asyncore.dispatcher tests from hanging by adding loop counters to server & client, and by adding asyncore.close_all calls in tearDown. Also choose correct expected logging results based on the value of __debug__ [Alan McIntyre - GSoC] ........ ................ r56442 | guido.van.rossum | 2007-07-18 10:26:38 -0700 (Wed, 18 Jul 2007) | 14 lines Merged revisions 56413-56441 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r56439 | georg.brandl | 2007-07-17 23:37:55 -0700 (Tue, 17 Jul 2007) | 2 lines Use "Unix" as platform name, not "UNIX". ........ r56441 | guido.van.rossum | 2007-07-18 10:19:14 -0700 (Wed, 18 Jul 2007) | 3 lines SF patch# 1755885 by Kurt Kaiser: show location of Unicode escape errors. (Slightly tweaked for style and refcounts.) ........ ................
1 parent 5ed317d commit b5a755e

42 files changed

Lines changed: 994 additions & 248 deletions

Some content is hidden

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

Doc/lib/email.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ \subsection{Package History\label{email-pkg-history}}
9494
This table describes the release history of the email package, corresponding
9595
to the version of Python that the package was released with. For purposes of
9696
this document, when you see a note about change or added versions, these refer
97-
to the Python version the change was made it, \emph{not} the email package
97+
to the Python version the change was made in, \emph{not} the email package
9898
version. This table also describes the Python compatibility of each version
9999
of the package.
100100

Doc/lib/libitertools.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ \subsection{Itertool functions \label{itertools-functions}}
117117
Make an iterator that drops elements from the iterable as long as
118118
the predicate is true; afterwards, returns every element. Note,
119119
the iterator does not produce \emph{any} output until the predicate
120-
is true, so it may have a lengthy start-up time. Equivalent to:
120+
first becomes false, so it may have a lengthy start-up time. Equivalent to:
121121

122122
\begin{verbatim}
123123
def dropwhile(predicate, iterable):
@@ -509,8 +509,8 @@ \subsection{Recipes \label{itertools-recipes}}
509509
return izip(mapping.iterkeys(), mapping.itervalues())
510510
511511
def nth(iterable, n):
512-
"Returns the nth item or raise IndexError"
513-
return list(islice(iterable, n, n+1))[0]
512+
"Returns the nth item or raise StopIteration"
513+
return islice(iterable, n, None).next()
514514
515515
def all(seq, pred=None):
516516
"Returns True if pred(x) is true for every element in the iterable"

Doc/lib/libnis.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ \section{\module{nis} ---
22
Interface to Sun's NIS (Yellow Pages)}
33

44
\declaremodule{extension}{nis}
5-
\platform{UNIX}
5+
\platform{Unix}
66
\moduleauthor{Fred Gansevles}{[email protected]}
77
\sectionauthor{Moshe Zadka}{[email protected]}
88
\modulesynopsis{Interface to Sun's NIS (Yellow Pages) library.}

Doc/lib/libsubprocess.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ \subsubsection{Convenience Functions}
145145
\begin{verbatim}
146146
check_call(["ls", "-l"])
147147
\end{verbatim}
148+
149+
\versionadded{2.5}
148150
\end{funcdesc}
149151

150152
\subsubsection{Exceptions}

Doc/lib/libtime.tex

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,23 @@ \section{\module{time} ---
309309
\begin{funcdesc}{strptime}{string\optional{, format}}
310310
Parse a string representing a time according to a format. The return
311311
value is a \class{struct_time} as returned by \function{gmtime()} or
312-
\function{localtime()}. The \var{format} parameter uses the same
313-
directives as those used by \function{strftime()}; it defaults to
314-
\code{"\%a \%b \%d \%H:\%M:\%S \%Y"} which matches the formatting
315-
returned by \function{ctime()}. If \var{string} cannot be parsed
316-
according to \var{format}, \exception{ValueError} is raised. If the
317-
string to be parsed has excess data after parsing,
318-
\exception{ValueError} is raised. The default values used to fill in
319-
any missing data when more accurate values cannot be inferred are
320-
\code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} .
312+
\function{localtime()}.
313+
314+
The \var{format} parameter uses the same directives as those used by
315+
\function{strftime()}; it defaults to \code{"\%a \%b \%d \%H:\%M:\%S
316+
\%Y"} which matches the formatting returned by \function{ctime()}.
317+
If \var{string} cannot be parsed according to \var{format}, or if it
318+
has excess data after parsing, \exception{ValueError} is raised. The
319+
default values used to fill in any missing data when more accurate
320+
values cannot be inferred are \code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)}.
321+
322+
For example:
323+
324+
\begin{verbatim}
325+
>>> import time
326+
>>> time.strptime("30 Nov 00", "%d %b %y")
327+
(2000, 11, 30, 0, 0, 0, 3, 335, -1)
328+
\end{verbatim}
321329

322330
Support for the \code{\%Z} directive is based on the values contained in
323331
\code{tzname} and whether \code{daylight} is true. Because of this,

Doc/lib/libwebbrowser.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ \section{\module{webbrowser} ---
4747

4848
\begin{funcdesc}{open}{url\optional{, new=0\optional{, autoraise=1}}}
4949
Display \var{url} using the default browser. If \var{new} is 0, the
50-
\var{url} is opened in the same browser window. If \var{new} is 1,
50+
\var{url} is opened in the same browser window if possible. If \var{new} is 1,
5151
a new browser window is opened if possible. If \var{new} is 2,
5252
a new browser page ("tab") is opened if possible. If \var{autoraise} is
5353
true, the window is raised if possible (note that under many window

Doc/lib/libzipfile.tex

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ \section{\module{zipfile} ---
2424

2525
The available attributes of this module are:
2626

27-
\begin{excdesc}{error}
28-
The error raised for bad ZIP files.
27+
\begin{excdesc}{BadZipfile}
28+
The error raised for bad ZIP files (old name: \code{zipfile.error}).
2929
\end{excdesc}
3030

3131
\begin{excdesc}{LargeZipFile}
@@ -90,7 +90,7 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
9090
(a string) or a file-like object. The \var{mode} parameter
9191
should be \code{'r'} to read an existing file, \code{'w'} to
9292
truncate and write a new file, or \code{'a'} to append to an
93-
existing file. For \var{mode} is \code{'a'} and \var{file}
93+
existing file. If \var{mode} is \code{'a'} and \var{file}
9494
refers to an existing ZIP file, then additional files are added to
9595
it. If \var{file} does not refer to a ZIP file, then a new ZIP
9696
archive is appended to the file. This is meant for adding a ZIP
@@ -128,7 +128,8 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
128128

129129
\begin{methoddesc}{getinfo}{name}
130130
Return a \class{ZipInfo} object with information about the archive
131-
member \var{name}.
131+
member \var{name}. Calling \method{getinfo()} for a name not currently
132+
contained in the archive will raise a \exception{KeyError}.
132133
\end{methoddesc}
133134

134135
\begin{methoddesc}{infolist}{}
@@ -147,7 +148,9 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
147148
parameter, if included, must be one of the following: \code{'r'} (the
148149
default), \code{'U'}, or \code{'rU'}. Choosing \code{'U'} or
149150
\code{'rU'} will enable universal newline support in the read-only
150-
object. \var{pwd} is the password used for encrypted files.
151+
object. \var{pwd} is the password used for encrypted files. Calling
152+
\method{open()} on a closed ZipFile will raise a
153+
\exception{RuntimeError}.
151154
\begin{notice}
152155
The file-like object is read-only and provides the following methods:
153156
\method{read()}, \method{readline()}, \method{readlines()},
@@ -182,14 +185,17 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
182185
Return the bytes of the file in the archive. The archive must be
183186
open for read or append. \var{pwd} is the password used for encrypted
184187
files and, if specified, it will override the default password set with
185-
\method{setpassword()}.
188+
\method{setpassword()}. Calling \method{read()} on a closed ZipFile
189+
will raise a \exception{RuntimeError}.
186190

187191
\versionchanged[\var{pwd} was added]{2.6}
188192
\end{methoddesc}
189193

190194
\begin{methoddesc}{testzip}{}
191195
Read all the files in the archive and check their CRC's and file
192196
headers. Return the name of the first bad file, or else return \code{None}.
197+
Calling \method{testzip()} on a closed ZipFile will raise a
198+
\exception{RuntimeError}.
193199
\end{methoddesc}
194200

195201
\begin{methoddesc}{write}{filename\optional{, arcname\optional{,
@@ -200,7 +206,10 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
200206
separators removed). If given, \var{compress_type} overrides the
201207
value given for the \var{compression} parameter to the constructor
202208
for the new entry. The archive must be open with mode \code{'w'}
203-
or \code{'a'}.
209+
or \code{'a'} -- calling \method{write()} on a ZipFile created with
210+
mode \code{'r'} will raise a \exception{RuntimeError}. Calling
211+
\method{write()} on a closed ZipFile will raise a
212+
\exception{RuntimeError}.
204213

205214
\note{There is no official file name encoding for ZIP files.
206215
If you have unicode file names, please convert them to byte strings
@@ -210,6 +219,11 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
210219

211220
\note{Archive names should be relative to the archive root, that is,
212221
they should not start with a path separator.}
222+
223+
\note{If \code{arcname} (or \code{filename}, if \code{arcname} is
224+
not given) contains a null byte, the name of the file in the archive will
225+
be truncated at the null byte.}
226+
213227
\end{methoddesc}
214228

215229
\begin{methoddesc}{writestr}{zinfo_or_arcname, bytes}
@@ -218,7 +232,10 @@ \subsection{ZipFile Objects \label{zipfile-objects}}
218232
\class{ZipInfo} instance. If it's an instance, at least the
219233
filename, date, and time must be given. If it's a name, the date
220234
and time is set to the current date and time. The archive must be
221-
opened with mode \code{'w'} or \code{'a'}.
235+
opened with mode \code{'w'} or \code{'a'} -- calling
236+
\method{writestr()} on a ZipFile created with mode \code{'r'}
237+
will raise a \exception{RuntimeError}. Calling \method{writestr()}
238+
on a closed ZipFile will raise a \exception{RuntimeError}.
222239
\end{methoddesc}
223240

224241

@@ -243,12 +260,13 @@ \subsection{PyZipFile Objects \label{pyzipfile-objects}}
243260
available, else a \file{*.pyc} file, compiling if necessary. If the
244261
pathname is a file, the filename must end with \file{.py}, and just
245262
the (corresponding \file{*.py[co]}) file is added at the top level
246-
(no path information). If it is a directory, and the directory is
247-
not a package directory, then all the files \file{*.py[co]} are
248-
added at the top level. If the directory is a package directory,
249-
then all \file{*.py[oc]} are added under the package name as a file
250-
path, and if any subdirectories are package directories, all of
251-
these are added recursively. \var{basename} is intended for
263+
(no path information). If the pathname is a file that does not end with
264+
\file{.py}, a \exception{RuntimeError} will be raised. If it is a
265+
directory, and the directory is not a package directory, then all the
266+
files \file{*.py[co]} are added at the top level. If the directory is
267+
a package directory, then all \file{*.py[co]} are added under the package
268+
name as a file path, and if any subdirectories are package directories, all
269+
of these are added recursively. \var{basename} is intended for
252270
internal use only. The \method{writepy()} method makes archives
253271
with file names like this:
254272

Doc/tut/tut.tex

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,44 @@ \section{More on Modules \label{moreModules}}
24982498
This imports all names except those beginning with an underscore
24992499
(\code{_}).
25002500

2501+
\subsection{Executing modules as scripts \label{modulesAsScripts}}
2502+
2503+
When you run a Python module with
2504+
2505+
\begin{verbatim}
2506+
python fibo.py <arguments>
2507+
\end{verbatim}
2508+
2509+
the code in the module will be executed, just as if you imported it, but
2510+
with the \code{__name__} set to \code{"__main__"}. That means that by
2511+
adding this code at the end of your module:
2512+
2513+
\begin{verbatim}
2514+
if __name__ == "__main__":
2515+
import sys
2516+
fib(int(sys.argv[1]))
2517+
\end{verbatim}
2518+
2519+
you can make the file usable as a script as well as an importable module,
2520+
because the code that parses the command line only runs if the module is
2521+
executed as the ``main'' file:
2522+
2523+
\begin{verbatim}
2524+
$ python fibo.py 50
2525+
1 1 2 3 5 8 13 21 34
2526+
\end{verbatim}
2527+
2528+
If the module is imported, the code is not run:
2529+
2530+
\begin{verbatim}
2531+
>>> import fibo
2532+
>>>
2533+
\end{verbatim}
2534+
2535+
This is often used either to provide a convenient user interface to a
2536+
module, or for testing purposes (running the module as a script executes
2537+
a test suite).
2538+
25012539

25022540
\subsection{The Module Search Path \label{searchPath}}
25032541

Include/opcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extern "C" {
112112
#define LOAD_GLOBAL 116 /* Index in name list */
113113

114114
#define CONTINUE_LOOP 119 /* Start of loop (absolute) */
115-
#define SETUP_LOOP 120 /* Target address (absolute) */
115+
#define SETUP_LOOP 120 /* Target address (relative) */
116116
#define SETUP_EXCEPT 121 /* "" */
117117
#define SETUP_FINALLY 122 /* "" */
118118

Lib/ctypes/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ class c_char(_SimpleCData):
223223

224224
class c_char_p(_SimpleCData):
225225
_type_ = "z"
226+
if _os.name == "nt":
227+
def __repr__(self):
228+
if not windll.kernel32.IsBadStringPtrA(self, -1):
229+
return "%s(%r)" % (self.__class__.__name__, self.value)
230+
return "%s(%s)" % (self.__class__.__name__, cast(self, c_void_p).value)
231+
else:
232+
def __repr__(self):
233+
return "%s(%s)" % (self.__class__.__name__, cast(self, c_void_p).value)
226234
_check_size(c_char_p, "P")
227235

228236
class c_void_p(_SimpleCData):

0 commit comments

Comments
 (0)