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

Skip to content

Commit 292d351

Browse files
committed
Merged revisions 60481,60485,60489-60520,60523-60527,60530-60533,60535-60538,60540-60551 via svnmerge from
svn+ssh://[email protected]/python/trunk NOTE: I blocked the following revisions: svnmerge.py block -r 60521,60522,60528,60529,60534,60539 The new tests must be merged with lots of manual work. ........ r60493 | georg.brandl | 2008-02-01 12:59:08 +0100 (Fri, 01 Feb 2008) | 2 lines Update IPv6 RFC number. ........ r60497 | georg.brandl | 2008-02-01 16:50:15 +0100 (Fri, 01 Feb 2008) | 2 lines Add link checker builder, written for GHOP by Thomas Lamb. ........ r60500 | georg.brandl | 2008-02-01 19:08:09 +0100 (Fri, 01 Feb 2008) | 2 lines Rename batch file. ........ r60504 | christian.heimes | 2008-02-01 19:49:26 +0100 (Fri, 01 Feb 2008) | 1 line More int -> pid_t. ........ r60507 | georg.brandl | 2008-02-01 20:24:01 +0100 (Fri, 01 Feb 2008) | 2 lines Wording nit. ........ r60510 | georg.brandl | 2008-02-01 21:45:33 +0100 (Fri, 01 Feb 2008) | 2 lines Update for latest sphinx latex writer. ........ r60511 | raymond.hettinger | 2008-02-01 22:30:23 +0100 (Fri, 01 Feb 2008) | 1 line Issue #1996: float.as_integer_ratio() should return fraction in lowest terms. ........ r60512 | raymond.hettinger | 2008-02-01 23:15:52 +0100 (Fri, 01 Feb 2008) | 1 line Integer ratio should return ints instead of longs whereever possible. ........ r60513 | raymond.hettinger | 2008-02-01 23:22:50 +0100 (Fri, 01 Feb 2008) | 1 line labs() takes a long for an input. ........ r60514 | raymond.hettinger | 2008-02-01 23:42:59 +0100 (Fri, 01 Feb 2008) | 1 line Test round-trip on float.as_integer_ratio() and float.__truediv__(). ........ r60515 | marc-andre.lemburg | 2008-02-01 23:58:17 +0100 (Fri, 01 Feb 2008) | 3 lines Bump distutils version number to match Python version. ........ r60516 | raymond.hettinger | 2008-02-02 00:12:19 +0100 (Sat, 02 Feb 2008) | 1 line Fix int/long typecase. Add check for non-binary floating point. ........ r60517 | raymond.hettinger | 2008-02-02 00:45:44 +0100 (Sat, 02 Feb 2008) | 1 line Add protection from weirdness while scaling the mantissa to an integer. ........ r60518 | raymond.hettinger | 2008-02-02 06:11:40 +0100 (Sat, 02 Feb 2008) | 1 line Simpler solution to handling non-IEEE 754 environments. ........ r60519 | raymond.hettinger | 2008-02-02 06:24:44 +0100 (Sat, 02 Feb 2008) | 1 line Neaten-up a bit. ........ r60520 | georg.brandl | 2008-02-02 10:56:20 +0100 (Sat, 02 Feb 2008) | 2 lines Amendments to the urllib2 docs, written for GHOP by Thomas Lamb. ........ r60525 | georg.brandl | 2008-02-02 11:49:58 +0100 (Sat, 02 Feb 2008) | 3 lines Add email example how to send a multipart message. Written for GHOP by Martin Matejek. ........ r60526 | georg.brandl | 2008-02-02 12:05:00 +0100 (Sat, 02 Feb 2008) | 2 lines Rewrite test_socketserver as unittest, written for GHOP by Benjamin Petersen. ........ r60527 | georg.brandl | 2008-02-02 12:05:34 +0100 (Sat, 02 Feb 2008) | 2 lines Add GHOP contributor. ........ r60530 | mark.dickinson | 2008-02-02 18:16:13 +0100 (Sat, 02 Feb 2008) | 2 lines Make the Rational constructor accept '3.' and '.2' as well as '3.2'. ........ r60531 | neal.norwitz | 2008-02-02 19:52:51 +0100 (Sat, 02 Feb 2008) | 1 line Update the leaky tests (ie, ignore these tests if they report leaks). This version has been running for a while. ........ r60533 | skip.montanaro | 2008-02-02 20:11:57 +0100 (Sat, 02 Feb 2008) | 7 lines Split the refleak mail body into two parts, the first being those failing tests which are deemed more important issues, the second those which are known to have difficult to solve problems and are generally expected to leak. Hopefully this doesn't break the script... ........ r60535 | georg.brandl | 2008-02-03 01:04:50 +0100 (Sun, 03 Feb 2008) | 3 lines Wait for a delay before reaping children -- this should fix the test_socketserver failures on several platforms. ........ r60536 | brett.cannon | 2008-02-03 03:07:55 +0100 (Sun, 03 Feb 2008) | 2 lines Fix a minor typo. ........ r60537 | brett.cannon | 2008-02-03 03:08:45 +0100 (Sun, 03 Feb 2008) | 3 lines Directories from CPPFLAGS and LDFLAGS were being added in the reverse order for searches as to how they were listed in the environment variable. ........ r60538 | brett.cannon | 2008-02-03 03:34:14 +0100 (Sun, 03 Feb 2008) | 2 lines Remove extra tick marks and add a missing closing parenthesis. ........ r60540 | andrew.macintyre | 2008-02-03 07:58:06 +0100 (Sun, 03 Feb 2008) | 2 lines Update OS/2 EMX build bits for 2.6. ........ r60541 | andrew.macintyre | 2008-02-03 08:01:11 +0100 (Sun, 03 Feb 2008) | 2 lines Rename module definition file to reflect v2.6. ........ r60542 | andrew.macintyre | 2008-02-03 08:07:31 +0100 (Sun, 03 Feb 2008) | 6 lines The wrapper function is supposed to be for spawnvpe() so that's what we should call [this wrapper only available on OS/2]. Backport candidate to 2.5. ........ r60544 | gregory.p.smith | 2008-02-03 08:20:53 +0100 (Sun, 03 Feb 2008) | 6 lines Merge this fix from the pybsddb tree: r293 | jcea | 2008-01-31 01:08:19 -0800 (Thu, 31 Jan 2008) | 4 lines Solved memory leak when using cursors with databases without environment. ........ r60546 | gregory.p.smith | 2008-02-03 09:01:46 +0100 (Sun, 03 Feb 2008) | 2 lines remove a repeated occurance of a hardcoded berkeleydb library version number ........ r60549 | brett.cannon | 2008-02-03 10:59:21 +0100 (Sun, 03 Feb 2008) | 2 lines Add an entry for r60537. ........ r60550 | georg.brandl | 2008-02-03 13:29:00 +0100 (Sun, 03 Feb 2008) | 2 lines #2003: fix sentence. ........ r60551 | christian.heimes | 2008-02-03 15:34:18 +0100 (Sun, 03 Feb 2008) | 2 lines Fixed paths to Windows build directories in build_ext.py Use vsbuild instead of devenv in build.bat and _bsddb.vcproj ........
1 parent ec17d20 commit 292d351

31 files changed

+615
-431
lines changed

Doc/Makefile

+11-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
1616

1717
help:
1818
@echo "Please use \`make <target>' where <target> is one of"
19-
@echo " html to make standalone HTML files"
20-
@echo " web to make file usable by Sphinx.web"
21-
@echo " htmlhelp to make HTML files and a HTML help project"
22-
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
23-
@echo " changes to make an overview over all changed/added/deprecated items"
19+
@echo " html to make standalone HTML files"
20+
@echo " web to make file usable by Sphinx.web"
21+
@echo " htmlhelp to make HTML files and a HTML help project"
22+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
23+
@echo " changes to make an overview over all changed/added/deprecated items"
24+
@echo " linkcheck to check all external links for integrity"
2425

2526
checkout:
2627
@if [ ! -d tools/sphinx ]; then \
@@ -71,6 +72,11 @@ changes: BUILDER = changes
7172
changes: build
7273
@echo "The overview file is in build/changes."
7374

75+
linkcheck: BUILDER = linkcheck
76+
linkcheck: build
77+
@echo "Link check complete; look for any errors in the above output "\
78+
"or in build/$(BUILDER)/output.txt"
79+
7480
clean:
7581
-rm -rf build/*
7682
-rm -rf tools/sphinx

Doc/README.txt

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ Available make targets are:
5555

5656
* "latex", which builds LaTeX source files that can be run with "pdflatex"
5757
to produce PDF documents.
58+
59+
* "linkcheck", which checks all external references to see whether they are
60+
broken, redirected or malformed, and outputs this information to stdout
61+
as well as a plain-text (.txt) file.
5862

5963
* "changes", which builds an overview over all versionadded/versionchanged/
6064
deprecated items in the current version. This is meant as a help for the

Doc/conf.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,29 @@
103103
# (source start file, target name, title, author, document class [howto/manual]).
104104
_stdauthor = r'Guido van Rossum\\Fred L. Drake, Jr., editor'
105105
latex_documents = [
106-
('c-api/index.rst', 'c-api.tex',
106+
('c-api/index', 'c-api.tex',
107107
'The Python/C API', _stdauthor, 'manual'),
108-
('distutils/index.rst', 'distutils.tex',
108+
('distutils/index', 'distutils.tex',
109109
'Distributing Python Modules', _stdauthor, 'manual'),
110-
('documenting/index.rst', 'documenting.tex',
110+
('documenting/index', 'documenting.tex',
111111
'Documenting Python', 'Georg Brandl', 'manual'),
112-
('extending/index.rst', 'extending.tex',
112+
('extending/index', 'extending.tex',
113113
'Extending and Embedding Python', _stdauthor, 'manual'),
114-
('install/index.rst', 'install.tex',
114+
('install/index', 'install.tex',
115115
'Installing Python Modules', _stdauthor, 'manual'),
116-
('library/index.rst', 'library.tex',
116+
('library/index', 'library.tex',
117117
'The Python Library Reference', _stdauthor, 'manual'),
118-
('reference/index.rst', 'reference.tex',
118+
('reference/index', 'reference.tex',
119119
'The Python Language Reference', _stdauthor, 'manual'),
120-
('tutorial/index.rst', 'tutorial.tex',
120+
('tutorial/index', 'tutorial.tex',
121121
'Python Tutorial', _stdauthor, 'manual'),
122-
('using/index.rst', 'using.tex',
122+
('using/index', 'using.tex',
123123
'Using Python', _stdauthor, 'manual'),
124-
('whatsnew/' + version + '.rst', 'whatsnew.tex',
124+
('whatsnew/' + version, 'whatsnew.tex',
125125
'What\'s New in Python', 'A. M. Kuchling', 'howto'),
126126
]
127127
# Collect all HOWTOs individually
128-
latex_documents.extend(('howto/' + fn, 'howto-' + fn[:-4] + '.tex',
128+
latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex',
129129
'HOWTO', _stdauthor, 'howto')
130130
for fn in os.listdir('howto')
131131
if fn.endswith('.rst') and fn != 'index.rst')
@@ -139,4 +139,4 @@
139139
'''
140140

141141
# Documents to append as an appendix to all manuals.
142-
latex_appendices = ['glossary.rst', 'about.rst', 'license.rst', 'copyright.rst']
142+
latex_appendices = ['glossary', 'about', 'license', 'copyright']

Doc/includes/email-alternative.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#! /usr/bin/python
2+
3+
import smtplib
4+
5+
from email.mime.multipart import MIMEMultipart
6+
from email.mime.text import MIMEText
7+
8+
# me == my email address
9+
# you == recipient's email address
10+
11+
12+
13+
# Create message container - the correct MIME type is multipart/alternative.
14+
msg = MIMEMultipart('alternative')
15+
msg['Subject'] = "Link"
16+
msg['From'] = me
17+
msg['To'] = you
18+
19+
# Create the body of the message (a plain-text and an HTML version).
20+
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
21+
html = """\
22+
<html>
23+
<head></head>
24+
<body>
25+
<p>Hi!<br>
26+
How are you?<br>
27+
Here is the <a href="http://www.python.org">link</a> you wanted.
28+
</p>
29+
</body>
30+
</html>
31+
"""
32+
33+
# Record the MIME types of both parts - text/plain and text/html.
34+
part1 = MIMEText(text, 'plain')
35+
part2 = MIMEText(html, 'html')
36+
37+
# Attach parts into message container.
38+
# According to RFC 2046, the last part of a multipart message, in this case
39+
# the HTML message, is best and preferred.
40+
msg.attach(part1)
41+
msg.attach(part2)
42+
43+
# Send the message via local SMTP server.
44+
s = smtplib.SMTP('localhost')
45+
# sendmail function takes 3 arguments: sender's address, recipient's address
46+
# and message to send - here it is sent as one string.
47+
s.sendmail(me, you, msg.as_string())
48+
s.close()

Doc/library/email-examples.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ pictures that may be residing in a directory:
1616

1717

1818
Here's an example of how to send the entire contents of a directory as an email
19-
message: [1]_
19+
message: [1]_
2020

2121
.. literalinclude:: ../includes/email-dir.py
2222

2323

24-
And finally, here's an example of how to unpack a MIME message like the one
24+
Here's an example of how to unpack a MIME message like the one
2525
above, into a directory of files:
2626

2727
.. literalinclude:: ../includes/email-unpack.py
2828

29+
Here's an example of how to create an HTML message with an alternative plain
30+
text version: [2]_
31+
32+
.. literalinclude:: ../includes/email-alternative.py
33+
2934

3035
.. rubric:: Footnotes
3136

3237
.. [1] Thanks to Matthew Dixon Cowles for the original inspiration and examples.
33-
38+
.. [2] Contributed by Martin Matejek.

Doc/library/queue.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The :mod:`Queue` module defines the following classes and exceptions:
7171
Queue Objects
7272
-------------
7373

74-
Queue objects (:class:``Queue``, :class:``LifoQueue``, or :class:``PriorityQueue``
74+
Queue objects (:class:`Queue`, :class:`LifoQueue`, or :class:`PriorityQueue`)
7575
provide the public methods described below.
7676

7777

Doc/library/socket.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PS1:7 and PS1:8). The platform-specific reference material for the various
2323
socket-related system calls are also a valuable source of information on the
2424
details of socket semantics. For Unix, refer to the manual pages; for Windows,
2525
see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers may
26-
want to refer to :rfc:`2553` titled Basic Socket Interface Extensions for IPv6.
26+
want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6.
2727

2828
.. index:: object: socket
2929

Doc/library/urllib2.rst

+30-9
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ The :mod:`urllib2` module defines the following functions:
3333

3434
This function returns a file-like object with two additional methods:
3535

36-
* :meth:`geturl` --- return the URL of the resource retrieved
36+
* :meth:`geturl` --- return the URL of the resource retrieved, commonly used to
37+
determine if a redirect was followed
3738

38-
* :meth:`info` --- return the meta-information of the page, as a dictionary-like
39-
object
39+
* :meth:`info` --- return the meta-information of the page, such as headers, in
40+
the form of an ``httplib.HTTPMessage`` instance
41+
(see `Quick Reference to HTTP Headers <http://www.cs.tut.fi/~jkorpela/http.html>`_)
4042

4143
Raises :exc:`URLError` on errors.
4244

@@ -81,18 +83,32 @@ The following exceptions are raised as appropriate:
8183
The handlers raise this exception (or derived exceptions) when they run into a
8284
problem. It is a subclass of :exc:`IOError`.
8385

86+
.. attribute:: reason
87+
88+
The reason for this error. It can be a message string or another exception
89+
instance (:exc:`socket.error` for remote URLs, :exc:`OSError` for local
90+
URLs).
91+
8492

8593
.. exception:: HTTPError
8694

87-
A subclass of :exc:`URLError`, it can also function as a non-exceptional
88-
file-like return value (the same thing that :func:`urlopen` returns). This
89-
is useful when handling exotic HTTP errors, such as requests for
90-
authentication.
95+
Though being an exception (a subclass of :exc:`URLError`), an :exc:`HTTPError`
96+
can also function as a non-exceptional file-like return value (the same thing
97+
that :func:`urlopen` returns). This is useful when handling exotic HTTP
98+
errors, such as requests for authentication.
99+
100+
.. attribute:: code
101+
102+
An HTTP status code as defined in `RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html>`_.
103+
This numeric value corresponds to a value found in the dictionary of
104+
codes as found in :attr:`BaseHTTPServer.BaseHTTPRequestHandler.responses`.
105+
106+
91107

92108
The following classes are provided:
93109

94110

95-
.. class:: Request(url[, data][, headers] [, origin_req_host][, unverifiable])
111+
.. class:: Request(url[, data][, headers][, origin_req_host][, unverifiable])
96112

97113
This class is an abstraction of a URL request.
98114

@@ -107,7 +123,12 @@ The following classes are provided:
107123
returns a string in this format.
108124

109125
*headers* should be a dictionary, and will be treated as if :meth:`add_header`
110-
was called with each key and value as arguments.
126+
was called with each key and value as arguments. This is often used to "spoof"
127+
the ``User-Agent`` header, which is used by a browser to identify itself --
128+
some HTTP servers only allow requests coming from common browsers as opposed
129+
to scripts. For example, Mozilla Firefox may identify itself as ``"Mozilla/5.0
130+
(X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"``, while :mod:`urllib2`'s
131+
default user agent string is ``"Python-urllib/2.6"`` (on Python 2.6).
111132

112133
The final two arguments are only of interest for correct handling of third-party
113134
HTTP cookies:
File renamed without changes.

Doc/reference/datamodel.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ that all old-style instances, independently of their class, are implemented with
991991
a single built-in type, called ``instance``.
992992

993993
New-style classes were introduced in Python 2.2 to unify classes and types. A
994-
new-style class neither more nor less than a user-defined type. If *x* is an
994+
new-style class is neither more nor less than a user-defined type. If *x* is an
995995
instance of a new-style class, then ``type(x)`` is the same as ``x.__class__``.
996996

997997
The major motivation for introducing new-style classes is to provide a unified

Lib/distutils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# In general, major and minor version should loosely follow the Python
1919
# version number the distutils code was shipped with.
2020
#
21-
__version__ = "2.5.1"
21+
__version__ = "2.6.0"

Lib/distutils/command/build_ext.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ def finalize_options(self):
178178
self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
179179
if MSVC_VERSION == 9:
180180
self.library_dirs.append(os.path.join(sys.exec_prefix,
181-
'PCBuild9'))
181+
'PCbuild'))
182182
elif MSVC_VERSION == 8:
183183
self.library_dirs.append(os.path.join(sys.exec_prefix,
184-
'PCBuild8', 'win32release'))
184+
'PC', 'VS8.0', 'win32release'))
185185
else:
186186
self.library_dirs.append(os.path.join(sys.exec_prefix,
187-
'PCBuild'))
187+
'PC', 'VS7.1'))
188188

189189
# OS/2 (EMX) doesn't support Debug vs Release builds, but has the
190190
# import libraries in its "Config" subdirectory

Lib/rational.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ def gcd(a, b):
2424
return a
2525

2626

27-
_RATIONAL_FORMAT = re.compile(
28-
r'^\s*(?P<sign>[-+]?)(?P<num>\d+)'
29-
r'(?:/(?P<denom>\d+)|\.(?P<decimal>\d+))?\s*$')
27+
_RATIONAL_FORMAT = re.compile(r"""
28+
\A\s* # optional whitespace at the start, then
29+
(?P<sign>[-+]?) # an optional sign, then
30+
(?=\d|\.\d) # lookahead for digit or .digit
31+
(?P<num>\d*) # numerator (possibly empty)
32+
(?: # followed by an optional
33+
/(?P<denom>\d+) # / and denominator
34+
| # or
35+
\.(?P<decimal>\d*) # decimal point and fractional part
36+
)?
37+
\s*\Z # and optional whitespace to finish
38+
""", re.VERBOSE)
3039

3140

3241
class Rational(RationalAbc):

Lib/test/test_builtin.py

+14
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,20 @@ def empty_format_spec(value):
593593
self.assertEqual(format(0, C('10')), ' 0')
594594

595595
def test_floatasratio(self):
596+
for f, ratio in [
597+
(0.875, (7, 8)),
598+
(-0.875, (-7, 8)),
599+
(0.0, (0, 1)),
600+
(11.5, (23, 2)),
601+
]:
602+
self.assertEqual(f.as_integer_ratio(), ratio)
603+
604+
for i in range(10000):
605+
f = random.random()
606+
f *= 10 ** random.randint(-100, 100)
607+
n, d = f.as_integer_ratio()
608+
self.assertEqual(float(n).__truediv__(d), f)
609+
596610
R = rational.Rational
597611
self.assertEqual(R(0, 1),
598612
R(*float(0.0).as_integer_ratio()))

Lib/test/test_rational.py

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def testFromString(self):
7777
self.assertEquals((3, 2), _components(R(" 03/02 \n ")))
7878
self.assertEquals((16, 5), _components(R(" 3.2 ")))
7979
self.assertEquals((-16, 5), _components(R(" -3.2 ")))
80+
self.assertEquals((-3, 1), _components(R(" -3. ")))
81+
self.assertEquals((3, 5), _components(R(" .6 ")))
8082

8183
self.assertRaisesMessage(
8284
ZeroDivisionError, "Rational(3, 0)",
@@ -111,6 +113,10 @@ def testFromString(self):
111113
# Don't accept combinations of decimals and rationals.
112114
ValueError, "Invalid literal for Rational: 3.2/7",
113115
R, "3.2/7")
116+
self.assertRaisesMessage(
117+
# Allow 3. and .3, but not .
118+
ValueError, "Invalid literal for Rational: .",
119+
R, ".")
114120

115121
def testImmutable(self):
116122
r = R(7, 3)

0 commit comments

Comments
 (0)