Branch merge

This commit is contained in:
Éric Araujo 2011-07-28 23:08:11 +02:00
commit cf534817ad
25 changed files with 451 additions and 379 deletions

View file

@ -14,6 +14,7 @@ platform
pybuilddir.txt pybuilddir.txt
pyconfig.h pyconfig.h
libpython*.a libpython*.a
libpython*.so*
python.exe python.exe
python-gdb.py python-gdb.py
reflog.txt reflog.txt

1
.gitignore vendored
View file

@ -37,6 +37,7 @@ build/
config.log config.log
config.status config.status
libpython*.a libpython*.a
libpython*.so*
pybuilddir.txt pybuilddir.txt
pyconfig.h pyconfig.h
python python

View file

@ -39,14 +39,13 @@ Parser/pgen.stamp$
syntax: glob syntax: glob
libpython*.a libpython*.a
libpython*.so*
*.swp *.swp
*.o *.o
*.pyc *.pyc
*.pyo *.pyo
*.pyd *.pyd
*.cover *.cover
*.orig
*.rej
*~ *~
Lib/lib2to3/*.pickle Lib/lib2to3/*.pickle
Lib/test/data/* Lib/test/data/*

View file

@ -203,6 +203,7 @@ docs@python.org), and we'll be glad to correct the problem.
* Kalle Svensson * Kalle Svensson
* Jim Tittsler * Jim Tittsler
* David Turner * David Turner
* Sandro Tosi
* Ville Vainio * Ville Vainio
* Martijn Vries * Martijn Vries
* Charles G. Waldman * Charles G. Waldman

View file

@ -72,8 +72,8 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and
| | be built | :class:`distutils.core.Extension` | | | be built | :class:`distutils.core.Extension` |
+--------------------+--------------------------------+-------------------------------------------------------------+ +--------------------+--------------------------------+-------------------------------------------------------------+
| *classifiers* | A list of categories for the | The list of available | | *classifiers* | A list of categories for the | The list of available |
| | package | categorizations is at | | | package | categorizations is available on `PyPI |
| | | http://pypi.python.org/pypi?:action=list_classifiers. | | | | <http://pypi.python.org/pypi?:action=list_classifiers>`_. |
+--------------------+--------------------------------+-------------------------------------------------------------+ +--------------------+--------------------------------+-------------------------------------------------------------+
| *distclass* | the :class:`Distribution` | A subclass of | | *distclass* | the :class:`Distribution` | A subclass of |
| | class to use | :class:`distutils.core.Distribution` | | | class to use | :class:`distutils.core.Distribution` |

View file

@ -39,7 +39,7 @@ The Python standard library provides two different profilers:
2. :mod:`profile`, a pure Python module whose interface is imitated by 2. :mod:`profile`, a pure Python module whose interface is imitated by
:mod:`cProfile`. Adds significant overhead to profiled programs. If you're :mod:`cProfile`. Adds significant overhead to profiled programs. If you're
trying to extend the profiler in some way, the task might be easier with this trying to extend the profiler in some way, the task might be easier with this
module. Copyright © 1994, by InfoSeek Corporation. module.
The :mod:`profile` and :mod:`cProfile` modules export the same interface, so The :mod:`profile` and :mod:`cProfile` modules export the same interface, so
they are mostly interchangeable; :mod:`cProfile` has a much lower overhead but they are mostly interchangeable; :mod:`cProfile` has a much lower overhead but
@ -592,27 +592,3 @@ The resulting profiler will then call :func:`your_time_func`.
functions should be used with care and should be as fast as possible. For the functions should be used with care and should be as fast as possible. For the
best results with a custom timer, it might be necessary to hard-code it in the C best results with a custom timer, it might be necessary to hard-code it in the C
source of the internal :mod:`_lsprof` module. source of the internal :mod:`_lsprof` module.
Copyright and License Notices
=============================
Copyright © 1994, by InfoSeek Corporation, all rights reserved.
Permission to use, copy, modify, and distribute this Python software and its
associated documentation for any purpose (subject to the restriction in the
following sentence) without fee is hereby granted, provided that the above
copyright notice appears in all copies, and that both that copyright notice and
this permission notice appear in supporting documentation, and that the name of
InfoSeek not be used in advertising or publicity pertaining to distribution of
the software without specific, written prior permission. This permission is
explicitly restricted to the copying and modification of the software to remain
in Python, compiled Python, or other languages (such as C) wherein the modified
or derived code is exclusively imported into a Python module.
INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View file

@ -159,19 +159,25 @@ Directory and files operations
.. function:: move(src, dst) .. function:: move(src, dst)
Recursively move a file or directory to another location. Recursively move a file or directory (*src*) to another location (*dst*).
Uses :func:`os.rename` to perform the move. If it fails, for reasons such as If the destination is a directory or a symlink to a directory, then *src* is
when *src* and *dst* are on different filesystems or in case of windows where moved inside that directory.
rename is not supported when *dst* exists, fallback to copying *src* (with
:func:`copy2`) to the *dst* and then remove *src*. The destination directory must not already exist. If the destination already
exists but is not a directory, it may be overwritten depending on
:func:`os.rename` semantics.
If the destination is on the current filesystem, then :func:`os.rename` is
used. Otherwise, *src* is copied (using :func:`copy2`) to *dst* and then
removed.
.. exception:: Error .. exception:: Error
This exception collects exceptions that raised during a multi-file operation. For This exception collects exceptions that are raised during a multi-file
:func:`copytree`, the exception argument is a list of 3-tuples (*srcname*, operation. For :func:`copytree`, the exception argument is a list of 3-tuples
*dstname*, *exception*). (*srcname*, *dstname*, *exception*).
.. _shutil-example: .. _shutil-example:
@ -269,7 +275,7 @@ Archiving operations
.. function:: get_archive_formats() .. function:: get_archive_formats()
Returns a list of supported formats for archiving. Return a list of supported formats for archiving.
Each element of the returned sequence is a tuple ``(name, description)`` Each element of the returned sequence is a tuple ``(name, description)``
By default :mod:`shutil` provides these formats: By default :mod:`shutil` provides these formats:
@ -287,7 +293,7 @@ Archiving operations
.. function:: register_archive_format(name, function, [extra_args, [description]]) .. function:: register_archive_format(name, function, [extra_args, [description]])
Registers an archiver for the format *name*. *function* is a callable that Register an archiver for the format *name*. *function* is a callable that
will be used to invoke the archiver. will be used to invoke the archiver.
If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be

View file

@ -492,36 +492,6 @@ The :mod:`http.cookies` module contains the following notice::
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
Profiling
---------
The :mod:`profile` and :mod:`pstats` modules contain the following notice::
Copyright 1994, by InfoSeek Corporation, all rights reserved.
Written by James Roskind
Permission to use, copy, modify, and distribute this Python software
and its associated documentation for any purpose (subject to the
restriction in the following sentence) without fee is hereby granted,
provided that the above copyright notice appears in all copies, and
that both that copyright notice and this permission notice appear in
supporting documentation, and that the name of InfoSeek not be used in
advertising or publicity pertaining to distribution of the software
without specific, written prior permission. This permission is
explicitly restricted to the copying and modification of the software
to remain in Python, compiled Python, or other languages (such as C)
wherein the modified or derived code is exclusively imported into a
Python module.
INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Execution tracing Execution tracing
----------------- -----------------

View file

@ -5,7 +5,6 @@ c-api/sequence,,:i2,o[i1:i2]
c-api/sequence,,:i2,o[i1:i2] = v c-api/sequence,,:i2,o[i1:i2] = v
c-api/sequence,,:i2,del o[i1:i2] c-api/sequence,,:i2,del o[i1:i2]
c-api/unicode,,:end,str[start:end] c-api/unicode,,:end,str[start:end]
distutils/apiref,,:action,http://pypi.python.org/pypi?:action=list_classifiers
distutils/setupscript,,::, distutils/setupscript,,::,
extending/embedding,,:numargs,"if(!PyArg_ParseTuple(args, "":numargs""))" extending/embedding,,:numargs,"if(!PyArg_ParseTuple(args, "":numargs""))"
extending/extending,,:set,"if (PyArg_ParseTuple(args, ""O:set_callback"", &temp)) {" extending/extending,,:set,"if (PyArg_ParseTuple(args, ""O:set_callback"", &temp)) {"

1 c-api/arg :ref PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
5 c-api/sequence :i2 o[i1:i2] = v
6 c-api/sequence :i2 del o[i1:i2]
7 c-api/unicode :end str[start:end]
distutils/apiref :action http://pypi.python.org/pypi?:action=list_classifiers
8 distutils/setupscript ::
9 extending/embedding :numargs if(!PyArg_ParseTuple(args, ":numargs"))
10 extending/extending :set if (PyArg_ParseTuple(args, "O:set_callback", &temp)) {

View file

@ -232,7 +232,7 @@ class IOBinding:
# before being able to execute the code # before being able to execute the code
self.set_saved(False) self.set_saved(False)
self.text.mark_set("insert", "1.0") self.text.mark_set("insert", "1.0")
self.text.see("insert") self.text.yview("insert")
self.updaterecentfileslist(filename) self.updaterecentfileslist(filename)
return True return True

View file

@ -1,13 +1,9 @@
"""Class for printing reports on profiled python code.""" """Class for printing reports on profiled python code."""
# Class for printing reports on profiled python code. rev 1.0 4/1/94
#
# Written by James Roskind # Written by James Roskind
# Based on prior profile module by Sjoerd Mullender... # Based on prior profile module by Sjoerd Mullender...
# which was hacked somewhat by: Guido van Rossum # which was hacked somewhat by: Guido van Rossum
"""Class for profiling Python code."""
# Copyright Disney Enterprises, Inc. All Rights Reserved. # Copyright Disney Enterprises, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement # Licensed to PSF under a Contributor Agreement
# #

View file

@ -1219,6 +1219,14 @@ class Popen(object):
os.close(errread) os.close(errread)
os.close(errpipe_read) os.close(errpipe_read)
# When duping fds, if there arises a situation
# where one of the fds is either 0, 1 or 2, it
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
if errwrite == 0 or errwrite == 1:
errwrite = os.dup(errwrite)
# Dup fds for child # Dup fds for child
def _dup2(a, b): def _dup2(a, b):
# dup2() removes the CLOEXEC flag but # dup2() removes the CLOEXEC flag but

View file

@ -1234,7 +1234,7 @@ class CodecsModuleTest(unittest.TestCase):
def test_lookup_issue1813(self): def test_lookup_issue1813(self):
# Issue #1813: under Turkish locales, lookup of some codecs failed # Issue #1813: under Turkish locales, lookup of some codecs failed
# because 'I' is lowercased as "ı" (dotless i) # because 'I' is lowercased as "ı" (dotless i)
oldlocale = locale.getlocale(locale.LC_CTYPE) oldlocale = locale.setlocale(locale.LC_CTYPE)
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale) self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
try: try:
locale.setlocale(locale.LC_CTYPE, 'tr_TR') locale.setlocale(locale.LC_CTYPE, 'tr_TR')

View file

@ -393,16 +393,16 @@ class TestMiscellaneous(unittest.TestCase):
def test_getsetlocale_issue1813(self): def test_getsetlocale_issue1813(self):
# Issue #1813: setting and getting the locale under a Turkish locale # Issue #1813: setting and getting the locale under a Turkish locale
oldlocale = locale.getlocale() oldlocale = locale.setlocale(locale.LC_CTYPE)
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale) self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
try: try:
locale.setlocale(locale.LC_CTYPE, 'tr_TR') locale.setlocale(locale.LC_CTYPE, 'tr_TR')
except locale.Error: except locale.Error:
# Unsupported locale on this system # Unsupported locale on this system
self.skipTest('test needs Turkish locale') self.skipTest('test needs Turkish locale')
loc = locale.getlocale() loc = locale.getlocale(locale.LC_CTYPE)
locale.setlocale(locale.LC_CTYPE, loc) locale.setlocale(locale.LC_CTYPE, loc)
self.assertEqual(loc, locale.getlocale()) self.assertEqual(loc, locale.getlocale(locale.LC_CTYPE))
def test_main(): def test_main():

View file

@ -12,10 +12,12 @@ import os
import pwd import pwd
import shutil import shutil
import stat import stat
import tempfile
import unittest import unittest
import warnings import warnings
_DUMMY_SYMLINK = '%s/dummy-symlink' % os.getenv('TMPDIR', '/tmp') _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
support.TESTFN + '-dummy-symlink')
class PosixTester(unittest.TestCase): class PosixTester(unittest.TestCase):

View file

@ -1106,6 +1106,64 @@ class POSIXProcessTestCase(BaseTestCase):
for fd in temp_fds: for fd in temp_fds:
os.close(fd) os.close(fd)
def check_swap_fds(self, stdin_no, stdout_no, stderr_no):
# open up some temporary files
temps = [mkstemp() for i in range(3)]
temp_fds = [fd for fd, fname in temps]
try:
# unlink the files -- we won't need to reopen them
for fd, fname in temps:
os.unlink(fname)
# save a copy of the standard file descriptors
saved_fds = [os.dup(fd) for fd in range(3)]
try:
# duplicate the temp files over the standard fd's 0, 1, 2
for fd, temp_fd in enumerate(temp_fds):
os.dup2(temp_fd, fd)
# write some data to what will become stdin, and rewind
os.write(stdin_no, b"STDIN")
os.lseek(stdin_no, 0, 0)
# now use those files in the given order, so that subprocess
# has to rearrange them in the child
p = subprocess.Popen([sys.executable, "-c",
'import sys; got = sys.stdin.read();'
'sys.stdout.write("got %s"%got); sys.stderr.write("err")'],
stdin=stdin_no,
stdout=stdout_no,
stderr=stderr_no)
p.wait()
for fd in temp_fds:
os.lseek(fd, 0, 0)
out = os.read(stdout_no, 1024)
err = support.strip_python_stderr(os.read(stderr_no, 1024))
finally:
for std, saved in enumerate(saved_fds):
os.dup2(saved, std)
os.close(saved)
self.assertEqual(out, b"got STDIN")
self.assertEqual(err, b"err")
finally:
for fd in temp_fds:
os.close(fd)
# When duping fds, if there arises a situation where one of the fds is
# either 0, 1 or 2, it is possible that it is overwritten (#12607).
# This tests all combinations of this.
def test_swap_fds(self):
self.check_swap_fds(0, 1, 2)
self.check_swap_fds(0, 2, 1)
self.check_swap_fds(1, 0, 2)
self.check_swap_fds(1, 2, 0)
self.check_swap_fds(2, 0, 1)
self.check_swap_fds(2, 1, 0)
def test_surrogates_error_message(self): def test_surrogates_error_message(self):
def prepare(): def prepare():
raise ValueError("surrogate:\uDCff") raise ValueError("surrogate:\uDCff")

View file

@ -174,6 +174,22 @@ class OtherNetworkTests(unittest.TestCase):
opener.open(request) opener.open(request)
self.assertEqual(request.get_header('User-agent'),'Test-Agent') self.assertEqual(request.get_header('User-agent'),'Test-Agent')
def test_sites_no_connection_close(self):
# Some sites do not send Connection: close header.
# Verify that those work properly. (#issue12576)
try:
with urllib.request.urlopen('http://www.imdb.com') as res:
pass
except ValueError as e:
self.fail("urlopen failed for sites not sending Connection:close")
else:
self.assertTrue(res)
req = urllib.request.urlopen('http://www.imdb.com')
res = req.read()
self.assertTrue(res)
def _test_urls(self, urls, handlers, retry=True): def _test_urls(self, urls, handlers, retry=True):
import time import time
import logging import logging

View file

@ -1134,11 +1134,11 @@ class AbstractHTTPHandler(BaseHandler):
try: try:
h.request(req.get_method(), req.selector, req.data, headers) h.request(req.get_method(), req.selector, req.data, headers)
r = h.getresponse() # an HTTPResponse instance except socket.error as err: # timeout error
except socket.error as err:
raise URLError(err)
finally:
h.close() h.close()
raise URLError(err)
else:
r = h.getresponse()
r.url = req.get_full_url() r.url = req.get_full_url()
# This line replaces the .msg attribute of the HTTPResponse # This line replaces the .msg attribute of the HTTPResponse

View file

@ -41,6 +41,15 @@ Core and Builtins
Library Library
------- -------
- Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
given as a low fd, it gets overwritten.
- Issue #12590: IDLE editor window now always displays the first line
when opening a long file. With Tk 8.5, the first line was hidden.
- Issue #12576: Fix urlopen behavior on sites which do not send (or obfuscates)
Connection:close header.
- Issue #1813: Fix codec lookup under Turkish locales. - Issue #1813: Fix codec lookup under Turkish locales.
- Issue #12591: Improve support of "universal newlines" in the subprocess - Issue #12591: Improve support of "universal newlines" in the subprocess

View file

@ -69,6 +69,13 @@ static void child_exec(char *const exec_array[],
} }
POSIX_CALL(close(errpipe_read)); POSIX_CALL(close(errpipe_read));
/* When duping fds, if there arises a situation where one of the fds is
either 0, 1 or 2, it is possible that it is overwritten (#12607). */
if (c2pwrite == 0)
POSIX_CALL(c2pwrite = dup(c2pwrite));
if (errwrite == 0 || errwrite == 1)
POSIX_CALL(errwrite = dup(errwrite));
/* Dup fds for child. /* Dup fds for child.
dup2() removes the CLOEXEC flag but we must do it ourselves if dup2() dup2() removes the CLOEXEC flag but we must do it ourselves if dup2()
would be a no-op (issue #10806). */ would be a no-op (issue #10806). */

View file

@ -1102,7 +1102,7 @@ PyDoc_STRVAR(find__doc__,
"B.find(sub[, start[, end]]) -> int\n\ "B.find(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the lowest index in B where subsection sub is found,\n\ Return the lowest index in B where subsection sub is found,\n\
such that sub is contained within s[start,end]. Optional\n\ such that sub is contained within B[start,end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");
@ -1172,7 +1172,7 @@ PyDoc_STRVAR(rfind__doc__,
"B.rfind(sub[, start[, end]]) -> int\n\ "B.rfind(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the highest index in B where subsection sub is found,\n\ Return the highest index in B where subsection sub is found,\n\
such that sub is contained within s[start,end]. Optional\n\ such that sub is contained within B[start,end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");

View file

@ -1273,7 +1273,7 @@ PyDoc_STRVAR(find__doc__,
"B.find(sub[, start[, end]]) -> int\n\ "B.find(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the lowest index in B where substring sub is found,\n\ Return the lowest index in B where substring sub is found,\n\
such that sub is contained within s[start:end]. Optional\n\ such that sub is contained within B[start:end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");
@ -1312,7 +1312,7 @@ PyDoc_STRVAR(rfind__doc__,
"B.rfind(sub[, start[, end]]) -> int\n\ "B.rfind(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the highest index in B where substring sub is found,\n\ Return the highest index in B where substring sub is found,\n\
such that sub is contained within s[start:end]. Optional\n\ such that sub is contained within B[start:end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");

View file

@ -7587,7 +7587,7 @@ PyDoc_STRVAR(find__doc__,
"S.find(sub[, start[, end]]) -> int\n\ "S.find(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the lowest index in S where substring sub is found,\n\ Return the lowest index in S where substring sub is found,\n\
such that sub is contained within s[start:end]. Optional\n\ such that sub is contained within S[start:end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");
@ -8513,7 +8513,7 @@ PyDoc_STRVAR(rfind__doc__,
"S.rfind(sub[, start[, end]]) -> int\n\ "S.rfind(sub[, start[, end]]) -> int\n\
\n\ \n\
Return the highest index in S where substring sub is found,\n\ Return the highest index in S where substring sub is found,\n\
such that sub is contained within s[start:end]. Optional\n\ such that sub is contained within S[start:end]. Optional\n\
arguments start and end are interpreted as in slice notation.\n\ arguments start and end are interpreted as in slice notation.\n\
\n\ \n\
Return -1 on failure."); Return -1 on failure.");

599
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -833,7 +833,7 @@ AC_SUBST(HGVERSION)
AC_SUBST(HGTAG) AC_SUBST(HGTAG)
AC_SUBST(HGBRANCH) AC_SUBST(HGBRANCH)
if test -e $srcdir/.hg/00changelog.i if test -e $srcdir/.hg/dirstate
then then
AC_CHECK_PROG(HAS_HG, hg, found, not-found) AC_CHECK_PROG(HAS_HG, hg, found, not-found)
else else