Merge 3.5

This commit is contained in:
Yury Selivanov 2015-05-30 10:49:27 -04:00
commit 802d45b660
19 changed files with 1101 additions and 787 deletions

View File

@ -1,4 +1,4 @@
.. _tut-using:
3.6.. _tut-using:
****************************
Using the Python Interpreter
@ -10,13 +10,13 @@ Using the Python Interpreter
Invoking the Interpreter
========================
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.5`
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.6`
on those machines where it is available; putting :file:`/usr/local/bin` in your
Unix shell's search path makes it possible to start it by typing the command:
.. code-block:: text
python3.5
python3.6
to the shell. [#]_ Since the choice of the directory where the interpreter lives
is an installation option, other places are possible; check with your local
@ -24,11 +24,11 @@ Python guru or system administrator. (E.g., :file:`/usr/local/python` is a
popular alternative location.)
On Windows machines, the Python installation is usually placed in
:file:`C:\\Python35`, though you can change this when you're running the
:file:`C:\\Python36`, though you can change this when you're running the
installer. To add this directory to your path, you can type the following
command into the command prompt in a DOS box::
set path=%path%;C:\python35
set path=%path%;C:\python36
Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on
Windows) at the primary prompt causes the interpreter to exit with a zero exit
@ -96,8 +96,8 @@ with the *secondary prompt*, by default three dots (``...``). The interpreter
prints a welcome message stating its version number and a copyright notice
before printing the first prompt::
$ python3.5
Python 3.5 (default, Sep 16 2015, 09:25:04)
$ python3.6
Python 3.6 (default, Sep 16 2015, 09:25:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

View File

@ -15,7 +15,7 @@ operating system::
>>> import os
>>> os.getcwd() # Return the current working directory
'C:\\Python35'
'C:\\Python36'
>>> os.chdir('/server/accesslogs') # Change current working directory
>>> os.system('mkdir today') # Run the command mkdir in the system shell
0

View File

@ -277,7 +277,7 @@ applications include caching objects that are expensive to create::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
d['primary'] # entry was automatically removed
File "C:/python35/lib/weakref.py", line 46, in __getitem__
File "C:/python36/lib/weakref.py", line 46, in __getitem__
o = self.data[key]()
KeyError: 'primary'

166
Doc/whatsnew/3.6.rst Normal file
View File

@ -0,0 +1,166 @@
****************************
What's New In Python 3.6
****************************
:Release: |release|
:Date: |today|
.. Rules for maintenance:
* Anyone can add text to this document. Do not spend very much time
on the wording of your changes, because your text will probably
get rewritten to some degree.
* The maintainer will go through Misc/NEWS periodically and add
changes; it's therefore more important to add your changes to
Misc/NEWS than to this file.
* This is not a complete list of every single change; completeness
is the purpose of Misc/NEWS. Some changes I consider too small
or esoteric to include. If such a change is added to the text,
I'll just remove it. (This is another reason you shouldn't spend
too much time on writing your addition.)
* If you want to draw your new text to the attention of the
maintainer, add 'XXX' to the beginning of the paragraph or
section.
* It's OK to just add a fragmentary note about a change. For
example: "XXX Describe the transmogrify() function added to the
socket module." The maintainer will research the change and
write the necessary text.
* You can comment out your additions if you like, but it's not
necessary (especially when a final release is some months away).
* Credit the author of a patch or bugfix. Just the name is
sufficient; the e-mail address isn't necessary.
* It's helpful to add the bug/patch number as a comment:
XXX Describe the transmogrify() function added to the socket
module.
(Contributed by P.Y. Developer in :issue:`12345`.)
This saves the maintainer the effort of going through the Mercurial log
when researching a change.
This article explains the new features in Python 3.6, compared to 3.5.
For full details, see the :source:`Misc/NEWS` file.
.. note::
Prerelease users should be aware that this document is currently in draft
form. It will be updated substantially as Python 3.6 moves towards release,
so it's worth checking back even after reading earlier versions.
Summary -- Release highlights
=============================
.. This section singles out the most important changes in Python 3.6.
Brevity is key.
* None yet.
.. PEP-sized items next.
.. _pep-4XX:
.. PEP 4XX: Virtual Environments
.. =============================
.. (Implemented by Foo Bar.)
.. .. seealso::
:pep:`4XX` - Python Virtual Environments
PEP written by Carl Meyer
Other Language Changes
======================
* None yet.
New Modules
===========
* None yet.
Improved Modules
================
* None yet.
Optimizations
=============
* None yet.
Build and C API Changes
=======================
* None yet.
Deprecated
==========
New Keywords
------------
``async`` and ``await`` are not recommended to be used as variable, class or
function names. Introduced by :pep:`492` in Python 3.5, they will become
proper keywords in Python 3.7.
Deprecated Python modules, functions and methods
------------------------------------------------
* None yet.
Deprecated functions and types of the C API
-------------------------------------------
* None yet.
Deprecated features
-------------------
* None yet.
Removed
=======
API and Feature Removals
------------------------
* None yet.
Porting to Python 3.6
=====================
This section lists previously described changes and other bugfixes
that may require changes to your code.
Changes in the Python API
-------------------------
* None yet.
Changes in the C API
--------------------
* None yet.

View File

@ -11,6 +11,7 @@ anyone wishing to stay up-to-date after a new release.
.. toctree::
:maxdepth: 2
3.6.rst
3.5.rst
3.4.rst
3.3.rst

View File

@ -17,13 +17,13 @@
/* Version parsed out into numeric values */
/*--start constants--*/
#define PY_MAJOR_VERSION 3
#define PY_MINOR_VERSION 5
#define PY_MINOR_VERSION 6
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA
#define PY_RELEASE_SERIAL 1
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
#define PY_RELEASE_SERIAL 0
/* Version as a string */
#define PY_VERSION "3.5.0b1+"
#define PY_VERSION "3.6.0a0"
/*--end constants--*/
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

View File

@ -112,10 +112,7 @@ class Template(metaclass=_TemplateMetaclass):
# Check the most common path first.
named = mo.group('named') or mo.group('braced')
if named is not None:
val = mapping[named]
# We use this idiom instead of str() because the latter will
# fail if val is a Unicode containing non-ASCII characters.
return '%s' % (val,)
return str(mapping[named])
if mo.group('escaped') is not None:
return self.delimiter
if mo.group('invalid') is not None:
@ -142,9 +139,7 @@ class Template(metaclass=_TemplateMetaclass):
named = mo.group('named') or mo.group('braced')
if named is not None:
try:
# We use this idiom instead of str() because the latter
# will fail if val is a Unicode containing non-ASCII
return '%s' % (mapping[named],)
return str(mapping[named])
except KeyError:
return mo.group()
if mo.group('escaped') is not None:

View File

@ -1965,7 +1965,14 @@ class OrderedDictTests:
od = OrderedDict(**d)
self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
def test_views(self):
OrderedDict = self.module.OrderedDict
# See http://bugs.python.org/issue24286
s = 'the quick brown fox jumped over a lazy dog yesterday before dawn'.split()
od = OrderedDict.fromkeys(s)
self.assertEqual(od.keys(), dict(od).keys())
self.assertEqual(od.items(), dict(od).items())
def test_override_update(self):
OrderedDict = self.module.OrderedDict
# Verify that subclasses can override update() without breaking __init__()

View File

@ -1,3 +1,4 @@
import collections
import unittest
class DictSetTest(unittest.TestCase):
@ -197,6 +198,27 @@ class DictSetTest(unittest.TestCase):
d[42] = d.values()
self.assertRaises(RuntimeError, repr, d)
def test_abc_registry(self):
d = dict(a=1)
self.assertIsInstance(d.keys(), collections.KeysView)
self.assertIsInstance(d.keys(), collections.MappingView)
self.assertIsInstance(d.keys(), collections.Set)
self.assertIsInstance(d.keys(), collections.Sized)
self.assertIsInstance(d.keys(), collections.Iterable)
self.assertIsInstance(d.keys(), collections.Container)
self.assertIsInstance(d.values(), collections.ValuesView)
self.assertIsInstance(d.values(), collections.MappingView)
self.assertIsInstance(d.values(), collections.Sized)
self.assertIsInstance(d.items(), collections.ItemsView)
self.assertIsInstance(d.items(), collections.MappingView)
self.assertIsInstance(d.items(), collections.Set)
self.assertIsInstance(d.items(), collections.Sized)
self.assertIsInstance(d.items(), collections.Iterable)
self.assertIsInstance(d.items(), collections.Container)
if __name__ == "__main__":
unittest.main()

45
Lib/test/test_symbol.py Normal file
View File

@ -0,0 +1,45 @@
import unittest
from test import support
import filecmp
import os
import sys
import subprocess
SYMBOL_FILE = support.findfile('symbol.py')
GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
'..', '..', 'Include', 'graminit.h')
TEST_PY_FILE = 'symbol_test.py'
class TestSymbolGeneration(unittest.TestCase):
def _copy_file_without_generated_symbols(self, source_file, dest_file):
with open(source_file, 'rb') as fp:
lines = fp.readlines()
nl = lines[0][len(lines[0].rstrip()):]
with open(dest_file, 'wb') as fp:
fp.writelines(lines[:lines.index(b"#--start constants--" + nl) + 1])
fp.writelines(lines[lines.index(b"#--end constants--" + nl):])
def _generate_symbols(self, grammar_file, target_symbol_py_file):
proc = subprocess.Popen([sys.executable,
SYMBOL_FILE,
grammar_file,
target_symbol_py_file], stderr=subprocess.PIPE)
stderr = proc.communicate()[1]
return proc.returncode, stderr
@unittest.skipIf(not os.path.exists(GRAMMAR_FILE),
'test only works from source build directory')
def test_real_grammar_and_symbol_file(self):
self._copy_file_without_generated_symbols(SYMBOL_FILE, TEST_PY_FILE)
self.addCleanup(support.unlink, TEST_PY_FILE)
self.assertFalse(filecmp.cmp(SYMBOL_FILE, TEST_PY_FILE))
self.assertEqual((0, b''), self._generate_symbols(GRAMMAR_FILE,
TEST_PY_FILE))
self.assertTrue(filecmp.cmp(SYMBOL_FILE, TEST_PY_FILE))
if __name__ == "__main__":
unittest.main()

View File

@ -2,6 +2,18 @@
Python News
+++++++++++
What's New in Python 3.6.0 alpha 1?
===================================
Release date: XXXX-XX-XX
Core and Builtins
-----------------
Library
-------
What's New in Python 3.5.0 beta 2?
==================================
@ -43,6 +55,9 @@ Core and Builtins
- Issue #24268: PEP 489: Multi-phase extension module initialization.
Patch by Petr Viktorin.
- Issue #23359: Optimize set object internals by specializing the
hash table search into a lookup function and an insert function.
- Issue #23955: Add pyvenv.cfg option to suppress registry/environment
lookup for generating sys.path on Windows.

View File

@ -52,7 +52,6 @@ static setentry *
set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
{
setentry *table = so->table;
setentry *freeslot = NULL;
setentry *entry;
size_t perturb = hash;
size_t mask = so->mask;
@ -86,14 +85,12 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
return entry;
mask = so->mask; /* help avoid a register spill */
}
if (entry->hash == -1 && freeslot == NULL)
freeslot = entry;
if (i + LINEAR_PROBES <= mask) {
for (j = 0 ; j < LINEAR_PROBES ; j++) {
entry++;
if (entry->key == NULL)
goto found_null;
if (entry->hash == 0 && entry->key == NULL)
return entry;
if (entry->hash == hash) {
PyObject *startkey = entry->key;
assert(startkey != dummy);
@ -114,6 +111,89 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
return entry;
mask = so->mask;
}
}
}
perturb >>= PERTURB_SHIFT;
i = (i * 5 + 1 + perturb) & mask;
entry = &table[i];
if (entry->hash == 0 && entry->key == NULL)
return entry;
}
}
/*
Internal routine to insert a new key into the table.
Used by the public insert routine.
Eats a reference to key.
*/
static int
set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
{
setentry *table = so->table;
setentry *freeslot = NULL;
setentry *entry;
size_t perturb = hash;
size_t mask = so->mask;
size_t i = (size_t)hash & mask; /* Unsigned for defined overflow behavior */
size_t j;
int cmp;
entry = &table[i];
if (entry->key == NULL)
goto found_null;
while (1) {
if (entry->hash == hash) {
PyObject *startkey = entry->key;
/* startkey cannot be a dummy because the dummy hash field is -1 */
assert(startkey != dummy);
if (startkey == key)
goto found_active;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
&& unicode_eq(startkey, key))
goto found_active;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
Py_DECREF(startkey);
if (cmp < 0) /* unlikely */
return -1;
if (table != so->table || entry->key != startkey) /* unlikely */
return set_insert_key(so, key, hash);
if (cmp > 0) /* likely */
goto found_active;
mask = so->mask; /* help avoid a register spill */
}
if (entry->hash == -1 && freeslot == NULL)
freeslot = entry;
if (i + LINEAR_PROBES <= mask) {
for (j = 0 ; j < LINEAR_PROBES ; j++) {
entry++;
if (entry->hash == 0 && entry->key == NULL)
goto found_null;
if (entry->hash == hash) {
PyObject *startkey = entry->key;
assert(startkey != dummy);
if (startkey == key)
goto found_active;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
&& unicode_eq(startkey, key))
goto found_active;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
Py_DECREF(startkey);
if (cmp < 0)
return -1;
if (table != so->table || entry->key != startkey)
return set_insert_key(so, key, hash);
if (cmp > 0)
goto found_active;
mask = so->mask;
}
if (entry->hash == -1 && freeslot == NULL)
freeslot = entry;
}
@ -123,11 +203,26 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
i = (i * 5 + 1 + perturb) & mask;
entry = &table[i];
if (entry->key == NULL)
if (entry->hash == 0 && entry->key == NULL)
goto found_null;
}
found_null:
return freeslot == NULL ? entry : freeslot;
if (freeslot == NULL) {
/* UNUSED */
so->fill++;
} else {
/* DUMMY */
entry = freeslot;
}
so->used++;
entry->key = key;
entry->hash = hash;
return 0;
found_active:
Py_DECREF(key);
return 0;
}
/*
@ -172,38 +267,6 @@ set_insert_clean(PySetObject *so, PyObject *key, Py_hash_t hash)
/* ======== End logic for probing the hash table ========================== */
/* ======================================================================== */
/*
Internal routine to insert a new key into the table.
Used by the public insert routine.
Eats a reference to key.
*/
static int
set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
{
setentry *entry;
entry = set_lookkey(so, key, hash);
if (entry == NULL)
return -1;
if (entry->key == NULL) {
/* UNUSED */
entry->key = key;
entry->hash = hash;
so->fill++;
so->used++;
} else if (entry->key == dummy) {
/* DUMMY */
entry->key = key;
entry->hash = hash;
so->used++;
} else {
/* ACTIVE */
Py_DECREF(key);
}
return 0;
}
/*
Restructure the table by allocating a new table and reinserting all
keys again. When entries have been deleted, the new table may
@ -345,7 +408,7 @@ set_discard_entry(PySetObject *so, setentry *oldentry)
entry = set_lookkey(so, oldentry->key, oldentry->hash);
if (entry == NULL)
return -1;
if (entry->key == NULL || entry->key == dummy)
if (entry->key == NULL)
return DISCARD_NOTFOUND;
old_key = entry->key;
entry->key = dummy;
@ -623,7 +686,7 @@ set_contains_entry(PySetObject *so, setentry *entry)
if (lu_entry == NULL)
return -1;
key = lu_entry->key;
return key != NULL && key != dummy;
return key != NULL;
}
static int

View File

@ -39,7 +39,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/export:initexample"
AdditionalDependencies="odbc32.lib odbccp32.lib python35.lib"
AdditionalDependencies="odbc32.lib odbccp32.lib python36.lib"
OutputFile=".\Release/example.pyd"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -105,7 +105,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/export:initexample"
AdditionalDependencies="odbc32.lib odbccp32.lib python35_d.lib"
AdditionalDependencies="odbc32.lib odbccp32.lib python36_d.lib"
OutputFile=".\Debug/example_d.pyd"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

View File

@ -304,11 +304,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
their Makefile (other compilers are generally
taken care of by distutils.) */
# if defined(_DEBUG)
# pragma comment(lib,"python35_d.lib")
# pragma comment(lib,"python36_d.lib")
# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
# pragma comment(lib,"python35.lib")
# pragma comment(lib,"python36.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,10 @@ if not defined HOST_PYTHON (
if %1 EQU Debug (
shift
set HOST_PYTHON=python_d.exe
if not exist python35_d.dll exit 1
if not exist python36_d.dll exit 1
) ELSE (
set HOST_PYTHON=python.exe
if not exist python35.dll exit 1
if not exist python36.dll exit 1
)
)
%HOST_PYTHON% prepare_ssl.py %1

16
README
View File

@ -1,5 +1,5 @@
This is Python version 3.5.0 beta 1
===================================
This is Python version 3.6.0 alpha 1
====================================
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013, 2014, 2015 Python Software Foundation. All rights reserved.
@ -50,9 +50,9 @@ What's New
----------
We try to have a comprehensive overview of the changes in the "What's New in
Python 3.5" document, found at
Python 3.6" document, found at
http://docs.python.org/3.5/whatsnew/3.5.html
http://docs.python.org/3.6/whatsnew/3.6.html
For a more detailed change log, read Misc/NEWS (though this file, too, is
incomplete, and also doesn't list anything merged in from the 2.7 release under
@ -65,9 +65,9 @@ entitled "Installing multiple versions".
Documentation
-------------
Documentation for Python 3.5 is online, updated daily:
Documentation for Python 3.6 is online, updated daily:
http://docs.python.org/3.5/
http://docs.python.org/3.6/
It can also be downloaded in many formats for faster access. The documentation
is downloadable in HTML, PDF, and reStructuredText formats; the latter version
@ -92,7 +92,7 @@ backported versions of certain key Python 3.x features.
A source-to-source translation tool, "2to3", can take care of the mundane task
of converting large amounts of source code. It is not a complete solution but
is complemented by the deprecation warnings in 2.6. See
http://docs.python.org/3.5/library/2to3.html for more information.
http://docs.python.org/3.6/library/2to3.html for more information.
Testing
@ -130,7 +130,7 @@ same prefix you must decide which version (if any) is your "primary" version.
Install that version using "make install". Install all other versions using
"make altinstall".
For example, if you want to install Python 2.6, 2.7 and 3.5 with 2.7 being the
For example, if you want to install Python 2.6, 2.7 and 3.6 with 2.7 being the
primary version, you would execute "make install" in your 2.7 build directory
and "make altinstall" in the others.

20
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for python 3.5.
# Generated by GNU Autoconf 2.69 for python 3.6.
#
# Report bugs to <http://bugs.python.org/>.
#
@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='python'
PACKAGE_TARNAME='python'
PACKAGE_VERSION='3.5'
PACKAGE_STRING='python 3.5'
PACKAGE_VERSION='3.6'
PACKAGE_STRING='python 3.6'
PACKAGE_BUGREPORT='http://bugs.python.org/'
PACKAGE_URL=''
@ -1378,7 +1378,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures python 3.5 to adapt to many kinds of systems.
\`configure' configures python 3.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1443,7 +1443,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of python 3.5:";;
short | recursive ) echo "Configuration of python 3.6:";;
esac
cat <<\_ACEOF
@ -1597,7 +1597,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
python configure 3.5
python configure 3.6
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2436,7 +2436,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by python $as_me 3.5, which was
It was created by python $as_me 3.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -3009,7 +3009,7 @@ rm confdefs.h
mv confdefs.h.new confdefs.h
VERSION=3.5
VERSION=3.6
# Version number of Python's own shared library file.
@ -16540,7 +16540,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by python $as_me 3.5, which was
This file was extended by python $as_me 3.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -16602,7 +16602,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
python config.status 3.5
python config.status 3.6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -3,7 +3,7 @@ dnl * Please run autoreconf to test your changes! *
dnl ***********************************************
# Set VERSION so we only need to edit in one place (i.e., here)
m4_define(PYTHON_VERSION, 3.5)
m4_define(PYTHON_VERSION, 3.6)
AC_PREREQ(2.65)