From 7aa5341164794efc5367f63636cbe8327ca40393 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sat, 30 May 2015 10:57:56 -0400 Subject: Reverting my previous commit. Something went horribly wrong when I was doing `hg rebase`. --- Doc/tutorial/interpreter.rst | 14 +- Doc/tutorial/stdlib.rst | 2 +- Doc/tutorial/stdlib2.rst | 2 +- Doc/whatsnew/3.6.rst | 166 ----- Doc/whatsnew/index.rst | 1 - Include/patchlevel.h | 8 +- Lib/string.py | 9 +- Lib/test/test_collections.py | 7 - Lib/test/test_dictviews.py | 22 - Lib/test/test_symbol.py | 45 -- Misc/NEWS | 15 - Objects/setobject.c | 145 ++--- PC/example_nt/example.vcproj | 4 +- PC/pyconfig.h | 4 +- PC/python3.def | 1402 +++++++++++++++++++++--------------------- PCbuild/prepare_ssl.bat | 4 +- README | 16 +- configure | 20 +- configure.ac | 2 +- 19 files changed, 787 insertions(+), 1101 deletions(-) delete mode 100644 Doc/whatsnew/3.6.rst delete mode 100644 Lib/test/test_symbol.py diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst index db0be32..d5789a6 100644 --- a/Doc/tutorial/interpreter.rst +++ b/Doc/tutorial/interpreter.rst @@ -1,4 +1,4 @@ -3.6.. _tut-using: +.. _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.6` +The Python interpreter is usually installed as :file:`/usr/local/bin/python3.5` 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.6 + python3.5 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:\\Python36`, though you can change this when you're running the +:file:`C:\\Python35`, 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:\python36 + set path=%path%;C:\python35 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.6 - Python 3.6 (default, Sep 16 2015, 09:25:04) + $ python3.5 + Python 3.5 (default, Sep 16 2015, 09:25:04) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst index 405d799..598859d 100644 --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -15,7 +15,7 @@ operating system:: >>> import os >>> os.getcwd() # Return the current working directory - 'C:\\Python36' + 'C:\\Python35' >>> os.chdir('/server/accesslogs') # Change current working directory >>> os.system('mkdir today') # Run the command mkdir in the system shell 0 diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst index 71194b0..f7d2a0a 100644 --- a/Doc/tutorial/stdlib2.rst +++ b/Doc/tutorial/stdlib2.rst @@ -277,7 +277,7 @@ applications include caching objects that are expensive to create:: Traceback (most recent call last): File "", line 1, in d['primary'] # entry was automatically removed - File "C:/python36/lib/weakref.py", line 46, in __getitem__ + File "C:/python35/lib/weakref.py", line 46, in __getitem__ o = self.data[key]() KeyError: 'primary' diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst deleted file mode 100644 index 375d94e..0000000 --- a/Doc/whatsnew/3.6.rst +++ /dev/null @@ -1,166 +0,0 @@ -**************************** - 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. diff --git a/Doc/whatsnew/index.rst b/Doc/whatsnew/index.rst index 7c92524..edb5502 100644 --- a/Doc/whatsnew/index.rst +++ b/Doc/whatsnew/index.rst @@ -11,7 +11,6 @@ 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 diff --git a/Include/patchlevel.h b/Include/patchlevel.h index 246eba8..b5cac68 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -17,13 +17,13 @@ /* Version parsed out into numeric values */ /*--start constants--*/ #define PY_MAJOR_VERSION 3 -#define PY_MINOR_VERSION 6 +#define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 0 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 0 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA +#define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "3.6.0a0" +#define PY_VERSION "3.5.0b1+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Lib/string.py b/Lib/string.py index e7b692d..f3365c6 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -112,7 +112,10 @@ class Template(metaclass=_TemplateMetaclass): # Check the most common path first. named = mo.group('named') or mo.group('braced') if named is not None: - return str(mapping[named]) + 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,) if mo.group('escaped') is not None: return self.delimiter if mo.group('invalid') is not None: @@ -139,7 +142,9 @@ class Template(metaclass=_TemplateMetaclass): named = mo.group('named') or mo.group('braced') if named is not None: try: - return str(mapping[named]) + # We use this idiom instead of str() because the latter + # will fail if val is a Unicode containing non-ASCII + return '%s' % (mapping[named],) except KeyError: return mo.group() if mo.group('escaped') is not None: diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index c6db13e..3bb326a 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1965,14 +1965,7 @@ 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__() diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index d96832e..280353a 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,4 +1,3 @@ -import collections import unittest class DictSetTest(unittest.TestCase): @@ -198,27 +197,6 @@ 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() diff --git a/Lib/test/test_symbol.py b/Lib/test/test_symbol.py deleted file mode 100644 index 4475bbc..0000000 --- a/Lib/test/test_symbol.py +++ /dev/null @@ -1,45 +0,0 @@ -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() diff --git a/Misc/NEWS b/Misc/NEWS index 8ccdcba..d6ff9e4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,18 +2,6 @@ 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? ================================== @@ -55,9 +43,6 @@ 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. diff --git a/Objects/setobject.c b/Objects/setobject.c index 707ab95..d962c1e 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -52,6 +52,7 @@ 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; @@ -85,12 +86,14 @@ 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->hash == 0 && entry->key == NULL) - return entry; + if (entry->key == NULL) + goto found_null; if (entry->hash == hash) { PyObject *startkey = entry->key; assert(startkey != dummy); @@ -111,89 +114,6 @@ 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; } @@ -203,26 +123,11 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash) i = (i * 5 + 1 + perturb) & mask; entry = &table[i]; - if (entry->hash == 0 && entry->key == NULL) + if (entry->key == NULL) goto found_null; } - found_null: - 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; + return freeslot == NULL ? entry : freeslot; } /* @@ -267,6 +172,38 @@ 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 @@ -408,7 +345,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) + if (entry->key == NULL || entry->key == dummy) return DISCARD_NOTFOUND; old_key = entry->key; entry->key = dummy; @@ -686,7 +623,7 @@ set_contains_entry(PySetObject *so, setentry *entry) if (lu_entry == NULL) return -1; key = lu_entry->key; - return key != NULL; + return key != NULL && key != dummy; } static int diff --git a/PC/example_nt/example.vcproj b/PC/example_nt/example.vcproj index 958eb78..d82f76e 100644 --- a/PC/example_nt/example.vcproj +++ b/PC/example_nt/example.vcproj @@ -39,7 +39,7 @@ . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='python' PACKAGE_TARNAME='python' -PACKAGE_VERSION='3.6' -PACKAGE_STRING='python 3.6' +PACKAGE_VERSION='3.5' +PACKAGE_STRING='python 3.5' 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.6 to adapt to many kinds of systems. +\`configure' configures python 3.5 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.6:";; + short | recursive ) echo "Configuration of python 3.5:";; 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.6 +python configure 3.5 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.6, which was +It was created by python $as_me 3.5, 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.6 +VERSION=3.5 # 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.6, which was +This file was extended by python $as_me 3.5, 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.6 +python config.status 3.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 3e9d31a..4030e33 100644 --- a/configure.ac +++ b/configure.ac @@ -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.6) +m4_define(PYTHON_VERSION, 3.5) AC_PREREQ(2.65) -- cgit v0.12