diff -r ce070040e1a6 -r d7f128afe9db .hgignore --- a/.hgignore Sat May 10 13:24:58 2014 -0400 +++ b/.hgignore Sun Mar 23 09:44:28 2014 +0100 @@ -18,7 +18,6 @@ platform$ pyconfig.h$ python$ -python.bat$ python.exe$ python-config$ python-config.py$ diff -r ce070040e1a6 -r d7f128afe9db .hgtouch --- a/.hgtouch Sat May 10 13:24:58 2014 -0400 +++ b/.hgtouch Sun Mar 23 09:44:28 2014 +0100 @@ -4,8 +4,6 @@ Python/importlib.h: Lib/importlib/_bootstrap.py Modules/_freeze_importlib.c -Include/opcode.h: Lib/opcode.py Tools/scripts/generate_opcode_h.py - Include/Python-ast.h: Parser/Python.asdl Parser/asdl.py Parser/asdl_c.py Python/Python-ast.c: Include/Python-ast.h diff -r ce070040e1a6 -r d7f128afe9db Doc/Makefile --- a/Doc/Makefile Sat May 10 13:24:58 2014 -0400 +++ b/Doc/Makefile Sun Mar 23 09:44:28 2014 +0100 @@ -22,7 +22,6 @@ @echo "Please use \`make ' where is one of" @echo " clean to remove build files" @echo " html to make standalone HTML files" - @echo " htmlview to open the index page built by the html target in your browser" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " text to make plain text files" @@ -137,10 +136,16 @@ cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2 - # copy the epub build + # archive the epub build rm -rf build/epub make epub - cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub + mkdir -p dist/python-$(DISTVERSION)-docs-epub + cp -pPR build/epub/*.epub dist/python-$(DISTVERSION)-docs-epub/ + tar -C dist -cf dist/python-$(DISTVERSION)-docs-epub.tar python-$(DISTVERSION)-docs-epub + bzip2 -9 -k dist/python-$(DISTVERSION)-docs-epub.tar + (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-epub.zip python-$(DISTVERSION)-docs-epub) + rm -r dist/python-$(DISTVERSION)-docs-epub + rm dist/python-$(DISTVERSION)-docs-epub.tar check: $(PYTHON) tools/rstlint.py -i tools diff -r ce070040e1a6 -r d7f128afe9db Doc/README.txt --- a/Doc/README.txt Sat May 10 13:24:58 2014 -0400 +++ b/Doc/README.txt Sun Mar 23 09:44:28 2014 +0100 @@ -3,9 +3,9 @@ This directory contains the reStructuredText (reST) sources to the Python documentation. You don't need to build them yourself, prebuilt versions are -available at . +available at . -Documentation on authoring Python documentation, including information about +Documentation on the authoring Python documentation, including information about both style and markup, is available in the "Documenting Python" chapter of the developers guide . @@ -26,7 +26,8 @@ make html -to build the HTML output files. +to build the HTML output files. To view the generated HTML, point your favorite +browser at the top-level index `build/html/index.html` after running "make". On Windows, we try to emulate the Makefile as closely as possible with a ``make.bat`` file. @@ -34,29 +35,18 @@ To use a Python interpreter that's not called ``python``, use the standard way to set Makefile variables, using e.g. :: - make html PYTHON=python3 - -On Windows, set the PYTHON environment variable instead. - -To use a specific sphinx-build (something other than ``sphinx-build``), set -the SPHINXBUILD variable. + make html PYTHON=/usr/bin/python2.5 Available make targets are: - * "clean", which removes all build files. - * "html", which builds standalone HTML files for offline viewing. - * "htmlview", which re-uses the "html" builder, but then opens the main page - in your default web browser. - * "htmlhelp", which builds HTML files and a HTML Help project file usable to convert them into a single Compiled HTML (.chm) file -- these are popular under Microsoft Windows, but very handy on every platform. - To create the CHM file, you need to run the Microsoft HTML Help Workshop - over the generated project (.hhp) file. The make.bat script does this for - you on Windows. + To create the CHM file, you need to run the Microsoft HTML Help Workshop over + the generated project (.hhp) file. * "latex", which builds LaTeX source files as input to "pdflatex" to produce PDF documents. @@ -85,20 +75,13 @@ * "suspicious", which checks the parsed markup for text that looks like malformed and thus unconverted reST. - * "check", which checks for frequent markup errors. - - * "serve", which serves the build/html directory on port 8000. - - * "dist", (Unix only) which creates distributable archives of HTML, text, - PDF, and EPUB builds. - Without make ------------ Install the Sphinx package and its dependencies from PyPI. -Then, from the ``Doc`` directory, run :: +Then, from the ``Docs`` directory, run :: sphinx-build -b . build/ diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/exceptions.rst Sun Mar 23 09:44:28 2014 +0100 @@ -236,8 +236,8 @@ Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that if *filenameObject* is not *NULL*, it is passed to the constructor of *type* as - a third parameter. In the case of :exc:`OSError` exception, - this is used to define the :attr:`filename` attribute of the + a third parameter. In the case of exceptions such as :exc:`IOError` and + :exc:`OSError`, this is used to define the :attr:`filename` attribute of the exception instance. diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/import.rst --- a/Doc/c-api/import.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/import.rst Sun Mar 23 09:44:28 2014 +0100 @@ -245,9 +245,6 @@ .. versionadded:: 3.3 - .. versionchanged:: 3.4 - The ``__file__`` attribute is no longer set on the module. - .. c:function:: int PyImport_ImportFrozenModule(const char *name) diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/memory.rst --- a/Doc/c-api/memory.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/memory.rst Sun Mar 23 09:44:28 2014 +0100 @@ -92,8 +92,8 @@ need to be held. The default raw memory block allocator uses the following functions: -:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call -``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes. +:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when +requesting zero bytes. .. versionadded:: 3.4 @@ -106,17 +106,6 @@ been initialized in any way. -.. c:function:: void* PyMem_RawCalloc(size_t nelem, size_t elsize) - - Allocates *nelem* elements each whose size in bytes is *elsize* and returns - a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the - request fails. The memory is initialized to zeros. Requesting zero elements - or elements of size zero bytes returns a distinct non-*NULL* pointer if - possible, as if ``PyMem_RawCalloc(1, 1)`` had been called instead. - - .. versionadded:: 3.5 - - .. c:function:: void* PyMem_RawRealloc(void *p, size_t n) Resizes the memory block pointed to by *p* to *n* bytes. The contents will @@ -147,8 +136,8 @@ memory from the Python heap. The default memory block allocator uses the following functions: -:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call -``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes. +:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when +requesting zero bytes. .. warning:: @@ -163,17 +152,6 @@ been called instead. The memory will not have been initialized in any way. -.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize) - - Allocates *nelem* elements each whose size in bytes is *elsize* and returns - a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the - request fails. The memory is initialized to zeros. Requesting zero elements - or elements of size zero bytes returns a distinct non-*NULL* pointer if - possible, as if ``PyMem_Calloc(1, 1)`` had been called instead. - - .. versionadded:: 3.5 - - .. c:function:: void* PyMem_Realloc(void *p, size_t n) Resizes the memory block pointed to by *p* to *n* bytes. The contents will be @@ -244,17 +222,11 @@ +----------------------------------------------------------+---------------------------------------+ | ``void* malloc(void *ctx, size_t size)`` | allocate a memory block | +----------------------------------------------------------+---------------------------------------+ - | ``void* calloc(void *ctx, size_t nelem, size_t elsize)`` | allocate a memory block initialized | - | | with zeros | - +----------------------------------------------------------+---------------------------------------+ | ``void* realloc(void *ctx, void *ptr, size_t new_size)`` | allocate or resize a memory block | +----------------------------------------------------------+---------------------------------------+ | ``void free(void *ctx, void *ptr)`` | free a memory block | +----------------------------------------------------------+---------------------------------------+ - .. versionchanged:: 3.5 - Add a new field ``calloc``. - .. c:type:: PyMemAllocatorDomain Enum used to identify an allocator domain. Domains: diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/number.rst --- a/Doc/c-api/number.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/number.rst Sun Mar 23 09:44:28 2014 +0100 @@ -30,14 +30,6 @@ the equivalent of the Python expression ``o1 * o2``. -.. c:function:: PyObject* PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2) - - Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on - failure. This is the equivalent of the Python expression ``o1 @ o2``. - - .. versionadded:: 3.5 - - .. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2) Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is @@ -154,15 +146,6 @@ the Python statement ``o1 *= o2``. -.. c:function:: PyObject* PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2) - - Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on - failure. The operation is done *in-place* when *o1* supports it. This is - the equivalent of the Python statement ``o1 @= o2``. - - .. versionadded:: 3.5 - - .. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2) Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure. diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/sequence.rst --- a/Doc/c-api/sequence.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/sequence.rst Sun Mar 23 09:44:28 2014 +0100 @@ -123,10 +123,10 @@ .. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m) - Return the sequence *o* as a list, unless it is already a tuple or list, in - which case *o* is returned. Use :c:func:`PySequence_Fast_GET_ITEM` to access - the members of the result. Returns *NULL* on failure. If the object is not - a sequence, raises :exc:`TypeError` with *m* as the message text. + Returns the sequence *o* as a tuple, unless it is already a tuple or list, in + which case *o* is returned. Use :c:func:`PySequence_Fast_GET_ITEM` to access the + members of the result. Returns *NULL* on failure. If the object is not a + sequence, raises :exc:`TypeError` with *m* as the message text. .. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i) diff -r ce070040e1a6 -r d7f128afe9db Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/c-api/typeobj.rst Sun Mar 23 09:44:28 2014 +0100 @@ -464,24 +464,6 @@ :const:`Py_TPFLAGS_HAVE_VERSION_TAG`. - .. data:: Py_TPFLAGS_LONG_SUBCLASS - .. data:: Py_TPFLAGS_LIST_SUBCLASS - .. data:: Py_TPFLAGS_TUPLE_SUBCLASS - .. data:: Py_TPFLAGS_BYTES_SUBCLASS - .. data:: Py_TPFLAGS_UNICODE_SUBCLASS - .. data:: Py_TPFLAGS_DICT_SUBCLASS - .. data:: Py_TPFLAGS_BASE_EXC_SUBCLASS - .. data:: Py_TPFLAGS_TYPE_SUBCLASS - - These flags are used by functions such as - :c:func:`PyLong_Check` to quickly determine if a type is a subclass - of a built-in type; such specific checks are faster than a generic - check, like :c:func:`PyObject_IsInstance`. Custom types that inherit - from built-ins should have their :c:member:`~PyTypeObject.tp_flags` - set appropriately, or the code that interacts with such types - will behave differently depending on what kind of check is used. - - .. data:: Py_TPFLAGS_HAVE_FINALIZE This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is present in the @@ -1139,9 +1121,6 @@ binaryfunc nb_inplace_true_divide; unaryfunc nb_index; - - binaryfunc nb_matrix_multiply; - binaryfunc nb_inplace_matrix_multiply; } PyNumberMethods; .. note:: @@ -1220,8 +1199,7 @@ This function is used by :c:func:`PySequence_Repeat` and has the same signature. It is also used by the ``*`` operator, after trying numeric - multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_multiply` - slot. + multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_mul` slot. .. c:member:: ssizeargfunc PySequenceMethods.sq_item diff -r ce070040e1a6 -r d7f128afe9db Doc/faq/gui.rst --- a/Doc/faq/gui.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/faq/gui.rst Sun Mar 23 09:44:28 2014 +0100 @@ -32,14 +32,14 @@ `binary distributions `_ of Python) and use. For more info about Tk, including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the -Mac OS X, Windows, and Unix platforms. +MacOS, Windows, and Unix platforms. wxWidgets --------- wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a -number of platforms, with Windows, Mac OS X, GTK, X11, all listed as +number of platforms, with Windows, MacOS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number of languages including Python, Perl, Ruby, etc. @@ -102,9 +102,13 @@ What platform-specific GUI toolkits exist for Python? ======================================================== +`The Mac port `_ by Jack Jansen has a rich and +ever-growing set of modules that support the native Mac toolbox calls. The port +supports MacOS X's Carbon libraries. + By installing the `PyObjc Objective-C bridge -`_, Python programs can use Mac OS X's -Cocoa libraries. +`_, Python programs can use MacOS X's +Cocoa libraries. See the documentation that comes with the Mac port. :ref:`Pythonwin ` by Mark Hammond includes an interface to the Microsoft Foundation Classes and a Python programming environment diff -r ce070040e1a6 -r d7f128afe9db Doc/faq/programming.rst --- a/Doc/faq/programming.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/faq/programming.rst Sun Mar 23 09:44:28 2014 +0100 @@ -711,7 +711,7 @@ 144`` and ``int('0x144')`` raises :exc:`ValueError`. ``int(string, base)`` takes the base to convert from as a second optional argument, so ``int('0x144', 16) == 324``. If the base is specified as 0, the number is interpreted using Python's -rules: a leading '0o' indicates octal, and '0x' indicates a hex number. +rules: a leading '0' indicates octal, and '0x' indicates a hex number. Do not use the built-in function :func:`eval` if all you need is to convert strings to numbers. :func:`eval` will be significantly slower and it presents a @@ -732,7 +732,7 @@ constructor :func:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see the :ref:`string-formatting` section, e.g. ``"{:04d}".format(144)`` yields -``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. +``'0144'`` and ``"{:.3f}".format(1/3)`` yields ``'0.333'``. How do I modify a string in place? diff -r ce070040e1a6 -r d7f128afe9db Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/howto/logging-cookbook.rst Sun Mar 23 09:44:28 2014 +0100 @@ -416,7 +416,7 @@ Simple TCP socket-based logging receiver suitable for testing. """ - allow_reuse_address = True + allow_reuse_address = 1 def __init__(self, host='localhost', port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, diff -r ce070040e1a6 -r d7f128afe9db Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/howto/unicode.rst Sun Mar 23 09:44:28 2014 +0100 @@ -49,7 +49,7 @@ 255 characters aren't very many. For example, you can't fit both the accented characters used in Western Europe and the Cyrillic alphabet used for Russian -into the 128--255 range because there are more than 128 such characters. +into the 128--255 range because there are more than 127 such characters. You could write files using different codes (all your Russian files in a coding system called KOI8, all your French files in a different coding system called @@ -246,7 +246,7 @@ try: with open('/tmp/input.txt', 'r') as f: ... - except OSError: + except IOError: # 'File not found' error message. print("Fichier non trouvé") diff -r ce070040e1a6 -r d7f128afe9db Doc/library/__main__.rst --- a/Doc/library/__main__.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/__main__.rst Sun Mar 23 09:44:28 2014 +0100 @@ -5,19 +5,13 @@ .. module:: __main__ :synopsis: The environment where the top-level script is run. -``'__main__'`` is the name of the scope in which top-level code executes. -A module's __name__ is set equal to ``'__main__'`` when read from -standard input, a script, or from an interactive prompt. -A module can discover whether or not it is running in the main scope by -checking its own ``__name__``, which allows a common idiom for conditionally -executing code in a module when it is run as a script or with ``python --m`` but not when it is imported: +This module represents the (otherwise anonymous) scope in which the +interpreter's main program executes --- commands read either from standard +input, from a script file, or from an interactive prompt. It is this +environment in which the idiomatic "conditional script" stanza causes a script +to run:: if __name__ == "__main__": - # execute only if run as a script main() -For a package, the same effect can be achieved by including a -``__main__.py`` module, the contents of which will be executed when the -module is run with ``-m``. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/asyncio-protocol.rst --- a/Doc/library/asyncio-protocol.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/asyncio-protocol.rst Sun Mar 23 09:44:28 2014 +0100 @@ -9,7 +9,7 @@ Transports ========== -Transports are classes provided by :mod:`asyncio` in order to abstract +Transports are classed provided by :mod:`asyncio` in order to abstract various kinds of communication channels. You generally won't instantiate a transport yourself; instead, you will call a :class:`BaseEventLoop` method which will create the transport and try to initiate the underlying diff -r ce070040e1a6 -r d7f128afe9db Doc/library/asyncio-subprocess.rst --- a/Doc/library/asyncio-subprocess.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/asyncio-subprocess.rst Sun Mar 23 09:44:28 2014 +0100 @@ -8,7 +8,7 @@ On Windows, the default event loop uses :class:`selectors.SelectSelector` which only supports sockets. The :class:`ProactorEventLoop` should be used to -support subprocesses. However, the latter does not support SSL. +support subprocesses. On Mac OS X older than 10.9 (Mavericks), :class:`selectors.KqueueSelector` does not support character devices like PTY, whereas it is used by the diff -r ce070040e1a6 -r d7f128afe9db Doc/library/collections.rst --- a/Doc/library/collections.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/collections.rst Sun Mar 23 09:44:28 2014 +0100 @@ -978,9 +978,6 @@ keyword arguments, but their order is lost because Python's function call semantics pass-in keyword arguments using a regular unordered dictionary. -.. versionchanged:: 3.5 - The items, keys, and values :term:`views ` of :class:`OrderedDict` now - support reverse iteration using :func:`reversed`. :class:`OrderedDict` Examples and Recipes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -r ce070040e1a6 -r d7f128afe9db Doc/library/decimal.rst --- a/Doc/library/decimal.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/decimal.rst Sun Mar 23 09:44:28 2014 +0100 @@ -744,7 +744,7 @@ * ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number). * ``"sNaN"``, indicating that the operand is a signaling NaN. - .. method:: quantize(exp, rounding=None, context=None) + .. method:: quantize(exp, rounding=None, context=None, watchexp=True) Return a value equal to the first operand after rounding and having the exponent of the second operand. @@ -767,8 +767,14 @@ ``context`` argument; if neither argument is given the rounding mode of the current thread's context is used. - An error is returned whenever the resulting exponent is greater than - :attr:`Emax` or less than :attr:`Etiny`. + If *watchexp* is set (default), then an error is returned whenever the + resulting exponent is greater than :attr:`Emax` or less than + :attr:`Etiny`. + + .. deprecated:: 3.3 + *watchexp* is an implementation detail from the pure Python version + and is not present in the C version. It will be removed in version + 3.4, where it defaults to ``True``. .. method:: radix() diff -r ce070040e1a6 -r d7f128afe9db Doc/library/difflib.rst --- a/Doc/library/difflib.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/difflib.rst Sun Mar 23 09:44:28 2014 +0100 @@ -230,8 +230,8 @@ :file:`Tools/scripts/ndiff.py` is a command-line front-end to this function. - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), - ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), + ... 'ore\ntree\nemu\n'.splitlines(1)) >>> print(''.join(diff), end="") - one ? ^ @@ -254,8 +254,8 @@ Example: - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), - ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), + ... 'ore\ntree\nemu\n'.splitlines(1)) >>> diff = list(diff) # materialize the generated delta into a list >>> print(''.join(restore(diff, 1)), end="") one @@ -660,7 +660,7 @@ ... 2. Explicit is better than implicit. ... 3. Simple is better than complex. ... 4. Complex is better than complicated. - ... '''.splitlines(keepends=True) + ... '''.splitlines(1) >>> len(text1) 4 >>> text1[0][-1] @@ -669,7 +669,7 @@ ... 3. Simple is better than complex. ... 4. Complicated is better than complex. ... 5. Flat is better than nested. - ... '''.splitlines(keepends=True) + ... '''.splitlines(1) Next we instantiate a Differ object: diff -r ce070040e1a6 -r d7f128afe9db Doc/library/dis.rst --- a/Doc/library/dis.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/dis.rst Sun Mar 23 09:44:28 2014 +0100 @@ -364,11 +364,6 @@ Implements ``TOS = TOS1 * TOS``. -.. opcode:: BINARY_MATRIX_MULTIPLY - - Implements ``TOS = TOS1 @ TOS``. - - .. opcode:: BINARY_FLOOR_DIVIDE Implements ``TOS = TOS1 // TOS``. @@ -441,11 +436,6 @@ Implements in-place ``TOS = TOS1 * TOS``. -.. opcode:: INPLACE_MATRIX_MULTIPLY - - Implements in-place ``TOS = TOS1 @ TOS``. - - .. opcode:: INPLACE_FLOOR_DIVIDE Implements in-place ``TOS = TOS1 // TOS``. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/doctest.rst --- a/Doc/library/doctest.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/doctest.rst Sun Mar 23 09:44:28 2014 +0100 @@ -1058,9 +1058,15 @@ This function uses the same search technique as :func:`testmod`. - .. versionchanged:: 3.5 - :func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if *module* - contains no docstrings instead of raising :exc:`ValueError`. + .. note:: + Unlike :func:`testmod` and :class:`DocTestFinder`, this function raises + a :exc:`ValueError` if *module* contains no docstrings. You can prevent + this error by passing a :class:`DocTestFinder` instance as the + *test_finder* argument with its *exclude_empty* keyword argument set + to ``False``:: + + >>> finder = doctest.DocTestFinder(exclude_empty=False) + >>> suite = doctest.DocTestSuite(test_finder=finder) Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out diff -r ce070040e1a6 -r d7f128afe9db Doc/library/email.generator.rst --- a/Doc/library/email.generator.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/email.generator.rst Sun Mar 23 09:44:28 2014 +0100 @@ -112,7 +112,7 @@ :mod:`email.message`. .. class:: BytesGenerator(outfp, mangle_from_=True, maxheaderlen=78, *, \ - policy=None) + policy=policy.default) The constructor for the :class:`BytesGenerator` class takes a binary :term:`file-like object` called *outfp* for an argument. *outfp* must @@ -134,11 +134,9 @@ wrapping. The default is 78, as recommended (but not required) by :rfc:`2822`. - The *policy* keyword specifies a :mod:`~email.policy` object that controls a - number of aspects of the generator's operation. If no *policy* is specified, - then the *policy* attached to the message object passed to :attr:`flatten` - is used. + number of aspects of the generator's operation. The default policy + maintains backward compatibility. .. versionchanged:: 3.3 Added the *policy* keyword. @@ -176,7 +174,7 @@ Optional *linesep* specifies the line separator character used to terminate lines in the output. If specified it overrides the value - specified by the ``Generator``\ or *msg*\ 's ``policy``. + specified by the ``Generator``\ 's ``policy``. .. method:: clone(fp) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/email.message.rst --- a/Doc/library/email.message.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/email.message.rst Sun Mar 23 09:44:28 2014 +0100 @@ -34,7 +34,7 @@ .. class:: Message(policy=compat32) If *policy* is specified (it must be an instance of a :mod:`~email.policy` - class) use the rules it specifies to update and serialize the representation + class) use the rules it specifies to udpate and serialize the representation of the message. If *policy* is not set, use the :class:`compat32 ` policy, which maintains backward compatibility with the Python 3.2 version of the email package. For more information see the diff -r ce070040e1a6 -r d7f128afe9db Doc/library/email.parser.rst --- a/Doc/library/email.parser.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/email.parser.rst Sun Mar 23 09:44:28 2014 +0100 @@ -60,18 +60,15 @@ Here is the API for the :class:`FeedParser`: -.. class:: FeedParser(_factory=email.message.Message, *, policy=policy.compat32) +.. class:: FeedParser(_factory=email.message.Message, *, policy=policy.default) Create a :class:`FeedParser` instance. Optional *_factory* is a no-argument callable that will be called whenever a new message object is needed. It defaults to the :class:`email.message.Message` class. - If *policy* is specified (it must be an instance of a :mod:`~email.policy` - class) use the rules it specifies to update the representation of the - message. If *policy* is not set, use the :class:`compat32 - ` policy, which maintains backward compatibility with - the Python 3.2 version of the email package. For more information see the - :mod:`~email.policy` documentation. + The *policy* keyword specifies a :mod:`~email.policy` object that controls a + number of aspects of the parser's operation. The default policy maintains + backward compatibility. .. versionchanged:: 3.3 Added the *policy* keyword. @@ -116,7 +113,7 @@ The BytesHeaderParser class. -.. class:: Parser(_class=email.message.Message, *, policy=policy.compat32) +.. class:: Parser(_class=email.message.Message, *, policy=policy.default) The constructor for the :class:`Parser` class takes an optional argument *_class*. This must be a callable factory (such as a function or a class), and @@ -124,12 +121,9 @@ :class:`~email.message.Message` (see :mod:`email.message`). The factory will be called without arguments. - If *policy* is specified (it must be an instance of a :mod:`~email.policy` - class) use the rules it specifies to update the representation of the - message. If *policy* is not set, use the :class:`compat32 - ` policy, which maintains backward compatibility with - the Python 3.2 version of the email package. For more information see the - :mod:`~email.policy` documentation. + The *policy* keyword specifies a :mod:`~email.policy` object that controls a + number of aspects of the parser's operation. The default policy maintains + backward compatibility. .. versionchanged:: 3.3 Removed the *strict* argument that was deprecated in 2.4. Added the @@ -165,18 +159,15 @@ Optional *headersonly* is as with the :meth:`parse` method. -.. class:: BytesParser(_class=email.message.Message, *, policy=policy.compat32) +.. class:: BytesParser(_class=email.message.Message, *, policy=policy.default) This class is exactly parallel to :class:`Parser`, but handles bytes input. The *_class* and *strict* arguments are interpreted in the same way as for the :class:`Parser` constructor. - If *policy* is specified (it must be an instance of a :mod:`~email.policy` - class) use the rules it specifies to update the representation of the - message. If *policy* is not set, use the :class:`compat32 - ` policy, which maintains backward compatibility with - the Python 3.2 version of the email package. For more information see the - :mod:`~email.policy` documentation. + The *policy* keyword specifies a :mod:`~email.policy` object that + controls a number of aspects of the parser's operation. The default + policy maintains backward compatibility. .. versionchanged:: 3.3 Removed the *strict* argument. Added the *policy* keyword. @@ -218,7 +209,7 @@ .. currentmodule:: email .. function:: message_from_string(s, _class=email.message.Message, *, \ - policy=policy.compat32) + policy=policy.default) Return a message object structure from a string. This is exactly equivalent to ``Parser().parsestr(s)``. *_class* and *policy* are interpreted as @@ -228,7 +219,7 @@ Removed the *strict* argument. Added the *policy* keyword. .. function:: message_from_bytes(s, _class=email.message.Message, *, \ - policy=policy.compat32) + policy=policy.default) Return a message object structure from a byte string. This is exactly equivalent to ``BytesParser().parsebytes(s)``. Optional *_class* and @@ -240,7 +231,7 @@ Removed the *strict* argument. Added the *policy* keyword. .. function:: message_from_file(fp, _class=email.message.Message, *, \ - policy=policy.compat32) + policy=policy.default) Return a message object structure tree from an open :term:`file object`. This is exactly equivalent to ``Parser().parse(fp)``. *_class* @@ -251,7 +242,7 @@ Removed the *strict* argument. Added the *policy* keyword. .. function:: message_from_binary_file(fp, _class=email.message.Message, *, \ - policy=policy.compat32) + policy=policy.default) Return a message object structure tree from an open binary :term:`file object`. This is exactly equivalent to ``BytesParser().parse(fp)``. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/email.util.rst --- a/Doc/library/email.util.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/email.util.rst Sun Mar 23 09:44:28 2014 +0100 @@ -98,9 +98,12 @@ .. function:: mktime_tz(tuple) - Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC - timestamp (seconds since the Epoch). If the timezone item in the - tuple is ``None``, assume local time. + Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp. It + the timezone item in the tuple is ``None``, assume local time. Minor + deficiency: :func:`mktime_tz` interprets the first 8 elements of *tuple* as a + local time and then compensates for the timezone difference. This may yield a + slight error around changes in daylight savings time, though not worth worrying + about for common use. .. function:: formatdate(timeval=None, localtime=False, usegmt=False) @@ -207,3 +210,4 @@ .. [#] Note that the sign of the timezone offset is the opposite of the sign of the ``time.timezone`` variable for the same timezone; the latter variable follows the POSIX standard while this module follows :rfc:`2822`. + diff -r ce070040e1a6 -r d7f128afe9db Doc/library/exceptions.rst --- a/Doc/library/exceptions.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/exceptions.rst Sun Mar 23 09:44:28 2014 +0100 @@ -28,10 +28,10 @@ interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. -The built-in exception classes can be subclassed to define new exceptions; -programmers are encouraged to derive new exceptions from the :exc:`Exception` -class or one of its subclasses, and not from :exc:`BaseException`. More -information on defining exceptions is available in the Python Tutorial under +The built-in exception classes can be sub-classed to define new exceptions; +programmers are encouraged to at least derive new exceptions from the +:exc:`Exception` class and not :exc:`BaseException`. More information on +defining exceptions is available in the Python Tutorial under :ref:`tut-userexceptions`. When raising (or re-raising) an exception in an :keyword:`except` clause @@ -82,7 +82,7 @@ .. attribute:: args The tuple of arguments given to the exception constructor. Some built-in - exceptions (like :exc:`OSError`) expect a certain number of arguments and + exceptions (like :exc:`IOError`) expect a certain number of arguments and assign a special meaning to the elements of this tuple, while others are usually called only with a single string giving an error message. @@ -161,7 +161,7 @@ .. exception:: GeneratorExit - Raised when a :term:`generator`\'s :meth:`close` method is called. It + Raise when a :term:`generator`\'s :meth:`close` method is called. It directly inherits from :exc:`BaseException` instead of :exc:`Exception` since it is technically not an error. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/functions.rst --- a/Doc/library/functions.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/functions.rst Sun Mar 23 09:44:28 2014 +0100 @@ -773,7 +773,7 @@ already arranged into argument tuples, see :func:`itertools.starmap`\. -.. function:: max(iterable, *[, key, default]) +.. function:: max(iterable, *[, default, key]) max(arg1, arg2, *args[, key]) Return the largest item in an iterable or the largest of two or more @@ -781,7 +781,7 @@ If one positional argument is provided, it should be an :term:`iterable`. The largest item in the iterable is returned. If two or more positional - arguments are provided, the largest of the positional arguments is + arguments are provided, the smallest of the positional arguments is returned. There are two optional keyword-only arguments. The *key* argument specifies @@ -807,7 +807,7 @@ :ref:`typememoryview` for more information. -.. function:: min(iterable, *[, key, default]) +.. function:: min(iterable, *[, default, key]) min(arg1, arg2, *args[, key]) Return the smallest item in an iterable or the smallest of two or more diff -r ce070040e1a6 -r d7f128afe9db Doc/library/functools.rst --- a/Doc/library/functools.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/functools.rst Sun Mar 23 09:44:28 2014 +0100 @@ -218,8 +218,6 @@ Example:: >>> class Cell(object): - ... def __init__(self): - ... self._alive = False ... @property ... def alive(self): ... return self._alive diff -r ce070040e1a6 -r d7f128afe9db Doc/library/getpass.rst --- a/Doc/library/getpass.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/getpass.rst Sun Mar 23 09:44:28 2014 +0100 @@ -13,11 +13,10 @@ .. function:: getpass(prompt='Password: ', stream=None) Prompt the user for a password without echoing. The user is prompted using - the string *prompt*, which defaults to ``'Password: '``. On Unix, the - prompt is written to the file-like object *stream* using the replace error - handler if needed. *stream* defaults to the controlling terminal - (:file:`/dev/tty`) or if that is unavailable to ``sys.stderr`` (this - argument is ignored on Windows). + the string *prompt*, which defaults to ``'Password: '``. On Unix, the prompt + is written to the file-like object *stream*. *stream* defaults to the + controlling terminal (:file:`/dev/tty`) or if that is unavailable to + ``sys.stderr`` (this argument is ignored on Windows). If echo free input is unavailable getpass() falls back to printing a warning message to *stream* and reading from ``sys.stdin`` and diff -r ce070040e1a6 -r d7f128afe9db Doc/library/http.client.rst --- a/Doc/library/http.client.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/http.client.rst Sun Mar 23 09:44:28 2014 +0100 @@ -660,7 +660,7 @@ >>> # This creates an HTTP message >>> # with the content of BODY as the enclosed representation - >>> # for the resource http://localhost:8080/file + >>> # for the resource http://localhost:8080/foobar ... >>> import http.client >>> BODY = "***filecontents***" diff -r ce070040e1a6 -r d7f128afe9db Doc/library/http.server.rst --- a/Doc/library/http.server.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/http.server.rst Sun Mar 23 09:44:28 2014 +0100 @@ -81,10 +81,7 @@ Holds an instance of the class specified by the :attr:`MessageClass` class variable. This instance parses and manages the headers in the HTTP - request. The :func:`~http.client.parse_headers` function from - :mod:`http.client` is used to parse the headers and it requires that the - HTTP request provide a valid :rfc:`2822` style header. - + request. .. attribute:: rfile diff -r ce070040e1a6 -r d7f128afe9db Doc/library/imp.rst --- a/Doc/library/imp.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/imp.rst Sun Mar 23 09:44:28 2014 +0100 @@ -79,9 +79,7 @@ When *P* itself has a dotted name, apply this recipe recursively. .. deprecated:: 3.3 - Use :func:`importlib.util.find_spec` instead unless Python 3.3 - compatibility is required, in which case use - :func:`importlib.find_loader`. + Use :func:`importlib.find_loader` instead. .. function:: load_module(name, file, pathname, description) @@ -106,11 +104,9 @@ .. deprecated:: 3.3 If previously used in conjunction with :func:`imp.find_module` then - consider using :func:`importlib.import_module`, otherwise use the loader - returned by the replacement you chose for :func:`imp.find_module`. If you - called :func:`imp.load_module` and related functions directly then use the - classes in :mod:`importlib.machinery`, e.g. - ``importlib.machinery.SourceFileLoader(name, path).load_module()``. + call ``load_module()`` on the returned loader. If you wish to load a + module from a specific file, then use one of the file-based loaders found + in :mod:`importlib.machinery`. .. function:: new_module(name) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/importlib.rst --- a/Doc/library/importlib.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/importlib.rst Sun Mar 23 09:44:28 2014 +0100 @@ -449,12 +449,12 @@ Loaders that have a file-like storage back-end that allows storing arbitrary data can implement this abstract method to give direct access - to the data stored. :exc:`OSError` is to be raised if the *path* cannot + to the data stored. :exc:`IOError` is to be raised if the *path* cannot be found. The *path* is expected to be constructed using a module's :attr:`__file__` attribute or an item from a package's :attr:`__path__`. .. versionchanged:: 3.4 - Raises :exc:`OSError` instead of :exc:`NotImplementedError`. + Raises :exc:`IOError` instead of :exc:`NotImplementedError`. .. class:: InspectLoader @@ -499,7 +499,7 @@ .. versionchanged:: 3.4 Raises :exc:`ImportError` instead of :exc:`NotImplementedError`. - .. staticmethod:: source_to_code(data, path='') + .. method:: source_to_code(data, path='') Create a code object from Python source. @@ -508,14 +508,8 @@ the "path" to where the source code originated from, which can be an abstract concept (e.g. location in a zip file). - With the subsequent code object one can execute it in a module by - running ``exec(code, module.__dict__)``. - .. versionadded:: 3.4 - .. versionchanged:: 3.5 - Made the method static. - .. method:: exec_module(module) Implementation of :meth:`Loader.exec_module`. @@ -615,12 +609,12 @@ - ``'size'`` (optional): the size in bytes of the source code. Any other keys in the dictionary are ignored, to allow for future - extensions. If the path cannot be handled, :exc:`OSError` is raised. + extensions. If the path cannot be handled, :exc:`IOError` is raised. .. versionadded:: 3.3 .. versionchanged:: 3.4 - Raise :exc:`OSError` instead of :exc:`NotImplementedError`. + Raise :exc:`IOError` instead of :exc:`NotImplementedError`. .. method:: path_mtime(path) @@ -630,10 +624,10 @@ .. deprecated:: 3.3 This method is deprecated in favour of :meth:`path_stats`. You don't have to implement it, but it is still available for compatibility - purposes. Raise :exc:`OSError` if the path cannot be handled. + purposes. Raise :exc:`IOError` if the path cannot be handled. .. versionchanged:: 3.4 - Raise :exc:`OSError` instead of :exc:`NotImplementedError`. + Raise :exc:`IOError` instead of :exc:`NotImplementedError`. .. method:: set_data(path, data) @@ -893,11 +887,6 @@ Concrete implementation of :meth:`importlib.abc.SourceLoader.set_data`. - .. method:: load_module(name=None) - - Concrete implementation of :meth:`importlib.abc.Loader.load_module` where - specifying the name of the module to load is optional. - .. class:: SourcelessFileLoader(fullname, path) @@ -932,11 +921,6 @@ Returns ``None`` as bytecode files have no source when this loader is used. - .. method:: load_module(name=None) - - Concrete implementation of :meth:`importlib.abc.Loader.load_module` where - specifying the name of the module to load is optional. - .. class:: ExtensionFileLoader(fullname, path) @@ -956,7 +940,7 @@ Path to the extension module. - .. method:: load_module(name=None) + .. method:: load_module(fullname) Loads the extension module if and only if *fullname* is the same as :attr:`name` or is ``None``. @@ -1207,38 +1191,3 @@ module will be file-based. .. versionadded:: 3.4 - -.. class:: LazyLoader(loader) - - A class which postpones the execution of the loader of a module until the - module has an attribute accessed. - - This class **only** works with loaders that define - :meth:`importlib.abc.Loader.exec_module` as control over what module type - is used for the module is required. For the same reasons, the loader - **cannot** define :meth:`importlib.abc.Loader.create_module`. Finally, - modules which substitute the object placed into :attr:`sys.modules` will - not work as there is no way to properly replace the module references - throughout the interpreter safely; :exc:`ValueError` is raised if such a - substitution is detected. - - .. note:: - For projects where startup time is critical, this class allows for - potentially minimizing the cost of loading a module if it is never used. - For projects where startup time is not essential then use of this class is - **heavily** discouraged due to error messages created during loading being - postponed and thus occurring out of context. - - .. versionadded:: 3.5 - - .. classmethod:: factory(loader) - - A static method which returns a callable that creates a lazy loader. This - is meant to be used in situations where the loader is passed by class - instead of by instance. - :: - - suffixes = importlib.machinery.SOURCE_SUFFIXES - loader = importlib.machinery.SourceFileLoader - lazy_loader = importlib.util.LazyLoader.factory(loader) - finder = importlib.machinery.FileFinder(path, [(lazy_loader, suffixes)]) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/inspect.rst --- a/Doc/library/inspect.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/inspect.rst Sun Mar 23 09:44:28 2014 +0100 @@ -462,9 +462,6 @@ Signature objects are *immutable*. Use :meth:`Signature.replace` to make a modified copy. - .. versionchanged:: 3.5 - Signature objects are picklable and hashable. - .. attribute:: Signature.empty A special class-level marker to specify absence of a return annotation. @@ -509,29 +506,12 @@ >>> str(new_sig) "(a, b) -> 'new return anno'" - .. classmethod:: Signature.from_callable(obj) - - Return a :class:`Signature` (or its subclass) object for a given callable - ``obj``. This method simplifies subclassing of :class:`Signature`: - - :: - - class MySignature(Signature): - pass - sig = MySignature.from_callable(min) - assert isinstance(sig, MySignature) - - .. versionadded:: 3.5 - .. class:: Parameter(name, kind, \*, default=Parameter.empty, annotation=Parameter.empty) Parameter objects are *immutable*. Instead of modifying a Parameter object, you can use :meth:`Parameter.replace` to create a modified copy. - .. versionchanged:: 3.5 - Parameter objects are picklable and hashable. - .. attribute:: Parameter.empty A special class-level marker to specify absence of default values and diff -r ce070040e1a6 -r d7f128afe9db Doc/library/ipaddress.rst --- a/Doc/library/ipaddress.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/ipaddress.rst Sun Mar 23 09:44:28 2014 +0100 @@ -146,20 +146,6 @@ the appropriate length (most significant octet first). This is 4 bytes for IPv4 and 16 bytes for IPv6. - .. attribute:: reverse_pointer - - The name of the reverse DNS PTR record for the IP address, e.g.:: - - >>> ipaddress.ip_address("127.0.0.1").reverse_pointer - '1.0.0.127.in-addr.arpa' - >>> ipaddress.ip_address("2001:db8::1").reverse_pointer - '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa' - - This is the name that could be used for performing a PTR lookup, not the - resolved hostname itself. - - .. versionadded:: 3.5 - .. attribute:: is_multicast ``True`` if the address is reserved for multicast use. See @@ -240,7 +226,6 @@ :class:`IPv4Address` class: .. attribute:: packed - .. attribute:: reverse_pointer .. attribute:: version .. attribute:: max_prefixlen .. attribute:: is_multicast diff -r ce070040e1a6 -r d7f128afe9db Doc/library/itertools.rst --- a/Doc/library/itertools.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/itertools.rst Sun Mar 23 09:44:28 2014 +0100 @@ -87,15 +87,10 @@ .. function:: accumulate(iterable[, func]) - Make an iterator that returns accumulated sums, or accumulated - results of other binary functions (specified via the optional - *func* argument). If *func* is supplied, it should be a function - of two arguments. Elements of the input *iterable* may be any type - that can be accepted as arguments to *func*. (For example, with - the default operation of addition, elements may be any addable - type including :class:`~decimal.Decimal` or - :class:`~fractions.Fraction`.) If the input iterable is empty, the - output iterable will also be empty. + Make an iterator that returns accumulated sums. Elements may be any addable + type including :class:`~decimal.Decimal` or :class:`~fractions.Fraction`. + If the optional *func* argument is supplied, it should be a function of two + arguments and it will be used instead of addition. Equivalent to:: @@ -789,19 +784,6 @@ except exception: pass - def first_true(iterable, default=False, pred=None): - """Returns the first true value in the iterable. - - If no true value is found, returns *default* - - If *pred* is not None, returns the first item - for which pred(item) is true. - - """ - # first_true([a,b,c], x) --> a or b or c or x - # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x - return next(filter(pred, iterable), default) - def random_product(*args, repeat=1): "Random selection from itertools.product(*args, **kwds)" pools = [tuple(pool) for pool in args] * repeat diff -r ce070040e1a6 -r d7f128afe9db Doc/library/json.rst --- a/Doc/library/json.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/json.rst Sun Mar 23 09:44:28 2014 +0100 @@ -590,7 +590,7 @@ Command line options ^^^^^^^^^^^^^^^^^^^^ -.. cmdoption:: infile +.. cmdoption:: [] The JSON file to be validated or pretty-printed:: @@ -606,9 +606,7 @@ } ] - If *infile* is not specified, read from :attr:`sys.stdin`. - -.. cmdoption:: outfile +.. cmdoption:: [] Write the output of the *infile* to the given *outfile*. Otherwise, write it to :attr:`sys.stdout`. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/logging.rst --- a/Doc/library/logging.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/logging.rst Sun Mar 23 09:44:28 2014 +0100 @@ -250,7 +250,7 @@ interpreted as for :meth:`debug`. -.. method:: Logger.exception(msg, *args, **kwargs) +.. method:: Logger.exception(msg, *args) Logs a message with level :const:`ERROR` on this logger. The arguments are interpreted as for :meth:`debug`. Exception info is added to the logging @@ -992,7 +992,7 @@ are interpreted as for :func:`debug`. -.. function:: exception(msg, *args, **kwargs) +.. function:: exception(msg, *args) Logs a message with level :const:`ERROR` on the root logger. The arguments are interpreted as for :func:`debug`. Exception info is added to the logging diff -r ce070040e1a6 -r d7f128afe9db Doc/library/operator.rst --- a/Doc/library/operator.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/operator.rst Sun Mar 23 09:44:28 2014 +0100 @@ -138,14 +138,6 @@ Return ``a * b``, for *a* and *b* numbers. -.. function:: matmul(a, b) - __matmul__(a, b) - - Return ``a @ b``. - - .. versionadded:: 3.5 - - .. function:: neg(obj) __neg__(obj) @@ -408,8 +400,6 @@ +-----------------------+-------------------------+---------------------------------------+ | Multiplication | ``a * b`` | ``mul(a, b)`` | +-----------------------+-------------------------+---------------------------------------+ -| Matrix Multiplication | ``a @ b`` | ``matmul(a, b)`` | -+-----------------------+-------------------------+---------------------------------------+ | Negation (Arithmetic) | ``- a`` | ``neg(a)`` | +-----------------------+-------------------------+---------------------------------------+ | Negation (Logical) | ``not a`` | ``not_(a)`` | @@ -518,14 +508,6 @@ ``a = imul(a, b)`` is equivalent to ``a *= b``. -.. function:: imatmul(a, b) - __imatmul__(a, b) - - ``a = imatmul(a, b)`` is equivalent to ``a @= b``. - - .. versionadded:: 3.5 - - .. function:: ior(a, b) __ior__(a, b) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/os.rst --- a/Doc/library/os.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/os.rst Sun Mar 23 09:44:28 2014 +0100 @@ -1087,9 +1087,6 @@ All platforms support sockets as *out* file descriptor, and some platforms allow other types (e.g. regular file, pipe) as well. - Cross-platform applications should not use *headers*, *trailers* and *flags* - arguments. - Availability: Unix. .. versionadded:: 3.3 @@ -1622,8 +1619,11 @@ The default *mode* is ``0o777`` (octal). On some systems, *mode* is ignored. Where it is used, the current umask value is first masked out. - If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if the - target directory already exists. + If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if + the target directory already exists. If *exist_ok* is ``True`` an + :exc:`OSError` is still raised if the umask-masked *mode* is different from + the existing mode, on systems where the mode is used. :exc:`OSError` will + also be raised if the directory creation fails. .. note:: @@ -1635,13 +1635,6 @@ .. versionadded:: 3.2 The *exist_ok* parameter. - .. versionchanged:: 3.4.1 - - Before Python 3.4.1, if *exist_ok* was ``True`` and the directory existed, - :func:`makedirs` would still raise an error if *mode* did not match the - mode of the existing directory. Since this behavior was impossible to - implement safely, it was removed in Python 3.4.1. See :issue:`21082`. - .. function:: mkfifo(path, mode=0o666, *, dir_fd=None) @@ -2733,27 +2726,10 @@ Availability: Unix. -.. function:: popen(command, mode='r', buffering=-1) - - Open a pipe to or from *command*. The return value is an open file object - connected to the pipe, which can be read or written depending on whether *mode* - is ``'r'`` (default) or ``'w'``. The *buffering* argument has the same meaning as - the corresponding argument to the built-in :func:`open` function. The - returned file object reads or writes text strings rather than bytes. - - The ``close`` method returns :const:`None` if the subprocess exited - successfully, or the subprocess's return code if there was an - error. On POSIX systems, if the return code is positive it - represents the return value of the process left-shifted by one - byte. If the return code is negative, the process was terminated - by the signal given by the negated value of the return code. (For - example, the return value might be ``- signal.SIGKILL`` if the - subprocess was killed.) On Windows systems, the return value - contains the signed integer return code from the child process. - - This is implemented using :class:`subprocess.Popen`; see that class's - documentation for more powerful ways to manage and communicate with - subprocesses. +.. function:: popen(...) + + Run child processes, returning opened pipes for communications. These functions + are described in section :ref:`os-newstreams`. .. function:: spawnl(mode, path, ...) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/pyexpat.rst Sun Mar 23 09:44:28 2014 +0100 @@ -100,11 +100,6 @@ http://www.python.org/ns/ elem1 elem2 - Due to limitations in the ``Expat`` library used by :mod:`pyexpat`, - the :class:`xmlparser` instance returned can only be used to parse a single - XML document. Call ``ParserCreate`` for each document to provide unique - parser instances. - .. seealso:: @@ -124,9 +119,7 @@ Parses the contents of the string *data*, calling the appropriate handler functions to process the parsed data. *isfinal* must be true on the final call - to this method; it allows the parsing of a single file in fragments, - not the submission of multiple files. - *data* can be the empty string at any time. + to this method. *data* can be the empty string at any time. .. method:: xmlparser.ParseFile(file) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/select.rst --- a/Doc/library/select.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/select.rst Sun Mar 23 09:44:28 2014 +0100 @@ -377,7 +377,7 @@ Modifies an already registered fd. This has the same effect as ``register(fd, eventmask)``. Attempting to modify a file descriptor - that was never registered causes an :exc:`OSError` exception with errno + that was never registered causes an :exc:`IOError` exception with errno :const:`ENOENT` to be raised. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/shutil.rst --- a/Doc/library/shutil.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/shutil.rst Sun Mar 23 09:44:28 2014 +0100 @@ -421,26 +421,6 @@ copytree(source, destination, ignore=_logpath) -.. _shutil-rmtree-example: - -rmtree example -~~~~~~~~~~~~~~ - -This example shows how to remove a directory tree on Windows where some -of the files have their read-only bit set. It uses the onerror callback -to clear the readonly bit and reattempt the remove. Any subsequent failure -will propagate. :: - - import os, stat - import shutil - - def remove_readonly(func, path, _): - "Clear the readonly bit and reattempt the removal" - os.chmod(path, stat.S_IWRITE) - func(path) - - shutil.rmtree(directory, onerror=remove_readonly) - .. _archiving-operations: Archiving operations diff -r ce070040e1a6 -r d7f128afe9db Doc/library/signal.rst --- a/Doc/library/signal.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/signal.rst Sun Mar 23 09:44:28 2014 +0100 @@ -65,16 +65,6 @@ Module contents --------------- -.. versionchanged:: 3.5 - signal (SIG*), handler (:const:`SIG_DFL`, :const:`SIG_IGN`) and sigmask - (:const:`SIG_BLOCK`, :const:`SIG_UNBLOCK`, :const:`SIG_SETMASK`) - related constants listed below were turned into - :class:`enums `. - :func:`getsignal`, :func:`pthread_sigmask`, :func:`sigpending` and - :func:`sigwait` functions return human-readable - :class:`enums `. - - The variables defined in the :mod:`signal` module are: diff -r ce070040e1a6 -r d7f128afe9db Doc/library/site.rst --- a/Doc/library/site.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/site.rst Sun Mar 23 09:44:28 2014 +0100 @@ -99,11 +99,7 @@ :mod:`sitecustomize`, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an :exc:`ImportError` exception, it is -silently ignored. If Python is started without output streams available, as -with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), -attempted output from :mod:`sitecustomize` is ignored. Any exception other -than :exc:`ImportError` causes a silent and perhaps mysterious failure of the -process. +silently ignored. .. index:: module: usercustomize diff -r ce070040e1a6 -r d7f128afe9db Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/sqlite3.rst Sun Mar 23 09:44:28 2014 +0100 @@ -13,8 +13,8 @@ application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle. -The sqlite3 module was written by Gerhard Häring. It provides a SQL interface -compliant with the DB-API 2.0 specification described by :pep:`249`. +sqlite3 was written by Gerhard Häring and provides a SQL interface compliant +with the DB-API 2.0 specification described by :pep:`249`. To use the module, you must first create a :class:`Connection` object that represents the database. Here the data will be stored in the @@ -31,29 +31,23 @@ c = conn.cursor() # Create table - c.execute('''CREATE TABLE stocks - (date text, trans text, symbol text, qty real, price real)''') + c.execute('''create table stocks + (date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data - c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") + c.execute("""insert into stocks + values ('2006-01-05','BUY','RHAT',100,35.14)""") # Save (commit) the changes conn.commit() - # We can also close the connection if we are done with it. - # Just be sure any changes have been committed or they will be lost. - conn.close() - -The data you've saved is persistent and is available in subsequent sessions:: - - import sqlite3 - conn = sqlite3.connect('example.db') - c = conn.cursor() + # We can also close the cursor if we are done with it + c.close() Usually your SQL operations will need to use values from Python variables. You shouldn't assemble your query using Python's string operations because doing so -is insecure; it makes your program vulnerable to an SQL injection attack -(see http://xkcd.com/327/ for humorous example of what can go wrong). +is insecure; it makes your program vulnerable to an SQL injection attack. Instead, use the DB-API's parameter substitution. Put ``?`` as a placeholder wherever you want to use a value, and then provide a tuple of values as the @@ -62,20 +56,19 @@ example:: # Never do this -- insecure! - symbol = 'RHAT' - c.execute("SELECT * FROM stocks WHERE symbol = '%s'" % symbol) + symbol = 'IBM' + c.execute("select * from stocks where symbol = '%s'" % symbol) # Do this instead - t = ('RHAT',) - c.execute('SELECT * FROM stocks WHERE symbol=?', t) - print(c.fetchone()) + t = ('IBM',) + c.execute('select * from stocks where symbol=?', t) - # Larger example that inserts many records at a time - purchases = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), - ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00), - ('2006-04-06', 'SELL', 'IBM', 500, 53.00), - ] - c.executemany('INSERT INTO stocks VALUES (?,?,?,?,?)', purchases) + # Larger example + for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), + ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00), + ('2006-04-06', 'SELL', 'IBM', 500, 53.00), + ]: + c.execute('insert into stocks values (?,?,?,?,?)', t) To retrieve data after executing a SELECT statement, you can either treat the cursor as an :term:`iterator`, call the cursor's :meth:`~Cursor.fetchone` method to @@ -84,13 +77,16 @@ This example uses the iterator form:: - >>> for row in c.execute('SELECT * FROM stocks ORDER BY price'): - print(row) - + >>> c = conn.cursor() + >>> c.execute('select * from stocks order by price') + >>> for row in c: + ... print(row) + ... ('2006-01-05', 'BUY', 'RHAT', 100, 35.14) ('2006-03-28', 'BUY', 'IBM', 1000, 45.0) ('2006-04-06', 'SELL', 'IBM', 500, 53.0) - ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0) + ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.0) + >>> .. seealso:: @@ -103,9 +99,6 @@ The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. - http://www.w3schools.com/sql/ - Tutorial, reference and examples for learning SQL syntax. - :pep:`249` - Database API Specification 2.0 PEP written by Marc-André Lemburg. @@ -524,7 +517,7 @@ .. method:: execute(sql, [parameters]) - Executes an SQL statement. The SQL statement may be parameterized (i. e. + Executes an SQL statement. The SQL statement may be parametrized (i. e. placeholders instead of SQL literals). The :mod:`sqlite3` module supports two kinds of placeholders: question marks (qmark style) and named placeholders (named style). @@ -721,20 +714,19 @@ This is how SQLite types are converted to Python types by default: -+-------------+----------------------------------------------+ -| SQLite type | Python type | -+=============+==============================================+ -| ``NULL`` | :const:`None` | -+-------------+----------------------------------------------+ -| ``INTEGER`` | :class:`int` | -+-------------+----------------------------------------------+ -| ``REAL`` | :class:`float` | -+-------------+----------------------------------------------+ -| ``TEXT`` | depends on :attr:`~Connection.text_factory`, | -| | :class:`str` by default | -+-------------+----------------------------------------------+ -| ``BLOB`` | :class:`bytes` | -+-------------+----------------------------------------------+ ++-------------+---------------------------------------------+ +| SQLite type | Python type | ++=============+=============================================+ +| ``NULL`` | :const:`None` | ++-------------+---------------------------------------------+ +| ``INTEGER`` | :class:`int` | ++-------------+---------------------------------------------+ +| ``REAL`` | :class:`float` | ++-------------+---------------------------------------------+ +| ``TEXT`` | depends on text_factory, str by default | ++-------------+---------------------------------------------+ +| ``BLOB`` | :class:`bytes` | ++-------------+---------------------------------------------+ The type system of the :mod:`sqlite3` module is extensible in two ways: you can store additional Python types in a SQLite database via object adaptation, and @@ -750,6 +742,9 @@ sqlite3 module's supported types for SQLite: one of NoneType, int, float, str, bytes. +The :mod:`sqlite3` module uses Python object adaptation, as described in +:pep:`246` for this. The protocol to use is :class:`PrepareProtocol`. + There are two ways to enable the :mod:`sqlite3` module to adapt a custom Python type to one of the supported ones. @@ -805,8 +800,8 @@ .. note:: - Converter functions **always** get called with a :class:`bytes` object, no - matter under which data type you sent the value to SQLite. + Converter functions **always** get called with a string, no matter under which + data type you sent the value to SQLite. :: diff -r ce070040e1a6 -r d7f128afe9db Doc/library/ssl.rst --- a/Doc/library/ssl.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/ssl.rst Sun Mar 23 09:44:28 2014 +0100 @@ -372,34 +372,22 @@ IDN A-labels such as ``www*.xn--pthon-kva.org`` are still supported, but ``x*.python.org`` no longer matches ``xn--tda.python.org``. -.. function:: cert_time_to_seconds(cert_time) +.. function:: cert_time_to_seconds(timestring) - Return the time in seconds since the Epoch, given the ``cert_time`` - string representing the "notBefore" or "notAfter" date from a - certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C - locale). + Returns a floating-point value containing a normal seconds-after-the-epoch + time value, given the time-string representing the "notBefore" or "notAfter" + date from a certificate. - Here's an example: + Here's an example:: - .. doctest:: newcontext + >>> import ssl + >>> ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT") + 1178694000.0 + >>> import time + >>> time.ctime(ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT")) + 'Wed May 9 00:00:00 2007' - >>> import ssl - >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") - >>> timestamp - 1515144883 - >>> from datetime import datetime - >>> print(datetime.utcfromtimestamp(timestamp)) - 2018-01-05 09:34:43 - - "notBefore" or "notAfter" dates must use GMT (:rfc:`5280`). - - .. versionchanged:: 3.5 - Interpret the input time as a time in UTC as specified by 'GMT' - timezone in the input string. Local timezone was used - previously. Return an integer (no fractions of a second in the - input format) - -.. function:: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None) +.. function:: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None) Given the address ``addr`` of an SSL-protected server, as a (*hostname*, *port-number*) pair, fetches the server's certificate, and returns it as a @@ -413,10 +401,6 @@ .. versionchanged:: 3.3 This function is now IPv6-compatible. - .. versionchanged:: 3.5 - The default *ssl_version* is changed from :data:`PROTOCOL_SSLv3` to - :data:`PROTOCOL_SSLv23` for maximum compatibility with modern servers. - .. function:: DER_cert_to_PEM_cert(DER_cert_bytes) Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded @@ -1604,25 +1588,8 @@ Notes on non-blocking sockets ----------------------------- -SSL sockets behave slightly different than regular sockets in -non-blocking mode. When working with non-blocking sockets, there are -thus several things you need to be aware of: - -- Most :class:`SSLSocket` methods will raise either - :exc:`SSLWantWriteError` or :exc:`SSLWantReadError` instead of - :exc:`BlockingIOError` if an I/O operation would - block. :exc:`SSLWantReadError` will be raised if a read operation on - the underlying socket is necessary, and :exc:`SSLWantWriteError` for - a write operation on the underlying socket. Note that attempts to - *write* to an SSL socket may require *reading* from the underlying - socket first, and attempts to *read* from the SSL socket may require - a prior *write* to the underlying socket. - - .. versionchanged:: 3.5 - - In earlier Python versions, the :meth:`!SSLSocket.send` method - returned zero instead of raising :exc:`SSLWantWriteError` or - :exc:`SSLWantReadError`. +When working with non-blocking sockets, there are several things you need +to be aware of: - Calling :func:`~select.select` tells you that the OS-level socket can be read from (or written to), but it does not imply that there is sufficient diff -r ce070040e1a6 -r d7f128afe9db Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/subprocess.rst Sun Mar 23 09:44:28 2014 +0100 @@ -660,7 +660,6 @@ must be bytes or, if *universal_newlines* was ``True``, a string. :meth:`communicate` returns a tuple ``(stdoutdata, stderrdata)``. - The data will be bytes or, if *universal_newlines* was ``True``, strings. Note that if you want to send data to the process's stdin, you need to create the Popen object with ``stdin=PIPE``. Similarly, to get anything other than @@ -724,12 +723,6 @@ deadlocks due to any of the other OS pipe buffers filling up and blocking the child process. -.. attribute:: Popen.args - - The *args* argument as it was passed to :class:`Popen` -- a - sequence of program arguments or else a single string. - - .. versionadded:: 3.3 .. attribute:: Popen.stdin diff -r ce070040e1a6 -r d7f128afe9db Doc/library/timeit.rst --- a/Doc/library/timeit.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/timeit.rst Sun Mar 23 09:44:28 2014 +0100 @@ -63,12 +63,6 @@ Create a :class:`Timer` instance with the given statement, *setup* code and *timer* function and run its :meth:`.timeit` method with *number* executions. - .. note:: - - Because :meth:`.timeit` is executing *stmt*, placing a return statement - in *stmt* will prevent :meth:`.timeit` from returning execution time. - It will instead return the data specified by your return statement. - .. function:: repeat(stmt='pass', setup='pass', timer=, repeat=3, number=1000000) diff -r ce070040e1a6 -r d7f128afe9db Doc/library/token.rst --- a/Doc/library/token.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/token.rst Sun Mar 23 09:44:28 2014 +0100 @@ -93,7 +93,6 @@ DOUBLESLASH DOUBLESLASHEQUAL AT - ATEQUAL RARROW ELLIPSIS OP diff -r ce070040e1a6 -r d7f128afe9db Doc/library/trace.rst --- a/Doc/library/trace.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/trace.rst Sun Mar 23 09:44:28 2014 +0100 @@ -41,8 +41,8 @@ At least one of the following options must be specified when invoking :mod:`trace`. The :option:`--listfuncs <-l>` option is mutually exclusive with -the :option:`--trace <-t>` and :option:`--count <-c>` options. When -:option:`--listfuncs <-l>` is provided, neither :option:`--count <-c>` nor +the :option:`--trace <-t>` and :option:`--counts <-c>` options. When +:option:`--listfuncs <-l>` is provided, neither :option:`--counts <-c>` nor :option:`--trace <-t>` are accepted, and vice versa. .. program:: trace diff -r ce070040e1a6 -r d7f128afe9db Doc/library/traceback.rst --- a/Doc/library/traceback.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/traceback.rst Sun Mar 23 09:44:28 2014 +0100 @@ -72,7 +72,7 @@ Return a list of up to *limit* "pre-processed" stack trace entries extracted from the traceback object *traceback*. It is useful for alternate formatting of stack traces. If *limit* is omitted or ``None``, all entries are extracted. A - "pre-processed" stack trace entry is a 4-tuple (*filename*, *line number*, + "pre-processed" stack trace entry is a quadruple (*filename*, *line number*, *function name*, *text*) representing the information that is usually printed for a stack trace. The *text* is a string with leading and trailing whitespace stripped; if the source is not available it is ``None``. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/turtle.rst --- a/Doc/library/turtle.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/turtle.rst Sun Mar 23 09:44:28 2014 +0100 @@ -1879,7 +1879,7 @@ >>> cv = screen.getcanvas() >>> cv - + .. function:: getshapes() diff -r ce070040e1a6 -r d7f128afe9db Doc/library/unittest.mock.rst --- a/Doc/library/unittest.mock.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/unittest.mock.rst Sun Mar 23 09:44:28 2014 +0100 @@ -198,7 +198,7 @@ the `new_callable` argument to `patch`. -.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, unsafe=False, **kwargs) +.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, **kwargs) Create a new `Mock` object. `Mock` takes several optional arguments that specify the behaviour of the Mock object: @@ -235,12 +235,6 @@ this is a new Mock (created on first access). See the :attr:`return_value` attribute. - * `unsafe`: By default if any attribute starts with *assert* or - *assret* will raise an `AttributeError`. Passing `unsafe=True` will allow - access to these attributes. - - .. versionadded:: 3.5 - * `wraps`: Item for the mock object to wrap. If `wraps` is not None then calling the Mock will pass the call through to the wrapped object (returning the real result). Attribute access on the mock will return a @@ -321,20 +315,6 @@ >>> calls = [call(4), call(2), call(3)] >>> mock.assert_has_calls(calls, any_order=True) - .. method:: assert_not_called(*args, **kwargs) - - Assert the mock was never called. - - >>> m = Mock() - >>> m.hello.assert_not_called() - >>> obj = m.hello() - >>> m.hello.assert_not_called() - Traceback (most recent call last): - ... - AssertionError: Expected 'hello' to not have been called. Called 1 times. - - .. versionadded:: 3.5 - .. method:: reset_mock() @@ -1051,12 +1031,6 @@ default because it can be dangerous. With it switched on you can write passing tests against APIs that don't actually exist! - .. note:: - - .. versionchanged:: 3.5 - If you are patching builtins in a module then you don't - need to pass `create=True`, it will be added by default. - Patch can be used as a `TestCase` class decorator. It works by decorating each test method in the class. This reduces the boilerplate code when your test methods share a common patchings set. `patch` finds @@ -1427,21 +1401,6 @@ Stop all active patches. Only stops patches started with `start`. -.. patch-builtins: - -patch builtins -~~~~~~~~~~~~~~~ -You can patch any builtins within a module. The following example patches -builtin `ord`: - - >>> @patch('__main__.ord') - ... def test(mock_ord): - ... mock_ord.return_value = 101 - ... print(ord('c')) - ... - >>> test() - 101 - TEST_PREFIX ~~~~~~~~~~~ @@ -2052,7 +2011,7 @@ enough that a helper function is useful. >>> m = mock_open() - >>> with patch('__main__.open', m): + >>> with patch('__main__.open', m, create=True): ... with open('foo', 'w') as h: ... h.write('some stuff') ... @@ -2067,7 +2026,7 @@ And for reading files: - >>> with patch('__main__.open', mock_open(read_data='bibble')) as m: + >>> with patch('__main__.open', mock_open(read_data='bibble'), create=True) as m: ... with open('foo') as h: ... result = h.read() ... diff -r ce070040e1a6 -r d7f128afe9db Doc/library/unittest.rst --- a/Doc/library/unittest.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/unittest.rst Sun Mar 23 09:44:28 2014 +0100 @@ -674,9 +674,9 @@ .. method:: setUp() Method called to prepare the test fixture. This is called immediately - before calling the test method; other than :exc:`AssertionError` or :exc:`SkipTest`, - any exception raised by this method will be considered an error rather than - a test failure. The default implementation does nothing. + before calling the test method; any exception raised by this method will + be considered an error rather than a test failure. The default + implementation does nothing. .. method:: tearDown() @@ -684,10 +684,10 @@ Method called immediately after the test method has been called and the result recorded. This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly - careful about checking internal state. Any exception, other than :exc:`AssertionError` - or :exc:`SkipTest`, raised by this method will be considered an error rather than a - test failure. This method will only be called if the :meth:`setUp` succeeds, - regardless of the outcome of the test method. The default implementation does nothing. + careful about checking internal state. Any exception raised by this + method will be considered an error rather than a test failure. This + method will only be called if the :meth:`setUp` succeeds, regardless of + the outcome of the test method. The default implementation does nothing. .. method:: setUpClass() @@ -1807,14 +1807,14 @@ Called after the test case *test* has been executed, regardless of the outcome. - .. method:: startTestRun() + .. method:: startTestRun(test) Called once before any tests are executed. .. versionadded:: 3.1 - .. method:: stopTestRun() + .. method:: stopTestRun(test) Called once after all tests are executed. diff -r ce070040e1a6 -r d7f128afe9db Doc/library/venv.rst --- a/Doc/library/venv.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/venv.rst Sun Mar 23 09:44:28 2014 +0100 @@ -40,14 +40,14 @@ A venv is a directory tree which contains Python executable files and other files which indicate that it is a venv. - Common installation tools such as ``Distribute`` and ``pip`` work as + Common installation tools such as ``setuptools`` and ``pip`` work as expected with venvs - i.e. when a venv is active, they install Python packages into the venv without needing to be told to do so explicitly. Of course, you need to install them into the venv first: this could be - done by running ``distribute_setup.py`` with the venv activated, - followed by running ``easy_install pip``. Alternatively, you could download - the source tarballs and run ``python setup.py install`` after unpacking, - with the venv activated. + done by running ``setuptools`` project's ``ez_setup.py`` with the venv + activated, followed by running ``easy_install pip``. Alternatively, you + could download the source tarballs and run ``python setup.py install`` + after unpacking, with the venv activated. When a venv is active (i.e. the venv's Python interpreter is running), the attributes :attr:`sys.prefix` and :attr:`sys.exec_prefix` point to the base diff -r ce070040e1a6 -r d7f128afe9db Doc/library/webbrowser.rst --- a/Doc/library/webbrowser.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/webbrowser.rst Sun Mar 23 09:44:28 2014 +0100 @@ -19,12 +19,12 @@ available. If text-mode browsers are used, the calling process will block until the user exits the browser. -If the environment variable :envvar:`BROWSER` exists, it is interpreted as the -:data:`os.pathsep`-separated list of browsers to try ahead of the the platform -defaults. When the value of a list part contains the string ``%s``, then it is -interpreted as a literal browser command line to be used with the argument URL -substituted for ``%s``; if the part does not contain ``%s``, it is simply -interpreted as the name of the browser to launch. [1]_ +If the environment variable :envvar:`BROWSER` exists, it is interpreted to +override the platform default list of browsers, as a :data:`os.pathsep`-separated +list of browsers to try in order. When the value of a list part contains the +string ``%s``, then it is interpreted as a literal browser command line to be +used with the argument URL substituted for ``%s``; if the part does not contain +``%s``, it is simply interpreted as the name of the browser to launch. [1]_ For non-Unix platforms, or when a remote browser is available on Unix, the controlling process will not wait for the user to finish with the browser, but diff -r ce070040e1a6 -r d7f128afe9db Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/library/xml.etree.elementtree.rst Sun Mar 23 09:44:28 2014 +0100 @@ -106,19 +106,6 @@ '2008' -.. note:: - - Not all elements of the XML input will end up as elements of the - parsed tree. Currently, this module skips over any XML comments, - processing instructions, and document type declarations in the - input. Nevertheless, trees built using this module's API rather - than parsing from XML text can have comments and processing - instructions in them; they will be included when generating XML - output. A document type declaration may be accessed by passing a - custom :class:`TreeBuilder` instance to the :class:`XMLParser` - constructor. - - .. _elementtree-pull-parsing: Pull API for non-blocking parsing @@ -338,7 +325,7 @@ +=======================+======================================================+ | ``tag`` | Selects all child elements with the given tag. | | | For example, ``spam`` selects all child elements | -| | named ``spam``, and ``spam/egg`` selects all | +| | named ``spam``, ``spam/egg`` selects all | | | grandchildren named ``egg`` in all children named | | | ``spam``. | +-----------------------+------------------------------------------------------+ @@ -394,10 +381,6 @@ string containing the comment string. Returns an element instance representing a comment. - Note that :class:`XMLParser` skips over comments in the input - instead of creating comment objects for them. An :class:`ElementTree` will - only contain comment nodes if they have been inserted into to - the tree using one of the :class:`Element` methods. .. function:: dump(elem) @@ -478,11 +461,6 @@ containing the PI target. *text* is a string containing the PI contents, if given. Returns an element instance, representing a processing instruction. - Note that :class:`XMLParser` skips over processing instructions - in the input instead of creating comment objects for them. An - :class:`ElementTree` will only contain processing instruction nodes if - they have been inserted into to the tree using one of the - :class:`Element` methods. .. function:: register_namespace(prefix, uri) diff -r ce070040e1a6 -r d7f128afe9db Doc/make.bat --- a/Doc/make.bat Sat May 10 13:24:58 2014 -0400 +++ b/Doc/make.bat Sun Mar 23 09:44:28 2014 +0100 @@ -1,115 +1,40 @@ -@echo off +@@echo off setlocal -pushd %~dp0 - -set this=%~n0 - -if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build -if "%PYTHON%" EQU "" set PYTHON=py - -if DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles(x86)% -if NOT DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles% -if "%HTMLHELP%" EQU "" set HTMLHELP=%_PRGMFLS%\HTML Help Workshop\hhc.exe - +if "%PYTHON%" EQU "" set PYTHON=py -2 +if "%HTMLHELP%" EQU "" set HTMLHELP=%ProgramFiles%\HTML Help Workshop\hhc.exe if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/sphinxext/patchlevel.py`) do set DISTVERSION=%%v -if "%BUILDDIR%" EQU "" set BUILDDIR=build - -rem Targets that don't require sphinx-build if "%1" EQU "" goto help -if "%1" EQU "help" goto help -if "%1" EQU "check" goto check -if "%1" EQU "serve" goto serve -if "%1" == "clean" ( - rmdir /q /s %BUILDDIR% - goto end -) - -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - goto end -) - -rem Targets that do require sphinx-build and have their own label -if "%1" EQU "htmlview" goto htmlview - -rem Everything else -goto build +if "%1" EQU "html" goto build +if "%1" EQU "htmlhelp" goto build +if "%1" EQU "latex" goto build +if "%1" EQU "text" goto build +if "%1" EQU "suspicious" goto build +if "%1" EQU "linkcheck" goto build +if "%1" EQU "changes" goto build :help -echo.usage: %this% BUILDER [filename ...] +set this=%~n0 +echo HELP echo. -echo.Call %this% with the desired Sphinx builder as the first argument, e.g. -echo.``%this% html`` or ``%this% doctest``. Interesting targets that are -echo.always available include: +echo %this% html +echo %this% htmlhelp +echo %this% latex +echo %this% text +echo %this% suspicious +echo %this% linkcheck +echo %this% changes echo. -echo. Provided by Sphinx: -echo. html, htmlhelp, latex, text -echo. suspicious, linkcheck, changes, doctest -echo. Provided by this script: -echo. clean, check, serve, htmlview -echo. -echo.All arguments past the first one are passed through to sphinx-build as -echo.filenames to build or are ignored. See README.txt in this directory or -echo.the documentation for your version of Sphinx for more exhaustive lists -echo.of available targets and descriptions of each. -echo. -echo.This script assumes that the SPHINXBUILD environment variable contains -echo.a legitimate command for calling sphinx-build, or that sphinx-build is -echo.on your PATH if SPHINXBUILD is not set. Options for sphinx-build can -echo.be passed by setting the SPHINXOPTS environment variable. goto end :build -if NOT "%PAPER%" == "" ( - set SPHINXOPTS=-D latex_paper_size=%PAPER% %SPHINXOPTS% -) -cmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%* - -if "%1" EQU "htmlhelp" ( - cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp - rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2 - if not errorlevel 2 cmd /C exit /b 0 -) - -echo. -if errorlevel 1 ( - echo.Build failed (exit code %ERRORLEVEL%^), check for error messages - echo.above. Any output will be found in %BUILDDIR%\%1 -) else ( - echo.Build succeeded. All output should be in %BUILDDIR%\%1 -) -goto end - -:htmlview -if NOT "%2" EQU "" ( - echo.Can't specify filenames to build with htmlview target, ignoring. -) -cmd /C %this% html - -if EXIST %BUILDDIR%\html\index.html ( - echo.Opening %BUILDDIR%\html\index.html in the default web browser... - start %BUILDDIR%\html\index.html -) - -goto end - -:check -cmd /C %PYTHON% tools\rstlint.py -i tools -goto end - -:serve -cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html +if not exist build mkdir build +if not exist build\%1 mkdir build\%1 +if not exist build\doctrees mkdir build\doctrees +cmd /C %PYTHON% --version +cmd /C %PYTHON% tools\sphinx-build.py -b%1 -dbuild\doctrees . build\%* +if "%1" EQU "htmlhelp" "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp goto end :end -popd diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/compound_stmts.rst Sun Mar 23 09:44:28 2014 +0100 @@ -313,14 +313,14 @@ If the :keyword:`finally` clause executes a :keyword:`return` or :keyword:`break` statement, the saved exception is discarded:: - >>> def f(): - ... try: - ... 1/0 - ... finally: - ... return 42 - ... - >>> f() - 42 + def f(): + try: + 1/0 + finally: + return 42 + + >>> f() + 42 The exception information is not available to the program during execution of the :keyword:`finally` clause. @@ -337,20 +337,6 @@ reason is a problem with the current implementation --- this restriction may be lifted in the future). -The return value of a function is determined by the last :keyword:`return` -statement executed. Since the :keyword:`finally` clause always executes, a -:keyword:`return` statement executed in the :keyword:`finally` clause will -always be the last one executed:: - - >>> def foo(): - ... try: - ... return 'try' - ... finally: - ... return 'finally' - ... - >>> foo() - 'finally' - Additional information on exceptions can be found in section :ref:`exceptions`, and information on using the :keyword:`raise` statement to generate exceptions may be found in section :ref:`raise`. @@ -362,9 +348,7 @@ The :keyword:`with` statement ============================= -.. index:: - statement: with - single: as; with statement +.. index:: statement: with The :keyword:`with` statement is used to wrap the execution of a block with methods defined by a context manager (see section :ref:`context-managers`). diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/datamodel.rst Sun Mar 23 09:44:28 2014 +0100 @@ -1467,14 +1467,6 @@ Called to delete the attribute on an instance *instance* of the owner class. -The attribute :attr:`__objclass__` is interpreted by the :mod:`inspect` module -as specifying the class where this object was defined (setting this -appropriately can assist in runtime introspection of dynamic class attributes). -For callables, it may indicate that an instance of the given type (or a -subclass) is expected or required as the first positional argument (for example, -CPython sets this attribute for unbound methods that are implemented in C). - - .. _descriptor-invocation: Invoking Descriptors @@ -1970,7 +1962,6 @@ .. method:: object.__add__(self, other) object.__sub__(self, other) object.__mul__(self, other) - object.__matmul__(self, other) object.__truediv__(self, other) object.__floordiv__(self, other) object.__mod__(self, other) @@ -1987,16 +1978,15 @@ builtin: pow builtin: pow - These methods are called to implement the binary arithmetic operations - (``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`, - :func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For instance, to - evaluate the expression ``x + y``, where *x* is an instance of a class that - has an :meth:`__add__` method, ``x.__add__(y)`` is called. The - :meth:`__divmod__` method should be the equivalent to using - :meth:`__floordiv__` and :meth:`__mod__`; it should not be related to - :meth:`__truediv__`. Note that :meth:`__pow__` should be defined to accept - an optional third argument if the ternary version of the built-in :func:`pow` - function is to be supported. + These methods are called to implement the binary arithmetic operations (``+``, + ``-``, ``*``, ``/``, ``//``, ``%``, :func:`divmod`, :func:`pow`, ``**``, ``<<``, + ``>>``, ``&``, ``^``, ``|``). For instance, to evaluate the expression + ``x + y``, where *x* is an instance of a class that has an :meth:`__add__` + method, ``x.__add__(y)`` is called. The :meth:`__divmod__` method should be the + equivalent to using :meth:`__floordiv__` and :meth:`__mod__`; it should not be + related to :meth:`__truediv__`. Note that :meth:`__pow__` should be defined + to accept an optional third argument if the ternary version of the built-in + :func:`pow` function is to be supported. If one of those methods does not support the operation with the supplied arguments, it should return ``NotImplemented``. @@ -2005,7 +1995,6 @@ .. method:: object.__radd__(self, other) object.__rsub__(self, other) object.__rmul__(self, other) - object.__rmatmul__(self, other) object.__rtruediv__(self, other) object.__rfloordiv__(self, other) object.__rmod__(self, other) @@ -2021,14 +2010,14 @@ builtin: divmod builtin: pow - These methods are called to implement the binary arithmetic operations - (``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`, - :func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``) with reflected - (swapped) operands. These functions are only called if the left operand does - not support the corresponding operation and the operands are of different - types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is - an instance of a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)`` - is called if ``x.__sub__(y)`` returns *NotImplemented*. + These methods are called to implement the binary arithmetic operations (``+``, + ``-``, ``*``, ``/``, ``//``, ``%``, :func:`divmod`, :func:`pow`, ``**``, + ``<<``, ``>>``, ``&``, ``^``, ``|``) with reflected (swapped) operands. + These functions are only called if the left operand does not support the + corresponding operation and the operands are of different types. [#]_ For + instance, to evaluate the expression ``x - y``, where *y* is an instance of + a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)`` is called if + ``x.__sub__(y)`` returns *NotImplemented*. .. index:: builtin: pow @@ -2046,7 +2035,6 @@ .. method:: object.__iadd__(self, other) object.__isub__(self, other) object.__imul__(self, other) - object.__imatmul__(self, other) object.__itruediv__(self, other) object.__ifloordiv__(self, other) object.__imod__(self, other) @@ -2058,17 +2046,17 @@ object.__ior__(self, other) These methods are called to implement the augmented arithmetic assignments - (``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, - ``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the - operation in-place (modifying *self*) and return the result (which could be, - but does not have to be, *self*). If a specific method is not defined, the - augmented assignment falls back to the normal methods. For instance, if *x* - is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is - equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and - ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In - certain situations, augmented assignment can result in unexpected errors (see - :ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact - part of the data model. + (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``, + ``&=``, ``^=``, ``|=``). These methods should attempt to do the operation + in-place (modifying *self*) and return the result (which could be, but does + not have to be, *self*). If a specific method is not defined, the augmented + assignment falls back to the normal methods. For instance, if *x* is an + instance of a class with an :meth:`__iadd__` method, ``x += y`` is equivalent + to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and ``y.__radd__(x)`` + are considered, as with the evaluation of ``x + y``. In certain situations, + augmented assignment can result in unexpected errors (see + :ref:`faq-augmented-assignment-tuple-error`), but this behavior is in + fact part of the data model. .. method:: object.__neg__(self) diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/expressions.rst Sun Mar 23 09:44:28 2014 +0100 @@ -892,9 +892,8 @@ operators and one for additive operators: .. productionlist:: - m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` | - : `m_expr` "//" `u_expr`| `m_expr` "/" `u_expr` | - : `m_expr` "%" `u_expr` + m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr` + : | `m_expr` "%" `u_expr` a_expr: `m_expr` | `a_expr` "+" `m_expr` | `a_expr` "-" `m_expr` .. index:: single: multiplication @@ -905,13 +904,6 @@ common type and then multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence. -.. index:: single: matrix multiplication - -The ``@`` (at) operator is intended to be used for matrix multiplication. No -builtin Python types implement this operator. - -.. versionadded:: 3.5 - .. index:: exception: ZeroDivisionError single: division @@ -1354,9 +1346,8 @@ +-----------------------------------------------+-------------------------------------+ | ``+``, ``-`` | Addition and subtraction | +-----------------------------------------------+-------------------------------------+ -| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix | -| | multiplication division, | -| | remainder [#]_ | +| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder | +| | [#]_ | +-----------------------------------------------+-------------------------------------+ | ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT | +-----------------------------------------------+-------------------------------------+ diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/import.rst --- a/Doc/reference/import.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/import.rst Sun Mar 23 09:44:28 2014 +0100 @@ -519,10 +519,7 @@ The ``__spec__`` attribute must be set to the module spec that was used when importing the module. This is used primarily for - introspection and during reloading. Setting ``__spec__`` - appropriately applies equally to :ref:`modules initialized during - interpreter startup `. The one exception is ``__main__``, - where ``__spec__`` is :ref:`set to None in some cases `. + introspection and during reloading. .. versionadded:: 3.4 @@ -832,51 +829,6 @@ while raising an exception terminates it immediately. -Special considerations for __main__ -=================================== - -The :mod:`__main__` module is a special case relative to Python's import -system. As noted :ref:`elsewhere `, the ``__main__`` module -is directly initialized at interpreter startup, much like :mod:`sys` and -:mod:`builtins`. However, unlike those two, it doesn't strictly -qualify as a built-in module. This is because the manner in which -``__main__`` is initialized depends on the flags and other options with -which the interpreter is invoked. - -.. _main_spec: - -__main__.__spec__ ------------------ - -Depending on how :mod:`__main__` is initialized, ``__main__.__spec__`` -gets set appropriately or to ``None``. - -When Python is started with the :option:`-m` option, ``__spec__`` is set -to the module spec of the corresponding module or package. ``__spec__`` is -also populated when the ``__main__`` module is loaded as part of executing a -directory, zipfile or other :data:`sys.path` entry. - -In :ref:`the remaining cases ` -``__main__.__spec__`` is set to ``None``, as the code used to populate the -:mod:`__main__` does not correspond directly with an importable module: - -- interactive prompt -- -c switch -- running from stdin -- running directly from a source or bytecode file - -Note that ``__main__.__spec__`` is always ``None`` in the last case, -*even if* the file could technically be imported directly as a module -instead. Use the :option:`-m` switch if valid module metadata is desired -in :mod:`__main__`. - -Note also that even when ``__main__`` corresponds with an importable module -and ``__main__.__spec__`` is set accordingly, they're still considered -*distinct* modules. This is due to the fact that blocks guarded by -``if __name__ == "__main__":`` checks only execute when the module is used -to populate the ``__main__`` namespace, and not during normal import. - - Open issues =========== @@ -889,12 +841,6 @@ XXX runpy, pkgutil, et al in the library manual should all get "See Also" links at the top pointing to the new import system section. -XXX Add more explanation regarding the different ways in which -``__main__`` is initialized? - -XXX Add more info on ``__main__`` quirks/pitfalls (i.e. copy from -:pep:`395`). - References ========== diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/lexical_analysis.rst --- a/Doc/reference/lexical_analysis.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/lexical_analysis.rst Sun Mar 23 09:44:28 2014 +0100 @@ -76,7 +76,7 @@ Encoding declarations --------------------- -.. index:: source character set, encoding declarations (source file) +.. index:: source character set, encodings If a comment in the first or second line of the Python script matches the regular expression ``coding[=:]\s*([-\w.]+)``, this comment is processed as an diff -r ce070040e1a6 -r d7f128afe9db Doc/reference/simple_stmts.rst --- a/Doc/reference/simple_stmts.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/reference/simple_stmts.rst Sun Mar 23 09:44:28 2014 +0100 @@ -70,7 +70,6 @@ ===================== .. index:: - single: =; assignment statement pair: assignment; statement pair: binding; name pair: rebinding; name @@ -261,18 +260,6 @@ .. index:: pair: augmented; assignment single: statement; assignment, augmented - single: +=; augmented assignment - single: -=; augmented assignment - single: *=; augmented assignment - single: /=; augmented assignment - single: %=; augmented assignment - single: &=; augmented assignment - single: ^=; augmented assignment - single: |=; augmented assignment - single: **=; augmented assignment - single: //=; augmented assignment - single: >>=; augmented assignment - single: <<=; augmented assignment Augmented assignment is the combination, in a single statement, of a binary operation and an assignment statement: @@ -280,7 +267,7 @@ .. productionlist:: augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`) augtarget: `identifier` | `attributeref` | `subscription` | `slicing` - augop: "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**=" + augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**=" : | ">>=" | "<<=" | "&=" | "^=" | "|=" (See section :ref:`primaries` for the syntax definitions for the last three @@ -669,8 +656,6 @@ If the requested module is retrieved successfully, it will be made available in the local namespace in one of three ways: -.. index:: single: as; import statement - * If the module name is followed by :keyword:`as`, then the name following :keyword:`as` is bound directly to the imported module. * If no other name is specified, and the module being imported is a top diff -r ce070040e1a6 -r d7f128afe9db Doc/tools/sphinxext/c_annotations.py --- a/Doc/tools/sphinxext/c_annotations.py Sat May 10 13:24:58 2014 -0400 +++ b/Doc/tools/sphinxext/c_annotations.py Sun Mar 23 09:44:28 2014 +0100 @@ -81,10 +81,7 @@ continue if not par[0].has_key('names') or not par[0]['names']: continue - name = par[0]['names'][0] - if name.startswith("c."): - name = name[2:] - entry = self.get(name) + entry = self.get(par[0]['names'][0]) if not entry: continue elif entry.result_type not in ("PyObject*", "PyVarObject*"): diff -r ce070040e1a6 -r d7f128afe9db Doc/tools/sphinxext/download.html --- a/Doc/tools/sphinxext/download.html Sat May 10 13:24:58 2014 -0400 +++ b/Doc/tools/sphinxext/download.html Sun Mar 23 09:44:28 2014 +0100 @@ -34,8 +34,8 @@ Download (ca. 1.5 MB) EPUB - Download (ca. 4.5 MB) - + Download (ca. 3.5 MB) + Download (ca. 3.5 MB) diff -r ce070040e1a6 -r d7f128afe9db Doc/tutorial/controlflow.rst --- a/Doc/tutorial/controlflow.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/tutorial/controlflow.rst Sun Mar 23 09:44:28 2014 +0100 @@ -370,7 +370,7 @@ return False retries = retries - 1 if retries < 0: - raise OSError('uncooperative user') + raise IOError('uncooperative user') print(complaint) This function can be called in several ways: diff -r ce070040e1a6 -r d7f128afe9db Doc/tutorial/errors.rst --- a/Doc/tutorial/errors.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/tutorial/errors.rst Sun Mar 23 09:44:28 2014 +0100 @@ -131,8 +131,8 @@ f = open('myfile.txt') s = f.readline() i = int(s.strip()) - except OSError as err: - print("OS error: {0}".format(err)) + except IOError as err: + print("I/O error: {0}".format(err)) except ValueError: print("Could not convert data to an integer.") except: diff -r ce070040e1a6 -r d7f128afe9db Doc/tutorial/interpreter.rst --- a/Doc/tutorial/interpreter.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/tutorial/interpreter.rst Sun Mar 23 09:44:28 2014 +0100 @@ -35,14 +35,15 @@ status. If that doesn't work, you can exit the interpreter by typing the following command: ``quit()``. -The interpreter's line-editing features include interactive editing, history -substitution and code completion on systems that support readline. Perhaps the -quickest check to see whether command line editing is supported is typing -Control-P to the first Python prompt you get. If it beeps, you have command -line editing; see Appendix :ref:`tut-interacting` for an introduction to the -keys. If nothing appears to happen, or if ``^P`` is echoed, command line -editing isn't available; you'll only be able to use backspace to remove -characters from the current line. +The interpreter's line-editing features usually aren't very sophisticated. On +Unix, whoever installed the interpreter may have enabled support for the GNU +readline library, which adds more elaborate interactive editing and history +features. Perhaps the quickest check to see whether command line editing is +supported is typing Control-P to the first Python prompt you get. If it beeps, +you have command line editing; see Appendix :ref:`tut-interacting` for an +introduction to the keys. If nothing appears to happen, or if ``^P`` is echoed, +command line editing isn't available; you'll only be able to use backspace to +remove characters from the current line. The interpreter operates somewhat like the Unix shell: when called with standard input connected to a tty device, it reads and executes commands interactively; @@ -105,7 +106,7 @@ Continuation lines are needed when entering a multi-line construct. As an example, take a look at this :keyword:`if` statement:: - >>> the_world_is_flat = True + >>> the_world_is_flat = 1 >>> if the_world_is_flat: ... print("Be careful not to fall off!") ... diff -r ce070040e1a6 -r d7f128afe9db Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst Sat May 10 13:24:58 2014 -0400 +++ b/Doc/whatsnew/3.5.rst Sun Mar 23 09:44:28 2014 +0100 @@ -134,45 +134,16 @@ Improved Modules ================ -* Different constants of :mod:`signal` module are now enumeration values using - the :mod:`enum` module. This allows meaningful names to be printed during - debugging, instead of integer “magic numbers”. (contribute by Giampaolo - Rodola' in :issue:`21076`) - * :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager` (contributed by Claudiu Popa in :issue:`20627`). -* :class:`inspect.Signature` and :class:`inspect.Parameter` are now - picklable and hashable (contributed by Yury Selivanov in :issue:`20726` - and :issue:`20334`). - -* New class method :meth:`inspect.Signature.from_callable`, which makes - subclassing of :class:`~inspect.Signature` easier (contributed - by Yury Selivanov and Eric Snow in :issue:`17373`). - -* :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in - applications where startup time is paramount (contributed by Brett Cannon in - :issue:`17621`). - -* :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if - *module* contains no docstrings instead of raising :exc:`ValueError` - (contributed by Glenn Jones in :issue:`15916`). - -* :func:`importlib.abc.InspectLoader.source_to_code` is now a - static method to make it easier to work with source code in a string. - With a module object that you want to initialize you can then use - ``exec(code, module.__dict__)`` to execute the code in the module. - Optimizations ============= Major performance enhancements have been added: -* Construction of ``bytes(int)`` and ``bytearray(int)`` (filled by zero bytes) - is faster and use less memory (until the bytearray buffer is filled with - data) for large objects. ``calloc()`` is used instead of ``malloc()`` to - allocate memory for these objects. +* None yet. Build and C API Changes @@ -180,12 +151,7 @@ Changes to Python's build process and to the C API include: -* New ``calloc`` functions: - - * :c:func:`PyMem_RawCalloc` - * :c:func:`PyMem_Calloc` - * :c:func:`PyObject_Calloc` - * :c:func:`_PyObject_GC_Calloc` +* None yet. Deprecated @@ -222,19 +188,13 @@ This section lists previously described changes and other bugfixes that may require changes to your code. -Changes in the Python API -------------------------- - * Before Python 3.5, a :class:`datetime.time` object was considered to be false if it represented midnight in UTC. This behavior was considered obscure and error-prone and has been removed in Python 3.5. See :issue:`13936` for full details. -* :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError` - or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation - would block. Previously, it would return 0. See :issue:`20951`. - -Changes in the C API --------------------- - -* The :c:type:`PyMemAllocator` structure has a new ``calloc`` field. +* :meth:`unittest.TestCase.assertRaisesRegex` and + :meth:`~unittest.TestCase.assertWarnsRegex` now raise a :exc:`TypeError` if + the second argument is not a string or a compiled :mod:`regex`. You may have + tests with an invalid second argument that have until 3.5 been falsely + passing which will now raise TypeErrors (:issue:`20145`). diff -r ce070040e1a6 -r d7f128afe9db Grammar/Grammar --- a/Grammar/Grammar Sat May 10 13:24:58 2014 -0400 +++ b/Grammar/Grammar Sun Mar 23 09:44:28 2014 +0100 @@ -40,7 +40,7 @@ expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*) testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] -augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' | +augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') # For normal assignments, additional restrictions enforced by the interpreter del_stmt: 'del' exprlist @@ -97,7 +97,7 @@ and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* -term: factor (('*'|'@'|'/'|'%'|'//') factor)* +term: factor (('*'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power power: atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_comp] ')' | diff -r ce070040e1a6 -r d7f128afe9db Include/Python-ast.h --- a/Include/Python-ast.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/Python-ast.h Sun Mar 23 09:44:28 2014 +0100 @@ -15,9 +15,9 @@ typedef enum _boolop { And=1, Or=2 } boolop_ty; -typedef enum _operator { Add=1, Sub=2, Mult=3, MatMult=4, Div=5, Mod=6, Pow=7, - LShift=8, RShift=9, BitOr=10, BitXor=11, BitAnd=12, - FloorDiv=13 } operator_ty; +typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7, + RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 } + operator_ty; typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; diff -r ce070040e1a6 -r d7f128afe9db Include/abstract.h --- a/Include/abstract.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/abstract.h Sun Mar 23 09:44:28 2014 +0100 @@ -658,12 +658,6 @@ o1*o2. */ - PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2); - - /* - This is the equivalent of the Python expression: o1 @ o2. - */ - PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); /* @@ -838,12 +832,6 @@ o1 *= o2. */ - PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2); - - /* - This is the equivalent of the Python expression: o1 @= o2. - */ - PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2); @@ -1033,7 +1021,7 @@ PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); /* - Return the sequence, o, as a list, unless it's already a + Returns the sequence, o, as a list, unless it's already a tuple or list. Use PySequence_Fast_GET_ITEM to access the members of this list, and PySequence_Fast_GET_SIZE to get its length. diff -r ce070040e1a6 -r d7f128afe9db Include/code.h --- a/Include/code.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/code.h Sun Mar 23 09:44:28 2014 +0100 @@ -21,12 +21,7 @@ PyObject *co_varnames; /* tuple of strings (local variable names) */ PyObject *co_freevars; /* tuple of strings (free variable names) */ PyObject *co_cellvars; /* tuple of strings (cell variable names) */ - /* The rest aren't used in either hash or comparisons, except for - co_name (used in both) and co_firstlineno (used only in - comparisons). This is done to preserve the name and line number - for tracebacks and debuggers; otherwise, constant de-duplication - would collapse identical functions/lambdas defined on different lines. - */ + /* The rest doesn't count for hash or comparisons */ unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */ PyObject *co_filename; /* unicode (where it was loaded from) */ PyObject *co_name; /* unicode (name, for reference) */ diff -r ce070040e1a6 -r d7f128afe9db Include/dictobject.h --- a/Include/dictobject.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/dictobject.h Sun Mar 23 09:44:28 2014 +0100 @@ -50,10 +50,6 @@ PyAPI_FUNC(PyObject *) PyDict_New(void); PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); -#ifndef Py_LIMITED_API -PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key, - Py_hash_t hash); -#endif PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key); PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp, struct _Py_Identifier *key); @@ -62,10 +58,6 @@ PyObject *mp, PyObject *key, PyObject *defaultobj); #endif PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); -#ifndef Py_LIMITED_API -PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key, - PyObject *item, Py_hash_t hash); -#endif PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); PyAPI_FUNC(int) PyDict_Next( diff -r ce070040e1a6 -r d7f128afe9db Include/object.h --- a/Include/object.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/object.h Sun Mar 23 09:44:28 2014 +0100 @@ -275,9 +275,6 @@ binaryfunc nb_inplace_true_divide; unaryfunc nb_index; - - binaryfunc nb_matrix_multiply; - binaryfunc nb_inplace_matrix_multiply; } PyNumberMethods; typedef struct { diff -r ce070040e1a6 -r d7f128afe9db Include/objimpl.h --- a/Include/objimpl.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/objimpl.h Sun Mar 23 09:44:28 2014 +0100 @@ -95,7 +95,6 @@ the raw memory. */ PyAPI_FUNC(void *) PyObject_Malloc(size_t size); -PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize); PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size); PyAPI_FUNC(void) PyObject_Free(void *ptr); @@ -322,8 +321,7 @@ (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj))) #endif /* Py_LIMITED_API */ -PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size); -PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size); +PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t); PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); PyAPI_FUNC(void) PyObject_GC_Track(void *); diff -r ce070040e1a6 -r d7f128afe9db Include/opcode.h --- a/Include/opcode.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/opcode.h Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,3 @@ -/* Auto-generated by Tools/scripts/generate_opcode_h.py */ #ifndef Py_OPCODE_H #define Py_OPCODE_H #ifdef __cplusplus @@ -6,111 +5,141 @@ #endif - /* Instruction opcodes for compiled code */ -#define POP_TOP 1 -#define ROT_TWO 2 -#define ROT_THREE 3 -#define DUP_TOP 4 -#define DUP_TOP_TWO 5 -#define NOP 9 -#define UNARY_POSITIVE 10 -#define UNARY_NEGATIVE 11 -#define UNARY_NOT 12 -#define UNARY_INVERT 15 -#define BINARY_MATRIX_MULTIPLY 16 -#define INPLACE_MATRIX_MULTIPLY 17 -#define BINARY_POWER 19 -#define BINARY_MULTIPLY 20 -#define BINARY_MODULO 22 -#define BINARY_ADD 23 -#define BINARY_SUBTRACT 24 -#define BINARY_SUBSCR 25 -#define BINARY_FLOOR_DIVIDE 26 -#define BINARY_TRUE_DIVIDE 27 -#define INPLACE_FLOOR_DIVIDE 28 -#define INPLACE_TRUE_DIVIDE 29 -#define STORE_MAP 54 -#define INPLACE_ADD 55 -#define INPLACE_SUBTRACT 56 -#define INPLACE_MULTIPLY 57 -#define INPLACE_MODULO 59 -#define STORE_SUBSCR 60 -#define DELETE_SUBSCR 61 -#define BINARY_LSHIFT 62 -#define BINARY_RSHIFT 63 -#define BINARY_AND 64 -#define BINARY_XOR 65 -#define BINARY_OR 66 -#define INPLACE_POWER 67 -#define GET_ITER 68 -#define PRINT_EXPR 70 -#define LOAD_BUILD_CLASS 71 -#define YIELD_FROM 72 -#define INPLACE_LSHIFT 75 -#define INPLACE_RSHIFT 76 -#define INPLACE_AND 77 -#define INPLACE_XOR 78 -#define INPLACE_OR 79 -#define BREAK_LOOP 80 -#define WITH_CLEANUP 81 -#define RETURN_VALUE 83 -#define IMPORT_STAR 84 -#define YIELD_VALUE 86 -#define POP_BLOCK 87 -#define END_FINALLY 88 -#define POP_EXCEPT 89 -#define HAVE_ARGUMENT 90 -#define STORE_NAME 90 -#define DELETE_NAME 91 -#define UNPACK_SEQUENCE 92 -#define FOR_ITER 93 -#define UNPACK_EX 94 -#define STORE_ATTR 95 -#define DELETE_ATTR 96 -#define STORE_GLOBAL 97 -#define DELETE_GLOBAL 98 -#define LOAD_CONST 100 -#define LOAD_NAME 101 -#define BUILD_TUPLE 102 -#define BUILD_LIST 103 -#define BUILD_SET 104 -#define BUILD_MAP 105 -#define LOAD_ATTR 106 -#define COMPARE_OP 107 -#define IMPORT_NAME 108 -#define IMPORT_FROM 109 -#define JUMP_FORWARD 110 -#define JUMP_IF_FALSE_OR_POP 111 -#define JUMP_IF_TRUE_OR_POP 112 -#define JUMP_ABSOLUTE 113 -#define POP_JUMP_IF_FALSE 114 -#define POP_JUMP_IF_TRUE 115 -#define LOAD_GLOBAL 116 -#define CONTINUE_LOOP 119 -#define SETUP_LOOP 120 -#define SETUP_EXCEPT 121 -#define SETUP_FINALLY 122 -#define LOAD_FAST 124 -#define STORE_FAST 125 -#define DELETE_FAST 126 -#define RAISE_VARARGS 130 -#define CALL_FUNCTION 131 -#define MAKE_FUNCTION 132 -#define BUILD_SLICE 133 -#define MAKE_CLOSURE 134 -#define LOAD_CLOSURE 135 -#define LOAD_DEREF 136 -#define STORE_DEREF 137 -#define DELETE_DEREF 138 -#define CALL_FUNCTION_VAR 140 -#define CALL_FUNCTION_KW 141 -#define CALL_FUNCTION_VAR_KW 142 -#define SETUP_WITH 143 -#define EXTENDED_ARG 144 -#define LIST_APPEND 145 -#define SET_ADD 146 -#define MAP_ADD 147 -#define LOAD_CLASSDEREF 148 +/* Instruction opcodes for compiled code */ + +#define POP_TOP 1 +#define ROT_TWO 2 +#define ROT_THREE 3 +#define DUP_TOP 4 +#define DUP_TOP_TWO 5 +#define NOP 9 + +#define UNARY_POSITIVE 10 +#define UNARY_NEGATIVE 11 +#define UNARY_NOT 12 + +#define UNARY_INVERT 15 + +#define BINARY_POWER 19 + +#define BINARY_MULTIPLY 20 + +#define BINARY_MODULO 22 +#define BINARY_ADD 23 +#define BINARY_SUBTRACT 24 +#define BINARY_SUBSCR 25 +#define BINARY_FLOOR_DIVIDE 26 +#define BINARY_TRUE_DIVIDE 27 +#define INPLACE_FLOOR_DIVIDE 28 +#define INPLACE_TRUE_DIVIDE 29 + +#define STORE_MAP 54 +#define INPLACE_ADD 55 +#define INPLACE_SUBTRACT 56 +#define INPLACE_MULTIPLY 57 + +#define INPLACE_MODULO 59 +#define STORE_SUBSCR 60 +#define DELETE_SUBSCR 61 + +#define BINARY_LSHIFT 62 +#define BINARY_RSHIFT 63 +#define BINARY_AND 64 +#define BINARY_XOR 65 +#define BINARY_OR 66 +#define INPLACE_POWER 67 +#define GET_ITER 68 +#define PRINT_EXPR 70 +#define LOAD_BUILD_CLASS 71 +#define YIELD_FROM 72 + +#define INPLACE_LSHIFT 75 +#define INPLACE_RSHIFT 76 +#define INPLACE_AND 77 +#define INPLACE_XOR 78 +#define INPLACE_OR 79 +#define BREAK_LOOP 80 +#define WITH_CLEANUP 81 + +#define RETURN_VALUE 83 +#define IMPORT_STAR 84 + +#define YIELD_VALUE 86 +#define POP_BLOCK 87 +#define END_FINALLY 88 +#define POP_EXCEPT 89 + +#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ + +#define STORE_NAME 90 /* Index in name list */ +#define DELETE_NAME 91 /* "" */ +#define UNPACK_SEQUENCE 92 /* Number of sequence items */ +#define FOR_ITER 93 +#define UNPACK_EX 94 /* Num items before variable part + + (Num items after variable part << 8) */ + +#define STORE_ATTR 95 /* Index in name list */ +#define DELETE_ATTR 96 /* "" */ +#define STORE_GLOBAL 97 /* "" */ +#define DELETE_GLOBAL 98 /* "" */ + +#define LOAD_CONST 100 /* Index in const list */ +#define LOAD_NAME 101 /* Index in name list */ +#define BUILD_TUPLE 102 /* Number of tuple items */ +#define BUILD_LIST 103 /* Number of list items */ +#define BUILD_SET 104 /* Number of set items */ +#define BUILD_MAP 105 /* Always zero for now */ +#define LOAD_ATTR 106 /* Index in name list */ +#define COMPARE_OP 107 /* Comparison operator */ +#define IMPORT_NAME 108 /* Index in name list */ +#define IMPORT_FROM 109 /* Index in name list */ + +#define JUMP_FORWARD 110 /* Number of bytes to skip */ +#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning of code */ +#define JUMP_IF_TRUE_OR_POP 112 /* "" */ +#define JUMP_ABSOLUTE 113 /* "" */ +#define POP_JUMP_IF_FALSE 114 /* "" */ +#define POP_JUMP_IF_TRUE 115 /* "" */ + +#define LOAD_GLOBAL 116 /* Index in name list */ + +#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ +#define SETUP_LOOP 120 /* Target address (relative) */ +#define SETUP_EXCEPT 121 /* "" */ +#define SETUP_FINALLY 122 /* "" */ + +#define LOAD_FAST 124 /* Local variable number */ +#define STORE_FAST 125 /* Local variable number */ +#define DELETE_FAST 126 /* Local variable number */ + +#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ +/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ +#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ +#define MAKE_FUNCTION 132 /* #defaults + #kwdefaults<<8 + #annotations<<16 */ +#define BUILD_SLICE 133 /* Number of items */ + +#define MAKE_CLOSURE 134 /* same as MAKE_FUNCTION */ +#define LOAD_CLOSURE 135 /* Load free variable from closure */ +#define LOAD_DEREF 136 /* Load and dereference from closure cell */ +#define STORE_DEREF 137 /* Store into cell */ +#define DELETE_DEREF 138 /* Delete closure cell */ + +/* The next 3 opcodes must be contiguous and satisfy + (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ +#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ + +#define SETUP_WITH 143 + +/* Support for opargs more than 16 bits long */ +#define EXTENDED_ARG 144 + +#define LIST_APPEND 145 +#define SET_ADD 146 +#define MAP_ADD 147 + +#define LOAD_CLASSDEREF 148 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here @@ -119,9 +148,8 @@ #define EXCEPT_HANDLER 257 -enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, - PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, - PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; +enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, + PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) diff -r ce070040e1a6 -r d7f128afe9db Include/pymem.h --- a/Include/pymem.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/pymem.h Sun Mar 23 09:44:28 2014 +0100 @@ -13,7 +13,6 @@ #ifndef Py_LIMITED_API PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size); -PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize); PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size); PyAPI_FUNC(void) PyMem_RawFree(void *ptr); #endif @@ -58,7 +57,6 @@ */ PyAPI_FUNC(void *) PyMem_Malloc(size_t size); -PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size); PyAPI_FUNC(void) PyMem_Free(void *ptr); @@ -134,9 +132,6 @@ /* allocate a memory block */ void* (*malloc) (void *ctx, size_t size); - /* allocate a memory block initialized by zeros */ - void* (*calloc) (void *ctx, size_t nelem, size_t elsize); - /* allocate or resize a memory block */ void* (*realloc) (void *ctx, void *ptr, size_t new_size); diff -r ce070040e1a6 -r d7f128afe9db Include/pyport.h --- a/Include/pyport.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/pyport.h Sun Mar 23 09:44:28 2014 +0100 @@ -588,25 +588,6 @@ } while (0) #endif -#ifdef HAVE_GCC_ASM_FOR_MC68881 -#define HAVE_PY_SET_53BIT_PRECISION 1 -#define _Py_SET_53BIT_PRECISION_HEADER \ - unsigned int old_fpcr, new_fpcr -#define _Py_SET_53BIT_PRECISION_START \ - do { \ - __asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \ - /* Set double precision / round to nearest. */ \ - new_fpcr = (old_fpcr & ~0xf0) | 0x80; \ - if (new_fpcr != old_fpcr) \ - __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr)); \ - } while (0) -#define _Py_SET_53BIT_PRECISION_END \ - do { \ - if (new_fpcr != old_fpcr) \ - __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \ - } while (0) -#endif - /* default definitions are empty */ #ifndef HAVE_PY_SET_53BIT_PRECISION #define _Py_SET_53BIT_PRECISION_HEADER diff -r ce070040e1a6 -r d7f128afe9db Include/token.h --- a/Include/token.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/token.h Sun Mar 23 09:44:28 2014 +0100 @@ -58,14 +58,13 @@ #define DOUBLESTAREQUAL 46 #define DOUBLESLASH 47 #define DOUBLESLASHEQUAL 48 -#define AT 49 -#define ATEQUAL 50 -#define RARROW 51 -#define ELLIPSIS 52 +#define AT 49 +#define RARROW 50 +#define ELLIPSIS 51 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 53 -#define ERRORTOKEN 54 -#define N_TOKENS 55 +#define OP 52 +#define ERRORTOKEN 53 +#define N_TOKENS 54 /* Special definitions for cooperation with parser */ diff -r ce070040e1a6 -r d7f128afe9db Include/typeslots.h --- a/Include/typeslots.h Sat May 10 13:24:58 2014 -0400 +++ b/Include/typeslots.h Sun Mar 23 09:44:28 2014 +0100 @@ -74,5 +74,3 @@ #define Py_tp_members 72 #define Py_tp_getset 73 #define Py_tp_free 74 -#define Py_nb_matrix_multiply 75 -#define Py_nb_inplace_matrix_multiply 76 diff -r ce070040e1a6 -r d7f128afe9db Lib/_collections_abc.py --- a/Lib/_collections_abc.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/_collections_abc.py Sun Mar 23 09:44:28 2014 +0100 @@ -440,8 +440,6 @@ class MappingView(Sized): - __slots__ = '_mapping', - def __init__(self, mapping): self._mapping = mapping @@ -454,8 +452,6 @@ class KeysView(MappingView, Set): - __slots__ = () - @classmethod def _from_iterable(self, it): return set(it) @@ -471,8 +467,6 @@ class ItemsView(MappingView, Set): - __slots__ = () - @classmethod def _from_iterable(self, it): return set(it) @@ -495,8 +489,6 @@ class ValuesView(MappingView): - __slots__ = () - def __contains__(self, value): for key in self._mapping: if value == self._mapping[key]: diff -r ce070040e1a6 -r d7f128afe9db Lib/_osx_support.py --- a/Lib/_osx_support.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/_osx_support.py Sun Mar 23 09:44:28 2014 +0100 @@ -182,7 +182,7 @@ # Compiler is GCC, check if it is LLVM-GCC data = _read_output("'%s' --version" % (cc.replace("'", "'\"'\"'"),)) - if data and 'llvm-gcc' in data: + if 'llvm-gcc' in data: # Found LLVM-GCC, fall back to clang cc = _find_build_tool('clang') diff -r ce070040e1a6 -r d7f128afe9db Lib/_sitebuiltins.py --- a/Lib/_sitebuiltins.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/_sitebuiltins.py Sun Mar 23 09:44:28 2014 +0100 @@ -87,12 +87,8 @@ class _Helper(object): """Define the builtin 'help'. + This is a wrapper around pydoc.help (with a twist). - This is a wrapper around pydoc.help that provides a helpful message - when 'help' is typed at the Python interactive prompt. - - Calling help() at the Python prompt starts an interactive help session. - Calling help(thing) prints help for the python object 'thing'. """ def __repr__(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/asyncio/events.py --- a/Lib/asyncio/events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/asyncio/events.py Sun Mar 23 09:44:28 2014 +0100 @@ -16,7 +16,7 @@ class Handle: """Object returned by callback registration methods.""" - __slots__ = ['_callback', '_args', '_cancelled', '_loop', '__weakref__'] + __slots__ = ['_callback', '_args', '_cancelled', '_loop'] def __init__(self, callback, args, loop): assert not isinstance(callback, Handle), 'A Handle is not a callback' diff -r ce070040e1a6 -r d7f128afe9db Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/asyncio/selector_events.py Sun Mar 23 09:44:28 2014 +0100 @@ -87,17 +87,10 @@ pass def _write_to_self(self): - # This may be called from a different thread, possibly after - # _close_self_pipe() has been called or even while it is - # running. Guard for self._csock being None or closed. When - # a socket is closed, send() raises OSError (with errno set to - # EBADF, but let's not rely on the exact error code). - csock = self._csock - if csock is not None: - try: - csock.send(b'x') - except OSError: - pass + try: + self._csock.send(b'x') + except (BlockingIOError, InterruptedError): + pass def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None): diff -r ce070040e1a6 -r d7f128afe9db Lib/asyncio/tasks.py --- a/Lib/asyncio/tasks.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/asyncio/tasks.py Sun Mar 23 09:44:28 2014 +0100 @@ -36,7 +36,7 @@ class CoroWrapper: # Wrapper for coroutine in _DEBUG mode. - __slots__ = ['gen', 'func', '__name__', '__doc__', '__weakref__'] + __slots__ = ['gen', 'func', '__name__', '__doc__'] def __init__(self, gen, func): assert inspect.isgenerator(gen), gen @@ -49,12 +49,7 @@ def __next__(self): return next(self.gen) - def send(self, *value): - # We use `*value` because of a bug in CPythons prior - # to 3.4.1. See issue #21209 and test_yield_from_corowrapper - # for details. This workaround should be removed in 3.5.0. - if len(value) == 1: - value = value[0] + def send(self, value): return self.gen.send(value) def throw(self, exc): @@ -63,22 +58,8 @@ def close(self): return self.gen.close() - @property - def gi_frame(self): - return self.gen.gi_frame - - @property - def gi_running(self): - return self.gen.gi_running - - @property - def gi_code(self): - return self.gen.gi_code - def __del__(self): - # Be careful accessing self.gen.frame -- self.gen might not exist. - gen = getattr(self, 'gen', None) - frame = getattr(gen, 'gi_frame', None) + frame = self.gen.gi_frame if frame is not None and frame.f_lasti == -1: func = self.func code = func.__code__ @@ -269,25 +250,6 @@ print(line, file=file, end='') def cancel(self): - """Request that a task to cancel itself. - - This arranges for a CancellationError to be thrown into the - wrapped coroutine on the next cycle through the event loop. - The coroutine then has a chance to clean up or even deny - the request using try/except/finally. - - Contrary to Future.cancel(), this does not guarantee that the - task will be cancelled: the exception might be caught and - acted upon, delaying cancellation of the task or preventing it - completely. The task may also return a value or raise a - different exception. - - Immediately after this method is called, Task.cancelled() will - not return True (unless the task was already cancelled). A - task will be marked as cancelled when the wrapped coroutine - terminates with a CancelledError exception (even if cancel() - was not called). - """ if self.done(): return False if self._fut_waiter is not None: diff -r ce070040e1a6 -r d7f128afe9db Lib/asyncio/unix_events.py --- a/Lib/asyncio/unix_events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/asyncio/unix_events.py Sun Mar 23 09:44:28 2014 +0100 @@ -206,10 +206,6 @@ raise TypeError('ssl argument must be an SSLContext or None') if path is not None: - if sock is not None: - raise ValueError( - 'path and sock can not be specified at the same time') - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: diff -r ce070040e1a6 -r d7f128afe9db Lib/asyncore.py --- a/Lib/asyncore.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/asyncore.py Sun Mar 23 09:44:28 2014 +0100 @@ -404,6 +404,20 @@ if why.args[0] not in (ENOTCONN, EBADF): raise + # cheap inheritance, used to pass all other attribute + # references to the underlying socket object. + def __getattr__(self, attr): + try: + retattr = getattr(self.socket, attr) + except AttributeError: + raise AttributeError("%s instance has no attribute '%s'" + %(self.__class__.__name__, attr)) + else: + msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \ + "instead" % {'me' : self.__class__.__name__, 'attr' : attr} + warnings.warn(msg, DeprecationWarning, stacklevel=2) + return retattr + # log and log_info may be overridden to provide more sophisticated # logging and warning methods. In general, log is for 'hit' logging # and 'log_info' is for informational, warning and error logging. diff -r ce070040e1a6 -r d7f128afe9db Lib/cgi.py --- a/Lib/cgi.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/cgi.py Sun Mar 23 09:44:28 2014 +0100 @@ -1045,7 +1045,7 @@ return s -def valid_boundary(s): +def valid_boundary(s, _vb_pattern=None): import re if isinstance(s, bytes): _vb_pattern = b"^[ -~]{0,200}[!-~]$" diff -r ce070040e1a6 -r d7f128afe9db Lib/collections/__init__.py --- a/Lib/collections/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/collections/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -20,23 +20,6 @@ ### OrderedDict ################################################################################ -class _OrderedDictKeysView(KeysView): - - def __reversed__(self): - yield from reversed(self._mapping) - -class _OrderedDictItemsView(ItemsView): - - def __reversed__(self): - for key in reversed(self._mapping): - yield (key, self._mapping[key]) - -class _OrderedDictValuesView(ValuesView): - - def __reversed__(self): - for key in reversed(self._mapping): - yield self._mapping[key] - class _Link(object): __slots__ = 'prev', 'next', 'key', '__weakref__' @@ -96,8 +79,6 @@ link_next = link.next link_prev.next = link_next link_next.prev = link_prev - link.prev = None - link.next = None def __iter__(self): 'od.__iter__() <==> iter(od)' @@ -181,19 +162,9 @@ return size update = __update = MutableMapping.update - - def keys(self): - "D.keys() -> a set-like object providing a view on D's keys" - return _OrderedDictKeysView(self) - - def items(self): - "D.items() -> a set-like object providing a view on D's items" - return _OrderedDictItemsView(self) - - def values(self): - "D.values() -> an object providing a view on D's values" - return _OrderedDictValuesView(self) - + keys = MutableMapping.keys + values = MutableMapping.values + items = MutableMapping.items __ne__ = MutableMapping.__ne__ __marker = object() diff -r ce070040e1a6 -r d7f128afe9db Lib/copy.py --- a/Lib/copy.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/copy.py Sun Mar 23 09:44:28 2014 +0100 @@ -221,15 +221,17 @@ d[list] = _deepcopy_list def _deepcopy_tuple(x, memo): - y = [deepcopy(a, memo) for a in x] + y = [] + for a in x: + y.append(deepcopy(a, memo)) # We're not going to put the tuple in the memo, but it's still important we # check for it, in case the tuple contains recursive mutable structures. try: return memo[id(x)] except KeyError: pass - for k, j in zip(x, y): - if k is not j: + for i in range(len(x)): + if x[i] is not y[i]: y = tuple(y) break else: diff -r ce070040e1a6 -r d7f128afe9db Lib/ctypes/test/test_macholib.py --- a/Lib/ctypes/test/test_macholib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/ctypes/test/test_macholib.py Sun Mar 23 09:44:28 2014 +0100 @@ -50,11 +50,8 @@ '/usr/lib/libSystem.B.dylib') result = find_lib('z') - # Issue #21093: dyld default search path includes $HOME/lib and - # /usr/local/lib before /usr/lib, which caused test failures if - # a local copy of libz exists in one of them. Now ignore the head - # of the path. - self.assertRegex(result, r".*/lib/libz\..*.*\.dylib") + self.assertTrue(result.startswith('/usr/lib/libz.1')) + self.assertTrue(result.endswith('.dylib')) self.assertEqual(find_lib('IOKit'), '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit') diff -r ce070040e1a6 -r d7f128afe9db Lib/dbm/dumb.py --- a/Lib/dbm/dumb.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/dbm/dumb.py Sun Mar 23 09:44:28 2014 +0100 @@ -118,14 +118,9 @@ sync = _commit - def _verify_open(self): - if self._index is None: - raise error('DBM object has already been closed') - def __getitem__(self, key): if isinstance(key, str): key = key.encode('utf-8') - self._verify_open() pos, siz = self._index[key] # may raise KeyError f = _io.open(self._datfile, 'rb') f.seek(pos) @@ -178,7 +173,6 @@ val = val.encode('utf-8') elif not isinstance(val, (bytes, bytearray)): raise TypeError("values must be bytes or strings") - self._verify_open() if key not in self._index: self._addkey(key, self._addval(val)) else: @@ -206,7 +200,6 @@ def __delitem__(self, key): if isinstance(key, str): key = key.encode('utf-8') - self._verify_open() # The blocks used by the associated value are lost. del self._index[key] # XXX It's unclear why we do a _commit() here (the code always @@ -216,26 +209,21 @@ self._commit() def keys(self): - self._verify_open() return list(self._index.keys()) def items(self): - self._verify_open() return [(key, self[key]) for key in self._index.keys()] def __contains__(self, key): if isinstance(key, str): key = key.encode('utf-8') - self._verify_open() return key in self._index def iterkeys(self): - self._verify_open() return iter(self._index.keys()) __iter__ = iterkeys def __len__(self): - self._verify_open() return len(self._index) def close(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/decimal.py --- a/Lib/decimal.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/decimal.py Sun Mar 23 09:44:28 2014 +0100 @@ -2523,7 +2523,7 @@ end -= 1 return _dec_from_triple(dup._sign, dup._int[:end], exp) - def quantize(self, exp, rounding=None, context=None): + def quantize(self, exp, rounding=None, context=None, watchexp=True): """Quantize self so its exponent is the same as that of exp. Similar to self._rescale(exp._exp) but with error checking. @@ -2546,6 +2546,16 @@ return context._raise_error(InvalidOperation, 'quantize with one INF') + # if we're not watching exponents, do a simple rescale + if not watchexp: + ans = self._rescale(exp._exp, rounding) + # raise Inexact and Rounded where appropriate + if ans._exp > self._exp: + context._raise_error(Rounded) + if ans != self: + context._raise_error(Inexact) + return ans + # exp._exp should be between Etiny and Emax if not (context.Etiny() <= exp._exp <= context.Emax): return context._raise_error(InvalidOperation, diff -r ce070040e1a6 -r d7f128afe9db Lib/distutils/command/upload.py --- a/Lib/distutils/command/upload.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/distutils/command/upload.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,21 +1,24 @@ -""" -distutils.command.upload +"""distutils.command.upload -Implements the Distutils 'upload' subcommand (upload package to a package -index). -""" +Implements the Distutils 'upload' subcommand (upload package to PyPI).""" -import os -import io +from distutils.errors import * +from distutils.core import PyPIRCCommand +from distutils.spawn import spawn +from distutils import log +import sys +import os, io +import socket import platform -import hashlib from base64 import standard_b64encode from urllib.request import urlopen, Request, HTTPError from urllib.parse import urlparse -from distutils.errors import DistutilsOptionError -from distutils.core import PyPIRCCommand -from distutils.spawn import spawn -from distutils import log + +# this keeps compatibility for 2.3 and 2.4 +if sys.version < "2.5": + from md5 import md5 +else: + from hashlib import md5 class upload(PyPIRCCommand): @@ -57,8 +60,7 @@ def run(self): if not self.distribution.dist_files: - msg = "No dist file created in earlier command" - raise DistutilsOptionError(msg) + raise DistutilsOptionError("No dist file created in earlier command") for command, pyversion, filename in self.distribution.dist_files: self.upload_file(command, pyversion, filename) @@ -101,10 +103,10 @@ 'content': (os.path.basename(filename),content), 'filetype': command, 'pyversion': pyversion, - 'md5_digest': hashlib.md5(content).hexdigest(), + 'md5_digest': md5(content).hexdigest(), # additional meta-data - 'metadata_version': '1.0', + 'metadata_version' : '1.0', 'summary': meta.get_description(), 'home_page': meta.get_url(), 'author': meta.get_contact(), @@ -147,7 +149,7 @@ for key, value in data.items(): title = '\nContent-Disposition: form-data; name="%s"' % key # handle multiple entries for the same name - if not isinstance(value, list): + if type(value) != type([]): value = [value] for value in value: if type(value) is tuple: @@ -165,15 +167,13 @@ body.write(b"\n") body = body.getvalue() - msg = "Submitting %s to %s" % (filename, self.repository) - self.announce(msg, log.INFO) + self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) # build the Request - headers = { - 'Content-type': 'multipart/form-data; boundary=%s' % boundary, - 'Content-length': str(len(body)), - 'Authorization': auth, - } + headers = {'Content-type': + 'multipart/form-data; boundary=%s' % boundary, + 'Content-length': str(len(body)), + 'Authorization': auth} request = Request(self.repository, data=body, headers=headers) diff -r ce070040e1a6 -r d7f128afe9db Lib/distutils/extension.py --- a/Lib/distutils/extension.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/distutils/extension.py Sun Mar 23 09:44:28 2014 +0100 @@ -131,14 +131,6 @@ msg = "Unknown Extension options: %s" % options warnings.warn(msg) - def __repr__(self): - return '<%s.%s(%r) at %#x>' % ( - self.__class__.__module__, - self.__class__.__name__, - self.name, - id(self)) - - def read_setup_file(filename): """Reads a Setup file and returns Extension instances.""" from distutils.sysconfig import (parse_makefile, expand_makefile_vars, diff -r ce070040e1a6 -r d7f128afe9db Lib/distutils/tests/support.py --- a/Lib/distutils/tests/support.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/distutils/tests/support.py Sun Mar 23 09:44:28 2014 +0100 @@ -207,4 +207,4 @@ cmd.library_dirs = [] else: name, equals, value = runshared.partition('=') - cmd.library_dirs = [d for d in value.split(os.pathsep) if d] + cmd.library_dirs = value.split(os.pathsep) diff -r ce070040e1a6 -r d7f128afe9db Lib/doctest.py --- a/Lib/doctest.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/doctest.py Sun Mar 23 09:44:28 2014 +0100 @@ -2376,6 +2376,15 @@ suite = _DocTestSuite() suite.addTest(SkipDocTestCase(module)) return suite + elif not tests: + # Why do we want to do this? Because it reveals a bug that might + # otherwise be hidden. + # It is probably a bug that this exception is not also raised if the + # number of doctest examples in tests is zero (i.e. if no doctest + # examples were found). However, we should probably not be raising + # an exception at all here, though it is too late to make this change + # for a maintenance release. See also issue #14649. + raise ValueError(module, "has no docstrings") tests.sort() suite = _DocTestSuite() diff -r ce070040e1a6 -r d7f128afe9db Lib/email/generator.py --- a/Lib/email/generator.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/email/generator.py Sun Mar 23 09:44:28 2014 +0100 @@ -51,9 +51,8 @@ by RFC 2822. The policy keyword specifies a policy object that controls a number of - aspects of the generator's operation. If no policy is specified, - the policy associated with the Message object passed to the - flatten method is used. + aspects of the generator's operation. The default policy maintains + backward compatibility. """ self._fp = outfp @@ -77,9 +76,7 @@ Note that for subobjects, no From_ line is printed. linesep specifies the characters used to indicate a new line in - the output. The default value is determined by the policy specified - when the Generator instance was created or, if none was specified, - from the policy associated with the msg. + the output. The default value is determined by the policy. """ # We use the _XXX constants for operating on data that comes directly diff -r ce070040e1a6 -r d7f128afe9db Lib/encodings/rot_13.py --- a/Lib/encodings/rot_13.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/encodings/rot_13.py Sun Mar 23 09:44:28 2014 +0100 @@ -106,7 +106,7 @@ ### Filter API def rot13(infile, outfile): - outfile.write(codecs.encode(infile.read(), 'rot-13')) + outfile.write(infile.read().encode('rot-13')) if __name__ == '__main__': import sys diff -r ce070040e1a6 -r d7f128afe9db Lib/filecmp.py --- a/Lib/filecmp.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/filecmp.py Sun Mar 23 09:44:28 2014 +0100 @@ -36,7 +36,7 @@ f2 -- Second file name shallow -- Just check stat signature (do not read the files). - defaults to True. + defaults to 1. Return value: diff -r ce070040e1a6 -r d7f128afe9db Lib/fractions.py --- a/Lib/fractions.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/fractions.py Sun Mar 23 09:44:28 2014 +0100 @@ -70,7 +70,7 @@ __slots__ = ('_numerator', '_denominator') # We're immutable, so use __new__ not __init__ - def __new__(cls, numerator=0, denominator=None, _normalize=True): + def __new__(cls, numerator=0, denominator=None): """Constructs a Rational. Takes a string like '3/2' or '1.5', another Rational instance, a @@ -165,12 +165,9 @@ if denominator == 0: raise ZeroDivisionError('Fraction(%s, 0)' % numerator) - if _normalize: - g = gcd(numerator, denominator) - numerator //= g - denominator //= g - self._numerator = numerator - self._denominator = denominator + g = gcd(numerator, denominator) + self._numerator = numerator // g + self._denominator = denominator // g return self @classmethod @@ -456,12 +453,10 @@ power = b.numerator if power >= 0: return Fraction(a._numerator ** power, - a._denominator ** power, - _normalize=False) + a._denominator ** power) else: return Fraction(a._denominator ** -power, - a._numerator ** -power, - _normalize=False) + a._numerator ** -power) else: # A fractional power will generally produce an # irrational number. @@ -485,15 +480,15 @@ def __pos__(a): """+a: Coerces a subclass instance to Fraction""" - return Fraction(a._numerator, a._denominator, _normalize=False) + return Fraction(a._numerator, a._denominator) def __neg__(a): """-a""" - return Fraction(-a._numerator, a._denominator, _normalize=False) + return Fraction(-a._numerator, a._denominator) def __abs__(a): """abs(a)""" - return Fraction(abs(a._numerator), a._denominator, _normalize=False) + return Fraction(abs(a._numerator), a._denominator) def __trunc__(a): """trunc(a)""" diff -r ce070040e1a6 -r d7f128afe9db Lib/getpass.py --- a/Lib/getpass.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/getpass.py Sun Mar 23 09:44:28 2014 +0100 @@ -135,13 +135,7 @@ input = sys.stdin prompt = str(prompt) if prompt: - try: - stream.write(prompt) - except UnicodeEncodeError: - # Use replace error handler to get as much as possible printed. - prompt = prompt.encode(stream.encoding, 'replace') - prompt = prompt.decode(stream.encoding) - stream.write(prompt) + stream.write(prompt) stream.flush() # NOTE: The Python C API calls flockfile() (and unlock) during readline. line = input.readline() diff -r ce070040e1a6 -r d7f128afe9db Lib/heapq.py --- a/Lib/heapq.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/heapq.py Sun Mar 23 09:44:28 2014 +0100 @@ -192,69 +192,12 @@ for i in reversed(range(n//2)): _siftup_max(x, i) - -# Algorithm notes for nlargest() and nsmallest() -# ============================================== -# -# Makes just one pass over the data while keeping the n most extreme values -# in a heap. Memory consumption is limited to keeping n values in a list. -# -# Number of comparisons for n random inputs, keeping the k smallest values: -# ----------------------------------------------------------- -# Step Comparisons Action -# 1 1.66*k heapify the first k-inputs -# 2 n - k compare new input elements to top of heap -# 3 k*lg2(k)*(ln(n)-ln(k)) add new extreme values to the heap -# 4 k*lg2(k) final sort of the k most extreme values -# -# number of comparisons -# n-random inputs k-extreme values average of 5 trials % more than min() -# --------------- ---------------- ------------------- ----------------- -# 10,000 100 14,046 40.5% -# 100,000 100 105,749 5.7% -# 1,000,000 100 1,007,751 0.8% -# -# Computing the number of comparisons for step 3: -# ----------------------------------------------- -# * For the i-th new value from the iterable, the probability of being in the -# k most extreme values is k/i. For example, the probability of the 101st -# value seen being in the 100 most extreme values is 100/101. -# * If the value is a new extreme value, the cost of inserting it into the -# heap is log(k, 2). -# * The probabilty times the cost gives: -# (k/i) * log(k, 2) -# * Summing across the remaining n-k elements gives: -# sum((k/i) * log(k, 2) for xrange(k+1, n+1)) -# * This reduces to: -# (H(n) - H(k)) * k * log(k, 2) -# * Where H(n) is the n-th harmonic number estimated by: -# H(n) = log(n, e) + gamma + 1.0 / (2.0 * n) -# gamma = 0.5772156649 -# http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#Rate_of_divergence -# * Substituting the H(n) formula and ignoring the (1/2*n) fraction gives: -# comparisons = k * log(k, 2) * (log(n,e) - log(k, e)) -# -# Worst-case for step 3: -# ---------------------- -# In the worst case, the input data is reversed sorted so that every new element -# must be inserted in the heap: -# comparisons = log(k, 2) * (n - k) -# -# Alternative Algorithms -# ---------------------- -# Other algorithms were not used because they: -# 1) Took much more auxiliary memory, -# 2) Made multiple passes over the data. -# 3) Made more comparisons in common cases (small k, large n, semi-random input). -# See detailed comparisons at: -# http://code.activestate.com/recipes/577573-compare-algorithms-for-heapqsmallest - def nlargest(n, iterable): """Find the n largest elements in a dataset. Equivalent to: sorted(iterable, reverse=True)[:n] """ - if n <= 0: + if n < 0: return [] it = iter(iterable) result = list(islice(it, n)) @@ -272,7 +215,7 @@ Equivalent to: sorted(iterable)[:n] """ - if n <= 0: + if n < 0: return [] it = iter(iterable) result = list(islice(it, n)) diff -r ce070040e1a6 -r d7f128afe9db Lib/http/client.py --- a/Lib/http/client.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/http/client.py Sun Mar 23 09:44:28 2014 +0100 @@ -811,30 +811,14 @@ self._tunnel_port = None self._tunnel_headers = {} - (self.host, self.port) = self._get_hostport(host, port) - - # This is stored as an instance variable to allow unit - # tests to replace it with a suitable mockup - self._create_connection = socket.create_connection + self._set_hostport(host, port) def set_tunnel(self, host, port=None, headers=None): - """Set up host and port for HTTP CONNECT tunnelling. + """ Sets up the host and the port for the HTTP CONNECT Tunnelling. - In a connection that uses HTTP CONNECT tunneling, the host passed to the - constructor is used as a proxy server that relays all communication to - the endpoint passed to `set_tunnel`. This done by sending an HTTP - CONNECT request to the proxy server when the connection is established. - - This method must be called before the HTML connection has been - established. - - The headers argument should be a mapping of extra HTTP headers to send - with the CONNECT request. + The headers argument should be a mapping of extra HTTP headers + to send with the CONNECT request. """ - - if self.sock: - raise RuntimeError("Can't set up tunnel for established connection") - self._tunnel_host = host self._tunnel_port = port if headers: @@ -842,7 +826,7 @@ else: self._tunnel_headers.clear() - def _get_hostport(self, host, port): + def _set_hostport(self, host, port): if port is None: i = host.rfind(':') j = host.rfind(']') # ipv6 addresses have [...] @@ -859,16 +843,15 @@ port = self.default_port if host and host[0] == '[' and host[-1] == ']': host = host[1:-1] - - return (host, port) + self.host = host + self.port = port def set_debuglevel(self, level): self.debuglevel = level def _tunnel(self): - (host, port) = self._get_hostport(self._tunnel_host, - self._tunnel_port) - connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (host, port) + self._set_hostport(self._tunnel_host, self._tunnel_port) + connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self.host, self.port) connect_bytes = connect_str.encode("ascii") self.send(connect_bytes) for header, value in self._tunnel_headers.items(): @@ -896,9 +879,8 @@ def connect(self): """Connect to the host and port specified in __init__.""" - self.sock = self._create_connection((self.host,self.port), - self.timeout, self.source_address) - + self.sock = socket.create_connection((self.host,self.port), + self.timeout, self.source_address) if self._tunnel_host: self._tunnel() @@ -1067,29 +1049,22 @@ netloc_enc = netloc.encode("idna") self.putheader('Host', netloc_enc) else: - if self._tunnel_host: - host = self._tunnel_host - port = self._tunnel_port - else: - host = self.host - port = self.port - try: - host_enc = host.encode("ascii") + host_enc = self.host.encode("ascii") except UnicodeEncodeError: - host_enc = host.encode("idna") + host_enc = self.host.encode("idna") # As per RFC 273, IPv6 address should be wrapped with [] # when used as Host header - if host.find(':') >= 0: + if self.host.find(':') >= 0: host_enc = b'[' + host_enc + b']' - if port == self.default_port: + if self.port == self.default_port: self.putheader('Host', host_enc) else: host_enc = host_enc.decode("ascii") - self.putheader('Host', "%s:%s" % (host_enc, port)) + self.putheader('Host', "%s:%s" % (host_enc, self.port)) # note: we are assuming that clients will not attempt to set these # headers since *this* library must deal with the @@ -1282,19 +1257,19 @@ def connect(self): "Connect to a host on a given (SSL) port." - super().connect() + sock = socket.create_connection((self.host, self.port), + self.timeout, self.source_address) if self._tunnel_host: - server_hostname = self._tunnel_host - else: - server_hostname = self.host - sni_hostname = server_hostname if ssl.HAS_SNI else None + self.sock = sock + self._tunnel() - self.sock = self._context.wrap_socket(self.sock, - server_hostname=sni_hostname) + server_hostname = self.host if ssl.HAS_SNI else None + self.sock = self._context.wrap_socket(sock, + server_hostname=server_hostname) if not self._context.check_hostname and self._check_hostname: try: - ssl.match_hostname(self.sock.getpeercert(), server_hostname) + ssl.match_hostname(self.sock.getpeercert(), self.host) except Exception: self.sock.shutdown(socket.SHUT_RDWR) self.sock.close() diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/Bindings.py --- a/Lib/idlelib/Bindings.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/Bindings.py Sun Mar 23 09:44:28 2014 +0100 @@ -8,14 +8,9 @@ windows. """ +import sys from idlelib.configHandler import idleConf - -# Warning: menudefs is altered in macosxSupport.overrideRootMenu() -# after it is determined that an OS X Aqua Tk is in use, -# which cannot be done until after Tk() is first called. -# Do not alter the 'file', 'options', or 'help' cascades here -# without altering overrideRootMenu() as well. -# TODO: Make this more robust +from idlelib import macosxSupport menudefs = [ # underscore prefixes character to underscore @@ -86,4 +81,27 @@ ]), ] +if macosxSupport.runningAsOSXApp(): + # Running as a proper MacOS application bundle. This block restructures + # the menus a little to make them conform better to the HIG. + + quitItem = menudefs[0][1][-1] + closeItem = menudefs[0][1][-2] + + # Remove the last 3 items of the file menu: a separator, close window and + # quit. Close window will be reinserted just above the save item, where + # it should be according to the HIG. Quit is in the application menu. + del menudefs[0][1][-3:] + menudefs[0][1].insert(6, closeItem) + + # Remove the 'About' entry from the help menu, it is in the application + # menu + del menudefs[-1][1][0:2] + + # Remove the 'Configure' entry from the options menu, it is in the + # application menu as 'Preferences' + del menudefs[-2][1][0:2] + default_keydefs = idleConf.GetCurrentKeySet() + +del sys diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/Debugger.py --- a/Lib/idlelib/Debugger.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/Debugger.py Sun Mar 23 09:44:28 2014 +0100 @@ -322,7 +322,7 @@ class StackViewer(ScrolledList): def __init__(self, master, flist, gui): - if macosxSupport.isAquaTk(): + if macosxSupport.runningAsOSXApp(): # At least on with the stock AquaTk version on OSX 10.4 you'll # get an shaking GUI that eventually kills IDLE if the width # argument is specified. diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/EditorWindow.py Sun Mar 23 09:44:28 2014 +0100 @@ -109,8 +109,8 @@ 'Python%s.chm' % _sphinx_version()) if os.path.isfile(chmfile): dochome = chmfile - elif sys.platform == 'darwin': - # documentation may be stored inside a python framework + elif macosxSupport.runningAsOSXApp(): + # documentation is stored inside the python framework dochome = os.path.join(sys.base_prefix, 'Resources/English.lproj/Documentation/index.html') dochome = os.path.normpath(dochome) @@ -166,7 +166,7 @@ self.top.protocol("WM_DELETE_WINDOW", self.close) self.top.bind("<>", self.close_event) - if macosxSupport.isAquaTk(): + if macosxSupport.runningAsOSXApp(): # Command-W on editorwindows doesn't work without this. text.bind('<>', self.close_event) # Some OS X systems have only one mouse button, @@ -409,7 +409,7 @@ def set_status_bar(self): self.status_bar = self.MultiStatusBar(self.top) - if sys.platform == "darwin": + if macosxSupport.runningAsOSXApp(): # Insert some padding to avoid obscuring some of the statusbar # by the resize widget. self.status_bar.set_label('_padding1', ' ', side=RIGHT) @@ -436,7 +436,7 @@ ("help", "_Help"), ] - if sys.platform == "darwin": + if macosxSupport.runningAsOSXApp(): menu_specs[-2] = ("windows", "_Window") @@ -447,7 +447,7 @@ underline, label = prepstr(label) menudict[name] = menu = Menu(mbar, name=name) mbar.add_cascade(label=label, menu=menu, underline=underline) - if macosxSupport.isCarbonTk(): + if macosxSupport.isCarbonAquaTk(self.root): # Insert the application menu menudict['application'] = menu = Menu(mbar, name='apple') mbar.add_cascade(label='IDLE', menu=menu) @@ -1673,7 +1673,7 @@ keylist = keydefs.get(eventname) # issue10940: temporary workaround to prevent hang with OS X Cocoa Tk 8.5 # if not keylist: - if (not keylist) or (macosxSupport.isCocoaTk() and eventname in { + if (not keylist) or (macosxSupport.runningAsOSXApp() and eventname in { "<>", "<>", "<>"}): diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/FormatParagraph.py --- a/Lib/idlelib/FormatParagraph.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/FormatParagraph.py Sun Mar 23 09:44:28 2014 +0100 @@ -32,7 +32,7 @@ def close(self): self.editwin = None - def format_paragraph_event(self, event, limit=None): + def format_paragraph_event(self, event): """Formats paragraph to a max width specified in idleConf. If text is selected, format_paragraph_event will start breaking lines @@ -41,12 +41,9 @@ If no text is selected, format_paragraph_event uses the current cursor location to determine the paragraph (lines of text surrounded by blank lines) and formats it. - - The length limit parameter is for testing with a known value. """ - if limit == None: - limit = idleConf.GetOption( - 'main', 'FormatParagraph', 'paragraph', type='int') + maxformatwidth = idleConf.GetOption( + 'main', 'FormatParagraph', 'paragraph', type='int') text = self.editwin.text first, last = self.editwin.get_selection_indices() if first and last: @@ -56,9 +53,9 @@ first, last, comment_header, data = \ find_paragraph(text, text.index("insert")) if comment_header: - newdata = reformat_comment(data, limit, comment_header) + newdata = reformat_comment(data, maxformatwidth, comment_header) else: - newdata = reformat_paragraph(data, limit) + newdata = reformat_paragraph(data, maxformatwidth) text.tag_remove("sel", "1.0", "end") if newdata != data: diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/MultiCall.py --- a/Lib/idlelib/MultiCall.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/MultiCall.py Sun Mar 23 09:44:28 2014 +0100 @@ -32,6 +32,7 @@ import sys import re import tkinter +from idlelib import macosxSupport # the event type constants, which define the meaning of mc_type MC_KEYPRESS=0; MC_KEYRELEASE=1; MC_BUTTONPRESS=2; MC_BUTTONRELEASE=3; @@ -44,7 +45,7 @@ MC_OPTION = 1<<6; MC_COMMAND = 1<<7 # define the list of modifiers, to be used in complex event types. -if sys.platform == "darwin": +if macosxSupport.runningAsOSXApp(): _modifiers = (("Shift",), ("Control",), ("Option",), ("Command",)) _modifier_masks = (MC_SHIFT, MC_CONTROL, MC_OPTION, MC_COMMAND) else: diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/PyShell.py Sun Mar 23 09:44:28 2014 +0100 @@ -844,7 +844,7 @@ ("help", "_Help"), ] - if sys.platform == "darwin": + if macosxSupport.runningAsOSXApp(): menu_specs[-2] = ("windows", "_Window") @@ -1560,7 +1560,7 @@ shell = flist.open_shell() if not shell: return # couldn't open shell - if macosxSupport.isAquaTk() and flist.dict: + if macosxSupport.runningAsOSXApp() and flist.dict: # On OSX: when the user has double-clicked on a file that causes # IDLE to be launched the shell window will open just in front of # the file she wants to see. Lower the interpreter window when diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/ScriptBinding.py --- a/Lib/idlelib/ScriptBinding.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/ScriptBinding.py Sun Mar 23 09:44:28 2014 +0100 @@ -53,7 +53,7 @@ self.flist = self.editwin.flist self.root = self.editwin.root - if macosxSupport.isCocoaTk(): + if macosxSupport.runningAsOSXApp(): self.editwin.text_frame.bind('<>', self._run_module_event) def check_module_event(self, event): @@ -114,7 +114,7 @@ shell.set_warning_stream(saved_stream) def run_module_event(self, event): - if macosxSupport.isCocoaTk(): + if macosxSupport.runningAsOSXApp(): # Tk-Cocoa in MacOSX is broken until at least # Tk 8.5.9, and without this rather # crude workaround IDLE would hang when a user diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/ZoomHeight.py --- a/Lib/idlelib/ZoomHeight.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/ZoomHeight.py Sun Mar 23 09:44:28 2014 +0100 @@ -32,7 +32,7 @@ newy = 0 newheight = newheight - 72 - elif macosxSupport.isAquaTk(): + elif macosxSupport.runningAsOSXApp(): # The '88' below is a magic number that avoids placing the bottom # of the window below the panel on my machine. I don't know how # to calculate the correct value for this with tkinter. diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/config-main.def --- a/Lib/idlelib/config-main.def Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/config-main.def Sun Mar 23 09:44:28 2014 +0100 @@ -59,7 +59,7 @@ encoding= none [FormatParagraph] -paragraph=72 +paragraph=70 [Indent] use-spaces= 1 diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/configDialog.py --- a/Lib/idlelib/configDialog.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/configDialog.py Sun Mar 23 09:44:28 2014 +0100 @@ -74,7 +74,7 @@ frameActionButtons = Frame(self,pady=2) #action buttons - if macosxSupport.isAquaTk(): + if macosxSupport.runningAsOSXApp(): # Surpress the padx and pady arguments when # running as IDLE.app, otherwise the text # on these buttons will not be readable. diff -r ce070040e1a6 -r d7f128afe9db Lib/idlelib/configHandler.py --- a/Lib/idlelib/configHandler.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/idlelib/configHandler.py Sun Mar 23 09:44:28 2014 +0100 @@ -20,6 +20,7 @@ import os import sys +from idlelib import macosxSupport from configparser import ConfigParser, NoOptionError, NoSectionError class InvalidConfigType(Exception): pass @@ -526,13 +527,10 @@ def GetCurrentKeySet(self): result = self.GetKeySet(self.CurrentKeys()) - if sys.platform == "darwin": - # OS X Tk variants do not support the "Alt" keyboard modifier. - # So replace all keybingings that use "Alt" with ones that - # use the "Option" keyboard modifier. - # TO DO: the "Option" modifier does not work properly for - # Cocoa Tk and XQuartz Tk so we should not use it - # in default OS X KeySets. + if macosxSupport.runningAsOSXApp(): + # We're using AquaTk, replace all keybingings that use the + # Alt key by ones that use the Option key because the former + # don't work reliably. for k, v in result.items(): v2 = [ x.replace('>'), ) - if isCocoaTk(): + else: + # assume Cocoa AquaTk # replace default About dialog with About IDLE one root.createcommand('tkAboutDialog', about_dialog) # replace default "Help" item in Help menu @@ -218,22 +182,10 @@ def setupApp(root, flist): """ - Perform initial OS X customizations if needed. - Called from PyShell.main() after initial calls to Tk() + Perform setup for the OSX application bundle. + """ + if not runningAsOSXApp(): return - There are currently three major versions of Tk in use on OS X: - 1. Aqua Cocoa Tk (native default since OS X 10.6) - 2. Aqua Carbon Tk (original native, 32-bit only, deprecated) - 3. X11 (supported by some third-party distributors, deprecated) - There are various differences among the three that affect IDLE - behavior, primarily with menus, mouse key events, and accelerators. - Some one-time customizations are performed here. - Others are dynamically tested throughout idlelib by calls to the - isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which - are initialized here as well. - """ - _initializeTkVariantTests(root) - if isAquaTk(): - hideTkConsole(root) - overrideRootMenu(root, flist) - addOpenEventSupport(root, flist) + hideTkConsole(root) + overrideRootMenu(root, flist) + addOpenEventSupport(root, flist) diff -r ce070040e1a6 -r d7f128afe9db Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/importlib/_bootstrap.py Sun Mar 23 09:44:28 2014 +0100 @@ -419,13 +419,12 @@ # Python 3.4a4 3290 (changes to __qualname__ computation) # Python 3.4a4 3300 (more changes to __qualname__ computation) # Python 3.4rc2 3310 (alter __qualname__ computation) -# Python 3.5a0 3320 (matrix multiplication operator) # # MAGIC must change whenever the bytecode emitted by the compiler may no # longer be understood by older implementations of the eval loop (usually # due to the addition of new opcodes). -MAGIC_NUMBER = (3320).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3310).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff -r ce070040e1a6 -r d7f128afe9db Lib/importlib/abc.py --- a/Lib/importlib/abc.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/importlib/abc.py Sun Mar 23 09:44:28 2014 +0100 @@ -217,8 +217,7 @@ """ raise ImportError - @staticmethod - def source_to_code(data, path=''): + def source_to_code(self, data, path=''): """Compile 'data' into a code object. The 'data' argument can be anything that compile() can handle. The'path' diff -r ce070040e1a6 -r d7f128afe9db Lib/importlib/util.py --- a/Lib/importlib/util.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/importlib/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,5 @@ """Utility code for constructing importers, etc.""" -from . import abc + from ._bootstrap import MAGIC_NUMBER from ._bootstrap import cache_from_source from ._bootstrap import decode_source @@ -12,7 +12,6 @@ from contextlib import contextmanager import functools import sys -import types import warnings @@ -201,94 +200,3 @@ return fxn(self, module, *args, **kwargs) return module_for_loader_wrapper - - -class _Module(types.ModuleType): - - """A subclass of the module type to allow __class__ manipulation.""" - - -class _LazyModule(types.ModuleType): - - """A subclass of the module type which triggers loading upon attribute access.""" - - def __getattribute__(self, attr): - """Trigger the load of the module and return the attribute.""" - # All module metadata must be garnered from __spec__ in order to avoid - # using mutated values. - # Stop triggering this method. - self.__class__ = _Module - # Get the original name to make sure no object substitution occurred - # in sys.modules. - original_name = self.__spec__.name - # Figure out exactly what attributes were mutated between the creation - # of the module and now. - attrs_then = self.__spec__.loader_state - attrs_now = self.__dict__ - attrs_updated = {} - for key, value in attrs_now.items(): - # Code that set the attribute may have kept a reference to the - # assigned object, making identity more important than equality. - if key not in attrs_then: - attrs_updated[key] = value - elif id(attrs_now[key]) != id(attrs_then[key]): - attrs_updated[key] = value - self.__spec__.loader.exec_module(self) - # If exec_module() was used directly there is no guarantee the module - # object was put into sys.modules. - if original_name in sys.modules: - if id(self) != id(sys.modules[original_name]): - msg = ('module object for {!r} substituted in sys.modules ' - 'during a lazy load') - raise ValueError(msg.format(original_name)) - # Update after loading since that's what would happen in an eager - # loading situation. - self.__dict__.update(attrs_updated) - return getattr(self, attr) - - def __delattr__(self, attr): - """Trigger the load and then perform the deletion.""" - # To trigger the load and raise an exception if the attribute - # doesn't exist. - self.__getattribute__(attr) - delattr(self, attr) - - -class LazyLoader(abc.Loader): - - """A loader that creates a module which defers loading until attribute access.""" - - @staticmethod - def __check_eager_loader(loader): - if not hasattr(loader, 'exec_module'): - raise TypeError('loader must define exec_module()') - elif hasattr(loader.__class__, 'create_module'): - if abc.Loader.create_module != loader.__class__.create_module: - # Only care if create_module() is overridden in a subclass of - # importlib.abc.Loader. - raise TypeError('loader cannot define create_module()') - - @classmethod - def factory(cls, loader): - """Construct a callable which returns the eager loader made lazy.""" - cls.__check_eager_loader(loader) - return lambda *args, **kwargs: cls(loader(*args, **kwargs)) - - def __init__(self, loader): - self.__check_eager_loader(loader) - self.loader = loader - - def create_module(self, spec): - """Create a module which can have its __class__ manipulated.""" - return _Module(spec.name) - - def exec_module(self, module): - """Make the module load lazily.""" - module.__spec__.loader = self.loader - module.__loader__ = self.loader - # Don't need to worry about deep-copying as trying to set an attribute - # on an object would have triggered the load, - # e.g. ``module.__spec__.loader = None`` would trigger a load from - # trying to access module.__spec__. - module.__spec__.loader_state = module.__dict__.copy() - module.__class__ = _LazyModule diff -r ce070040e1a6 -r d7f128afe9db Lib/inspect.py --- a/Lib/inspect.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/inspect.py Sun Mar 23 09:44:28 2014 +0100 @@ -17,7 +17,7 @@ getclasstree() - arrange classes so as to represent their hierarchy getargspec(), getargvalues(), getcallargs() - get info about function arguments - getfullargspec() - same, with support for Python 3 features + getfullargspec() - same, with support for Python-3000 features formatargspec(), formatargvalues() - format an argument spec getouterframes(), getinnerframes() - get info about frames currentframe() - get the current stack frame @@ -32,7 +32,6 @@ 'Yury Selivanov ') import ast -import enum import importlib.machinery import itertools import linecache @@ -920,7 +919,7 @@ 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'defaults' is an n-tuple of the default values of the last n arguments. - Use the getfullargspec() API for Python 3 code, as annotations + Use the getfullargspec() API for Python-3000 code, as annotations and keyword arguments are supported. getargspec() will raise ValueError if the func has either annotations or keyword arguments. """ @@ -967,10 +966,9 @@ # getfullargspec() historically ignored __wrapped__ attributes, # so we ensure that remains the case in 3.3+ - sig = _signature_from_callable(func, - follow_wrapper_chains=False, - skip_bound_arg=False, - sigcls=Signature) + sig = _signature_internal(func, + follow_wrapper_chains=False, + skip_bound_arg=False) except Exception as ex: # Most of the times 'signature' will raise ValueError. # But, it can also raise AttributeError, and, maybe something @@ -1127,7 +1125,7 @@ elif missing == 2: s = "{} and {}".format(*names) else: - tail = ", {} and {}".format(*names[-2:]) + tail = ", {} and {}".format(names[-2:]) del names[-2:] s = ", ".join(names) + tail raise TypeError("%s() missing %i required %s argument%s: %s" % @@ -1210,7 +1208,7 @@ missing = 0 for kwarg in kwonlyargs: if kwarg not in arg2value: - if kwonlydefaults and kwarg in kwonlydefaults: + if kwarg in kwonlydefaults: arg2value[kwarg] = kwonlydefaults[kwarg] else: missing += 1 @@ -1497,10 +1495,6 @@ def _signature_get_user_defined_method(cls, method_name): - """Private helper. Checks if ``cls`` has an attribute - named ``method_name`` and returns it only if it is a - pure python function. - """ try: meth = getattr(cls, method_name) except AttributeError: @@ -1513,13 +1507,11 @@ def _signature_get_partial(wrapped_sig, partial, extra_args=()): - """Private helper to calculate how 'wrapped_sig' signature will - look like after applying a 'functools.partial' object (or alike) - on it. - """ - - old_params = wrapped_sig.parameters - new_params = OrderedDict(old_params.items()) + # Internal helper to calculate how 'wrapped_sig' signature will + # look like after applying a 'functools.partial' object (or alike) + # on it. + + new_params = OrderedDict(wrapped_sig.parameters.items()) partial_args = partial.args or () partial_keywords = partial.keywords or {} @@ -1533,65 +1525,39 @@ msg = 'partial object {!r} has incorrect arguments'.format(partial) raise ValueError(msg) from ex - - transform_to_kwonly = False - for param_name, param in old_params.items(): - try: - arg_value = ba.arguments[param_name] - except KeyError: - pass - else: - if param.kind is _POSITIONAL_ONLY: - # If positional-only parameter is bound by partial, - # it effectively disappears from the signature - new_params.pop(param_name) - continue - - if param.kind is _POSITIONAL_OR_KEYWORD: - if param_name in partial_keywords: - # This means that this parameter, and all parameters - # after it should be keyword-only (and var-positional - # should be removed). Here's why. Consider the following - # function: - # foo(a, b, *args, c): - # pass - # - # "partial(foo, a='spam')" will have the following - # signature: "(*, a='spam', b, c)". Because attempting - # to call that partial with "(10, 20)" arguments will - # raise a TypeError, saying that "a" argument received - # multiple values. - transform_to_kwonly = True - # Set the new default value - new_params[param_name] = param.replace(default=arg_value) - else: - # was passed as a positional argument - new_params.pop(param.name) - continue - - if param.kind is _KEYWORD_ONLY: - # Set the new default value - new_params[param_name] = param.replace(default=arg_value) - - if transform_to_kwonly: - assert param.kind is not _POSITIONAL_ONLY - - if param.kind is _POSITIONAL_OR_KEYWORD: - new_param = new_params[param_name].replace(kind=_KEYWORD_ONLY) - new_params[param_name] = new_param - new_params.move_to_end(param_name) - elif param.kind in (_KEYWORD_ONLY, _VAR_KEYWORD): - new_params.move_to_end(param_name) - elif param.kind is _VAR_POSITIONAL: - new_params.pop(param.name) + for arg_name, arg_value in ba.arguments.items(): + param = new_params[arg_name] + if arg_name in partial_keywords: + # We set a new default value, because the following code + # is correct: + # + # >>> def foo(a): print(a) + # >>> print(partial(partial(foo, a=10), a=20)()) + # 20 + # >>> print(partial(partial(foo, a=10), a=20)(a=30)) + # 30 + # + # So, with 'partial' objects, passing a keyword argument is + # like setting a new default value for the corresponding + # parameter + # + # We also mark this parameter with '_partial_kwarg' + # flag. Later, in '_bind', the 'default' value of this + # parameter will be added to 'kwargs', to simulate + # the 'functools.partial' real call. + new_params[arg_name] = param.replace(default=arg_value, + _partial_kwarg=True) + + elif (param.kind not in (_VAR_KEYWORD, _VAR_POSITIONAL) and + not param._partial_kwarg): + new_params.pop(arg_name) return wrapped_sig.replace(parameters=new_params.values()) def _signature_bound_method(sig): - """Private helper to transform signatures for unbound - functions to bound methods. - """ + # Internal helper to transform signatures for unbound + # functions to bound methods params = tuple(sig.parameters.values()) @@ -1615,9 +1581,8 @@ def _signature_is_builtin(obj): - """Private helper to test if `obj` is a callable that might - support Argument Clinic's __text_signature__ protocol. - """ + # Internal helper to test if `obj` is a callable that might + # support Argument Clinic's __text_signature__ protocol. return (isbuiltin(obj) or ismethoddescriptor(obj) or isinstance(obj, _NonUserDefinedCallables) or @@ -1627,11 +1592,10 @@ def _signature_is_functionlike(obj): - """Private helper to test if `obj` is a duck type of FunctionType. - A good example of such objects are functions compiled with - Cython, which have all attributes that a pure Python function - would have, but have their code statically compiled. - """ + # Internal helper to test if `obj` is a duck type of FunctionType. + # A good example of such objects are functions compiled with + # Cython, which have all attributes that a pure Python function + # would have, but have their code statically compiled. if not callable(obj) or isclass(obj): # All function-like objects are obviously callables, @@ -1652,12 +1616,11 @@ def _signature_get_bound_param(spec): - """ Private helper to get first parameter name from a - __text_signature__ of a builtin method, which should - be in the following format: '($param1, ...)'. - Assumptions are that the first argument won't have - a default value or an annotation. - """ + # Internal helper to get first parameter name from a + # __text_signature__ of a builtin method, which should + # be in the following format: '($param1, ...)'. + # Assumptions are that the first argument won't have + # a default value or an annotation. assert spec.startswith('($') @@ -1676,9 +1639,7 @@ def _signature_strip_non_python_syntax(signature): """ - Private helper function. Takes a signature in Argument Clinic's - extended signature format. - + Takes a signature in Argument Clinic's extended signature format. Returns a tuple of three things: * that signature re-rendered in standard Python syntax, * the index of the "self" parameter (generally 0), or None if @@ -1747,10 +1708,8 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True): - """Private helper to parse content of '__text_signature__' - and return a Signature based on it. - """ - + # Internal helper to parse content of '__text_signature__' + # and return a Signature based on it Parameter = cls._parameter_cls clean_signature, self_parameter, last_positional_only = \ @@ -1888,10 +1847,8 @@ def _signature_from_builtin(cls, func, skip_bound_arg=True): - """Private helper function to get signature for - builtin callables. - """ - + # Internal helper function to get signature for + # builtin callables if not _signature_is_builtin(func): raise TypeError("{!r} is not a Python builtin " "function".format(func)) @@ -1903,14 +1860,7 @@ return _signature_fromstr(cls, func, s, skip_bound_arg) -def _signature_from_callable(obj, *, - follow_wrapper_chains=True, - skip_bound_arg=True, - sigcls): - - """Private helper function to get signature for arbitrary - callable objects. - """ +def _signature_internal(obj, follow_wrapper_chains=True, skip_bound_arg=True): if not callable(obj): raise TypeError('{!r} is not a callable object'.format(obj)) @@ -1918,12 +1868,9 @@ if isinstance(obj, types.MethodType): # In this case we skip the first parameter of the underlying # function (usually `self` or `cls`). - sig = _signature_from_callable( - obj.__func__, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) - + sig = _signature_internal(obj.__func__, + follow_wrapper_chains, + skip_bound_arg) if skip_bound_arg: return _signature_bound_method(sig) else: @@ -1954,12 +1901,9 @@ # (usually `self`, or `cls`) will not be passed # automatically (as for boundmethods) - wrapped_sig = _signature_from_callable( - partialmethod.func, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) - + wrapped_sig = _signature_internal(partialmethod.func, + follow_wrapper_chains, + skip_bound_arg) sig = _signature_get_partial(wrapped_sig, partialmethod, (None,)) first_wrapped_param = tuple(wrapped_sig.parameters.values())[0] @@ -1970,18 +1914,16 @@ if isfunction(obj) or _signature_is_functionlike(obj): # If it's a pure Python function, or an object that is duck type # of a Python function (Cython functions, for instance), then: - return sigcls.from_function(obj) + return Signature.from_function(obj) if _signature_is_builtin(obj): - return _signature_from_builtin(sigcls, obj, + return _signature_from_builtin(Signature, obj, skip_bound_arg=skip_bound_arg) if isinstance(obj, functools.partial): - wrapped_sig = _signature_from_callable( - obj.func, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) + wrapped_sig = _signature_internal(obj.func, + follow_wrapper_chains, + skip_bound_arg) return _signature_get_partial(wrapped_sig, obj) sig = None @@ -1992,29 +1934,23 @@ # in its metaclass call = _signature_get_user_defined_method(type(obj), '__call__') if call is not None: - sig = _signature_from_callable( - call, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) + sig = _signature_internal(call, + follow_wrapper_chains, + skip_bound_arg) else: # Now we check if the 'obj' class has a '__new__' method new = _signature_get_user_defined_method(obj, '__new__') if new is not None: - sig = _signature_from_callable( - new, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) + sig = _signature_internal(new, + follow_wrapper_chains, + skip_bound_arg) else: # Finally, we should have at least __init__ implemented init = _signature_get_user_defined_method(obj, '__init__') if init is not None: - sig = _signature_from_callable( - init, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) + sig = _signature_internal(init, + follow_wrapper_chains, + skip_bound_arg) if sig is None: # At this point we know, that `obj` is a class, with no user- @@ -2036,7 +1972,7 @@ if text_sig: # If 'obj' class has a __text_signature__ attribute: # return a signature based on it - return _signature_fromstr(sigcls, obj, text_sig) + return _signature_fromstr(Signature, obj, text_sig) # No '__text_signature__' was found for the 'obj' class. # Last option is to check if its '__init__' is @@ -2056,11 +1992,9 @@ call = _signature_get_user_defined_method(type(obj), '__call__') if call is not None: try: - sig = _signature_from_callable( - call, - follow_wrapper_chains=follow_wrapper_chains, - skip_bound_arg=skip_bound_arg, - sigcls=sigcls) + sig = _signature_internal(call, + follow_wrapper_chains, + skip_bound_arg) except ValueError as ex: msg = 'no signature found for {!r}'.format(obj) raise ValueError(msg) from ex @@ -2080,35 +2014,41 @@ raise ValueError('callable {!r} is not supported by signature'.format(obj)) +def signature(obj): + '''Get a signature object for the passed callable.''' + return _signature_internal(obj) + class _void: - """A private marker - used in Parameter & Signature.""" + '''A private marker - used in Parameter & Signature''' class _empty: - """Marker object for Signature.empty and Parameter.empty.""" - - -class _ParameterKind(enum.IntEnum): - POSITIONAL_ONLY = 0 - POSITIONAL_OR_KEYWORD = 1 - VAR_POSITIONAL = 2 - KEYWORD_ONLY = 3 - VAR_KEYWORD = 4 + pass + + +class _ParameterKind(int): + def __new__(self, *args, name): + obj = int.__new__(self, *args) + obj._name = name + return obj def __str__(self): - return self._name_ - - -_POSITIONAL_ONLY = _ParameterKind.POSITIONAL_ONLY -_POSITIONAL_OR_KEYWORD = _ParameterKind.POSITIONAL_OR_KEYWORD -_VAR_POSITIONAL = _ParameterKind.VAR_POSITIONAL -_KEYWORD_ONLY = _ParameterKind.KEYWORD_ONLY -_VAR_KEYWORD = _ParameterKind.VAR_KEYWORD + return self._name + + def __repr__(self): + return '<_ParameterKind: {!r}>'.format(self._name) + + +_POSITIONAL_ONLY = _ParameterKind(0, name='POSITIONAL_ONLY') +_POSITIONAL_OR_KEYWORD = _ParameterKind(1, name='POSITIONAL_OR_KEYWORD') +_VAR_POSITIONAL = _ParameterKind(2, name='VAR_POSITIONAL') +_KEYWORD_ONLY = _ParameterKind(3, name='KEYWORD_ONLY') +_VAR_KEYWORD = _ParameterKind(4, name='VAR_KEYWORD') class Parameter: - """Represents a parameter in a function signature. + '''Represents a parameter in a function signature. Has the following public attributes: @@ -2127,9 +2067,9 @@ Possible values: `Parameter.POSITIONAL_ONLY`, `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`, `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`. - """ - - __slots__ = ('_name', '_kind', '_default', '_annotation') + ''' + + __slots__ = ('_name', '_kind', '_default', '_annotation', '_partial_kwarg') POSITIONAL_ONLY = _POSITIONAL_ONLY POSITIONAL_OR_KEYWORD = _POSITIONAL_OR_KEYWORD @@ -2139,7 +2079,8 @@ empty = _empty - def __init__(self, name, kind, *, default=_empty, annotation=_empty): + def __init__(self, name, kind, *, default=_empty, annotation=_empty, + _partial_kwarg=False): if kind not in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD, _VAR_POSITIONAL, _KEYWORD_ONLY, _VAR_KEYWORD): @@ -2164,15 +2105,7 @@ self._name = name - def __reduce__(self): - return (type(self), - (self._name, self._kind), - {'_default': self._default, - '_annotation': self._annotation}) - - def __setstate__(self, state): - self._default = state['_default'] - self._annotation = state['_annotation'] + self._partial_kwarg = _partial_kwarg @property def name(self): @@ -2190,9 +2123,9 @@ def kind(self): return self._kind - def replace(self, *, name=_void, kind=_void, - annotation=_void, default=_void): - """Creates a customized copy of the Parameter.""" + def replace(self, *, name=_void, kind=_void, annotation=_void, + default=_void, _partial_kwarg=_void): + '''Creates a customized copy of the Parameter.''' if name is _void: name = self._name @@ -2206,7 +2139,11 @@ if default is _void: default = self._default - return type(self)(name, kind, default=default, annotation=annotation) + if _partial_kwarg is _void: + _partial_kwarg = self._partial_kwarg + + return type(self)(name, kind, default=default, annotation=annotation, + _partial_kwarg=_partial_kwarg) def __str__(self): kind = self.kind @@ -2228,20 +2165,21 @@ return formatted def __repr__(self): - return '<{} at {:#x} "{}">'.format(self.__class__.__name__, - id(self), self) - - def __hash__(self): - hash_tuple = (self.name, int(self.kind)) - - if self._annotation is not _empty: - hash_tuple += (self._annotation,) - if self._default is not _empty: - hash_tuple += (self._default,) - - return hash(hash_tuple) + return '<{} at {:#x} {!r}>'.format(self.__class__.__name__, + id(self), self.name) def __eq__(self, other): + # NB: We deliberately do not compare '_partial_kwarg' attributes + # here. Imagine we have a following situation: + # + # def foo(a, b=1): pass + # def bar(a, b): pass + # bar2 = functools.partial(bar, b=1) + # + # For the above scenario, signatures for `foo` and `bar2` should + # be equal. '_partial_kwarg' attribute is an internal flag, to + # distinguish between keyword parameters with defaults and + # keyword parameters which got their defaults from functools.partial return (issubclass(other.__class__, Parameter) and self._name == other._name and self._kind == other._kind and @@ -2253,7 +2191,7 @@ class BoundArguments: - """Result of `Signature.bind` call. Holds the mapping of arguments + '''Result of `Signature.bind` call. Holds the mapping of arguments to the function's parameters. Has the following public attributes: @@ -2267,7 +2205,7 @@ Tuple of positional arguments values. * kwargs : dict Dict of keyword arguments values. - """ + ''' def __init__(self, signature, arguments): self.arguments = arguments @@ -2281,7 +2219,12 @@ def args(self): args = [] for param_name, param in self._signature.parameters.items(): - if param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY): + if (param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY) or + param._partial_kwarg): + # Keyword arguments mapped by 'functools.partial' + # (Parameter._partial_kwarg is True) are mapped + # in 'BoundArguments.kwargs', along with VAR_KEYWORD & + # KEYWORD_ONLY break try: @@ -2306,7 +2249,8 @@ kwargs_started = False for param_name, param in self._signature.parameters.items(): if not kwargs_started: - if param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY): + if (param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY) or + param._partial_kwarg): kwargs_started = True else: if param_name not in self.arguments: @@ -2340,7 +2284,7 @@ class Signature: - """A Signature object represents the overall signature of a function. + '''A Signature object represents the overall signature of a function. It stores a Parameter object for each parameter accepted by the function, as well as information specific to the function itself. @@ -2360,7 +2304,7 @@ * bind_partial(*args, **kwargs) -> BoundArguments Creates a partial mapping from positional and keyword arguments to parameters (simulating 'functools.partial' behavior.) - """ + ''' __slots__ = ('_return_annotation', '_parameters') @@ -2371,9 +2315,9 @@ def __init__(self, parameters=None, *, return_annotation=_empty, __validate_parameters__=True): - """Constructs Signature from the given list of Parameter + '''Constructs Signature from the given list of Parameter objects and 'return_annotation'. All arguments are optional. - """ + ''' if parameters is None: params = OrderedDict() @@ -2388,14 +2332,18 @@ name = param.name if kind < top_kind: - msg = 'wrong parameter order: {!r} before {!r}' + msg = 'wrong parameter order: {} before {}' msg = msg.format(top_kind, kind) raise ValueError(msg) elif kind > top_kind: kind_defaults = False top_kind = kind - if kind in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD): + if (kind in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD) and + not param._partial_kwarg): + # If we have a positional-only or positional-or-keyword + # parameter, that does not have its default value set + # by 'functools.partial' or other "partial" signature: if param.default is _empty: if kind_defaults: # No default for this parameter, but the @@ -2422,7 +2370,7 @@ @classmethod def from_function(cls, func): - """Constructs Signature for the given python function.""" + '''Constructs Signature for the given python function''' is_duck_function = False if not isfunction(func): @@ -2503,14 +2451,8 @@ @classmethod def from_builtin(cls, func): - """Constructs Signature for the given builtin function.""" return _signature_from_builtin(cls, func) - @classmethod - def from_callable(cls, obj): - """Constructs Signature for the given callable object.""" - return _signature_from_callable(obj, sigcls=cls) - @property def parameters(self): return self._parameters @@ -2520,10 +2462,10 @@ return self._return_annotation def replace(self, *, parameters=_void, return_annotation=_void): - """Creates a customized copy of the Signature. + '''Creates a customized copy of the Signature. Pass 'parameters' and/or 'return_annotation' arguments to override them in the new copy. - """ + ''' if parameters is _void: parameters = self.parameters.values() @@ -2534,12 +2476,6 @@ return type(self)(parameters, return_annotation=return_annotation) - def __hash__(self): - hash_tuple = tuple(self.parameters.values()) - if self._return_annotation is not _empty: - hash_tuple += (self._return_annotation,) - return hash(hash_tuple) - def __eq__(self, other): if (not issubclass(type(other), Signature) or self.return_annotation != other.return_annotation or @@ -2574,7 +2510,7 @@ return not self.__eq__(other) def _bind(self, args, kwargs, *, partial=False): - """Private method. Don't use directly.""" + '''Private method. Don't use directly.''' arguments = OrderedDict() @@ -2582,6 +2518,15 @@ parameters_ex = () arg_vals = iter(args) + if partial: + # Support for binding arguments to 'functools.partial' objects. + # See 'functools.partial' case in 'signature()' implementation + # for details. + for param_name, param in self.parameters.items(): + if (param._partial_kwarg and param_name not in kwargs): + # Simulating 'functools.partial' behavior + kwargs[param_name] = param.default + while True: # Let's iterate through the positional arguments and corresponding # parameters @@ -2701,31 +2646,19 @@ return self._bound_arguments_cls(self, arguments) def bind(*args, **kwargs): - """Get a BoundArguments object, that maps the passed `args` + '''Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. - """ + ''' return args[0]._bind(args[1:], kwargs) def bind_partial(*args, **kwargs): - """Get a BoundArguments object, that partially maps the + '''Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. - """ + ''' return args[0]._bind(args[1:], kwargs, partial=True) - def __reduce__(self): - return (type(self), - (tuple(self._parameters.values()),), - {'_return_annotation': self._return_annotation}) - - def __setstate__(self, state): - self._return_annotation = state['_return_annotation'] - - def __repr__(self): - return '<{} at {:#x} "{}">'.format(self.__class__.__name__, - id(self), self) - def __str__(self): result = [] render_pos_only_separator = False @@ -2771,12 +2704,6 @@ return rendered - -def signature(obj): - """Get a signature object for the passed callable.""" - return Signature.from_callable(obj) - - def _main(): """ Logic for inspecting an object given at command line """ import argparse diff -r ce070040e1a6 -r d7f128afe9db Lib/io.py --- a/Lib/io.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/io.py Sun Mar 23 09:44:28 2014 +0100 @@ -70,16 +70,16 @@ # Method descriptions and default implementations are inherited from the C # version however. class IOBase(_io._IOBase, metaclass=abc.ABCMeta): - __doc__ = _io._IOBase.__doc__ + pass class RawIOBase(_io._RawIOBase, IOBase): - __doc__ = _io._RawIOBase.__doc__ + pass class BufferedIOBase(_io._BufferedIOBase, IOBase): - __doc__ = _io._BufferedIOBase.__doc__ + pass class TextIOBase(_io._TextIOBase, IOBase): - __doc__ = _io._TextIOBase.__doc__ + pass RawIOBase.register(FileIO) diff -r ce070040e1a6 -r d7f128afe9db Lib/ipaddress.py --- a/Lib/ipaddress.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/ipaddress.py Sun Mar 23 09:44:28 2014 +0100 @@ -436,17 +436,6 @@ return str(self) @property - def reverse_pointer(self): - """The name of the reverse DNS pointer for the IP address, e.g.: - >>> ipaddress.ip_address("127.0.0.1").reverse_pointer - '1.0.0.127.in-addr.arpa' - >>> ipaddress.ip_address("2001:db8::1").reverse_pointer - '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa' - - """ - return self._reverse_pointer() - - @property def version(self): msg = '%200s has no version specified' % (type(self),) raise NotImplementedError(msg) @@ -1232,15 +1221,6 @@ return True return False - def _reverse_pointer(self): - """Return the reverse DNS pointer name for the IPv4 address. - - This implements the method described in RFC1035 3.5. - - """ - reverse_octets = str(self).split('.')[::-1] - return '.'.join(reverse_octets) + '.in-addr.arpa' - @property def max_prefixlen(self): return self._max_prefixlen @@ -1804,15 +1784,6 @@ return '%s/%d' % (':'.join(parts), self._prefixlen) return ':'.join(parts) - def _reverse_pointer(self): - """Return the reverse DNS pointer name for the IPv6 address. - - This implements the method described in RFC3596 2.5. - - """ - reverse_chars = self.exploded[::-1].replace(':', '') - return '.'.join(reverse_chars) + '.ip6.arpa' - @property def max_prefixlen(self): return self._max_prefixlen diff -r ce070040e1a6 -r d7f128afe9db Lib/lib2to3/Grammar.txt --- a/Lib/lib2to3/Grammar.txt Sat May 10 13:24:58 2014 -0400 +++ b/Lib/lib2to3/Grammar.txt Sun Mar 23 09:44:28 2014 +0100 @@ -56,7 +56,7 @@ expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*) testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] -augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' | +augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') # For normal assignments, additional restrictions enforced by the interpreter print_stmt: 'print' ( [ test (',' test)* [','] ] | @@ -119,7 +119,7 @@ and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* -term: factor (('*'|'@'|'/'|'%'|'//') factor)* +term: factor (('*'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power power: atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_gexp] ')' | @@ -155,5 +155,4 @@ # not used in grammar, but may appear in "node" passed from Parser to Compiler encoding_decl: NAME -yield_expr: 'yield' [yield_arg] -yield_arg: 'from' test | testlist +yield_expr: 'yield' [testlist] diff -r ce070040e1a6 -r d7f128afe9db Lib/lib2to3/pgen2/grammar.py --- a/Lib/lib2to3/pgen2/grammar.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/lib2to3/pgen2/grammar.py Sun Mar 23 09:44:28 2014 +0100 @@ -149,7 +149,6 @@ { LBRACE } RBRACE @ AT -@= ATEQUAL == EQEQUAL != NOTEQUAL <> NOTEQUAL diff -r ce070040e1a6 -r d7f128afe9db Lib/lib2to3/pgen2/token.py --- a/Lib/lib2to3/pgen2/token.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/lib2to3/pgen2/token.py Sun Mar 23 09:44:28 2014 +0100 @@ -57,13 +57,12 @@ DOUBLESLASH = 48 DOUBLESLASHEQUAL = 49 AT = 50 -ATEQUAL = 51 -OP = 52 -COMMENT = 53 -NL = 54 -RARROW = 55 -ERRORTOKEN = 56 -N_TOKENS = 57 +OP = 51 +COMMENT = 52 +NL = 53 +RARROW = 54 +ERRORTOKEN = 55 +N_TOKENS = 56 NT_OFFSET = 256 #--end constants-- diff -r ce070040e1a6 -r d7f128afe9db Lib/lib2to3/pgen2/tokenize.py --- a/Lib/lib2to3/pgen2/tokenize.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/lib2to3/pgen2/tokenize.py Sun Mar 23 09:44:28 2014 +0100 @@ -84,7 +84,7 @@ # recognized as two instances of =). Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=", r"//=?", r"->", - r"[+\-*/%&@|^=<>]=?", + r"[+\-*/%&|^=<>]=?", r"~") Bracket = '[][(){}]' diff -r ce070040e1a6 -r d7f128afe9db Lib/lib2to3/tests/test_parser.py --- a/Lib/lib2to3/tests/test_parser.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/lib2to3/tests/test_parser.py Sun Mar 23 09:44:28 2014 +0100 @@ -48,19 +48,6 @@ raise AssertionError("Syntax shouldn't have been valid") -class TestMatrixMultiplication(GrammarTest): - def test_matrix_multiplication_operator(self): - self.validate("a @ b") - self.validate("a @= b") - - -class TestYieldFrom(GrammarTest): - def test_matrix_multiplication_operator(self): - self.validate("yield from x") - self.validate("(yield from x) + y") - self.invalid_syntax("yield from") - - class TestRaiseChanges(GrammarTest): def test_2x_style_1(self): self.validate("raise") diff -r ce070040e1a6 -r d7f128afe9db Lib/logging/__init__.py --- a/Lib/logging/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/logging/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -23,8 +23,7 @@ To use, simply 'import logging' and log away! """ -import sys, os, time, io, traceback, warnings, weakref, collections - +import sys, os, time, io, traceback, warnings, weakref from string import Template __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', @@ -254,13 +253,7 @@ # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - # Issue #21172: a request was made to relax the isinstance check - # to hasattr(args[0], '__getitem__'). However, the docs on string - # formatting still seem to suggest a mapping object is required. - # Thus, while not removing the isinstance check, it does now look - # for collections.Mapping rather than, as before, dict. - if (args and len(args) == 1 and isinstance(args[0], collections.Mapping) - and args[0]): + if args and len(args) == 1 and isinstance(args[0], dict) and args[0]: args = args[0] self.args = args self.levelname = getLevelName(level) @@ -718,17 +711,16 @@ Remove a handler reference from the internal cleanup list. """ # This function can be called during module teardown, when globals are - # set to None. It can also be called from another thread. So we need to - # pre-emptively grab the necessary globals and check if they're None, - # to prevent race conditions and failures during interpreter shutdown. - acquire, release, handlers = _acquireLock, _releaseLock, _handlerList - if acquire and release and handlers: - acquire() + # set to None. If _acquireLock is None, assume this is the case and do + # nothing. + if (_acquireLock is not None and _handlerList is not None and + _releaseLock is not None): + _acquireLock() try: - if wr in handlers: - handlers.remove(wr) + if wr in _handlerList: + _handlerList.remove(wr) finally: - release() + _releaseLock() def _addHandlerRef(handler): """ diff -r ce070040e1a6 -r d7f128afe9db Lib/logging/config.py --- a/Lib/logging/config.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/logging/config.py Sun Mar 23 09:44:28 2014 +0100 @@ -116,12 +116,11 @@ sectname = "formatter_%s" % form fs = cp.get(sectname, "format", raw=True, fallback=None) dfs = cp.get(sectname, "datefmt", raw=True, fallback=None) - stl = cp.get(sectname, "style", raw=True, fallback='%') c = logging.Formatter class_name = cp[sectname].get("class") if class_name: c = _resolve(class_name) - f = c(fs, dfs, stl) + f = c(fs, dfs) formatters[form] = f return formatters @@ -661,12 +660,7 @@ fmt = config.get('format', None) dfmt = config.get('datefmt', None) style = config.get('style', '%') - cname = config.get('class', None) - if not cname: - c = logging.Formatter - else: - c = _resolve(cname) - result = c(fmt, dfmt, style) + result = logging.Formatter(fmt, dfmt, style) return result def configure_filter(self, config): diff -r ce070040e1a6 -r d7f128afe9db Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/multiprocessing/connection.py Sun Mar 23 09:44:28 2014 +0100 @@ -76,7 +76,7 @@ return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) elif family == 'AF_PIPE': return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + (os.getpid(), next(_mmap_counter))) else: raise ValueError('unrecognized family') diff -r ce070040e1a6 -r d7f128afe9db Lib/opcode.py --- a/Lib/opcode.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/opcode.py Sun Mar 23 09:44:28 2014 +0100 @@ -70,9 +70,6 @@ def_op('UNARY_INVERT', 15) -def_op('BINARY_MATRIX_MULTIPLY', 16) -def_op('INPLACE_MATRIX_MULTIPLY', 17) - def_op('BINARY_POWER', 19) def_op('BINARY_MULTIPLY', 20) diff -r ce070040e1a6 -r d7f128afe9db Lib/operator.py --- a/Lib/operator.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/operator.py Sun Mar 23 09:44:28 2014 +0100 @@ -105,10 +105,6 @@ "Same as a * b." return a * b -def matmul(a, b): - "Same as a @ b." - return a @ b - def neg(a): "Same as -a." return -a @@ -330,11 +326,6 @@ a *= b return a -def imatmul(a, b): - "Same as a @= b." - a @= b - return a - def ior(a, b): "Same as a |= b." a |= b @@ -392,7 +383,6 @@ __lshift__ = lshift __mod__ = mod __mul__ = mul -__matmul__ = matmul __neg__ = neg __or__ = or_ __pos__ = pos @@ -413,7 +403,6 @@ __ilshift__ = ilshift __imod__ = imod __imul__ = imul -__imatmul__ = imatmul __ior__ = ior __ipow__ = ipow __irshift__ = irshift diff -r ce070040e1a6 -r d7f128afe9db Lib/os.py --- a/Lib/os.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/os.py Sun Mar 23 09:44:28 2014 +0100 @@ -206,16 +206,23 @@ SEEK_CUR = 1 SEEK_END = 2 + +def _get_masked_mode(mode): + mask = umask(0) + umask(mask) + return mode & ~mask + # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) def makedirs(name, mode=0o777, exist_ok=False): """makedirs(name [, mode=0o777][, exist_ok=False]) - Super-mkdir; create a leaf directory and all intermediate ones. Works like - mkdir, except that any intermediate path segment (not just the rightmost) - will be created if it does not exist. If the target directory already - exists, raise an OSError if exist_ok is False. Otherwise no exception is + Super-mkdir; create a leaf directory and all intermediate ones. + Works like mkdir, except that any intermediate path segment (not + just the rightmost) will be created if it does not exist. If the + target directory with the same mode as we specified already exists, + raises an OSError if exist_ok is False, otherwise no exception is raised. This is recursive. """ @@ -236,7 +243,20 @@ try: mkdir(name, mode) except OSError as e: - if not exist_ok or e.errno != errno.EEXIST or not path.isdir(name): + dir_exists = path.isdir(name) + expected_mode = _get_masked_mode(mode) + if dir_exists: + # S_ISGID is automatically copied by the OS from parent to child + # directories on mkdir. Don't consider it being set to be a mode + # mismatch as mkdir does not unset it when not specified in mode. + actual_mode = st.S_IMODE(lstat(name).st_mode) & ~st.S_ISGID + else: + actual_mode = -1 + if not (e.errno == errno.EEXIST and exist_ok and dir_exists and + actual_mode == expected_mode): + if dir_exists and actual_mode != expected_mode: + e.strerror += ' (mode %o != expected mode %o)' % ( + actual_mode, expected_mode) raise def removedirs(name): diff -r ce070040e1a6 -r d7f128afe9db Lib/pathlib.py --- a/Lib/pathlib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/pathlib.py Sun Mar 23 09:44:28 2014 +0100 @@ -574,8 +574,8 @@ if isinstance(a, PurePath): parts += a._parts elif isinstance(a, str): - # Force-cast str subclasses to str (issue #21127) - parts.append(str(a)) + # Assuming a str + parts.append(a) else: raise TypeError( "argument should be a path or str object, not %r" diff -r ce070040e1a6 -r d7f128afe9db Lib/pkgutil.py --- a/Lib/pkgutil.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/pkgutil.py Sun Mar 23 09:44:28 2014 +0100 @@ -461,8 +461,6 @@ loader = getattr(module, '__loader__', None) if loader is not None: return loader - if getattr(module, '__spec__', None) is None: - return None fullname = module.__name__ else: fullname = module_or_name diff -r ce070040e1a6 -r d7f128afe9db Lib/pydoc.py --- a/Lib/pydoc.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/pydoc.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,9 +1,8 @@ #!/usr/bin/env python3 """Generate Python documentation in HTML or text for interactive use. -At the Python interactive prompt, calling help(thing) on a Python object -documents the object, and calling help() starts up an interactive -help session. +In the Python interpreter, do "from pydoc import help" to provide +help. Calling help(thing) on a Python object documents the object. Or, at the shell command line outside of Python: @@ -1866,7 +1865,7 @@ def intro(self): self.output.write(''' -Welcome to Python %s's help utility! +Welcome to Python %s! This is the interactive help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/%s/tutorial/. diff -r ce070040e1a6 -r d7f128afe9db Lib/signal.py --- a/Lib/signal.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -import _signal -from _signal import * -from functools import wraps as _wraps -from enum import IntEnum as _IntEnum - -_globals = globals() - -Signals = _IntEnum( - 'Signals', - {name: value for name, value in _globals.items() - if name.isupper() - and (name.startswith('SIG') and not name.startswith('SIG_')) - or name.startswith('CTRL_')}) - -class Handlers(_IntEnum): - SIG_DFL = _signal.SIG_DFL - SIG_IGN = _signal.SIG_IGN - -_globals.update(Signals.__members__) -_globals.update(Handlers.__members__) - -if 'pthread_sigmask' in _globals: - class Sigmasks(_IntEnum): - SIG_BLOCK = _signal.SIG_BLOCK - SIG_UNBLOCK = _signal.SIG_UNBLOCK - SIG_SETMASK = _signal.SIG_SETMASK - - _globals.update(Sigmasks.__members__) - - -def _int_to_enum(value, enum_klass): - """Convert a numeric value to an IntEnum member. - If it's not a known member, return the numeric value itself. - """ - try: - return enum_klass(value) - except ValueError: - return value - - -def _enum_to_int(value): - """Convert an IntEnum member to a numeric value. - If it's not a IntEnum member return the value itself. - """ - try: - return int(value) - except (ValueError, TypeError): - return value - - -@_wraps(_signal.signal) -def signal(signalnum, handler): - handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)) - return _int_to_enum(handler, Handlers) - - -@_wraps(_signal.getsignal) -def getsignal(signalnum): - handler = _signal.getsignal(signalnum) - return _int_to_enum(handler, Handlers) - - -if 'pthread_sigmask' in _globals: - @_wraps(_signal.pthread_sigmask) - def pthread_sigmask(how, mask): - sigs_set = _signal.pthread_sigmask(how, mask) - return set(_int_to_enum(x, Signals) for x in sigs_set) - pthread_sigmask.__doc__ = _signal.pthread_sigmask.__doc__ - - -if 'sigpending' in _globals: - @_wraps(_signal.sigpending) - def sigpending(): - sigs = _signal.sigpending() - return set(_int_to_enum(x, Signals) for x in sigs) - - -if 'sigwait' in _globals: - @_wraps(_signal.sigwait) - def sigwait(sigset): - retsig = _signal.sigwait(sigset) - return _int_to_enum(retsig, Signals) - sigwait.__doc__ = _signal.sigwait - -del _globals, _wraps diff -r ce070040e1a6 -r d7f128afe9db Lib/site.py --- a/Lib/site.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/site.py Sun Mar 23 09:44:28 2014 +0100 @@ -364,17 +364,12 @@ builtins.credits = _sitebuiltins._Printer("credits", """\ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.""") - files, dirs = [], [] - # Not all modules are required to have a __file__ attribute. See - # PEP 420 for more details. - if hasattr(os, '__file__'): - here = os.path.dirname(os.__file__) - files.extend(["LICENSE.txt", "LICENSE"]) - dirs.extend([os.path.join(here, os.pardir), here, os.curdir]) + here = os.path.dirname(os.__file__) builtins.license = _sitebuiltins._Printer( "license", "See http://www.python.org/download/releases/%.5s/license" % sys.version, - files, dirs) + ["LICENSE.txt", "LICENSE"], + [os.path.join(here, os.pardir), here, os.curdir]) def sethelper(): diff -r ce070040e1a6 -r d7f128afe9db Lib/smtplib.py --- a/Lib/smtplib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/smtplib.py Sun Mar 23 09:44:28 2014 +0100 @@ -478,18 +478,6 @@ """SMTP 'rset' command -- resets session.""" return self.docmd("rset") - def _rset(self): - """Internal 'rset' command which ignores any SMTPServerDisconnected error. - - Used internally in the library, since the server disconnected error - should appear to the application when the *next* command is issued, if - we are doing an internal "safety" reset. - """ - try: - self.rset() - except SMTPServerDisconnected: - pass - def noop(self): """SMTP 'noop' command -- doesn't do anything :>""" return self.docmd("noop") @@ -774,7 +762,7 @@ if code == 421: self.close() else: - self._rset() + self.rset() raise SMTPSenderRefused(code, resp, from_addr) senderrs = {} if isinstance(to_addrs, str): @@ -788,14 +776,14 @@ raise SMTPRecipientsRefused(senderrs) if len(senderrs) == len(to_addrs): # the server refused all our recipients - self._rset() + self.rset() raise SMTPRecipientsRefused(senderrs) (code, resp) = self.data(msg) if code != 250: if code == 421: self.close() else: - self._rset() + self.rset() raise SMTPDataError(code, resp) #if we got here then somebody got our mail return senderrs diff -r ce070040e1a6 -r d7f128afe9db Lib/ssl.py --- a/Lib/ssl.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/ssl.py Sun Mar 23 09:44:28 2014 +0100 @@ -92,7 +92,7 @@ import sys import os from collections import namedtuple -from enum import Enum as _Enum, IntEnum as _IntEnum +from enum import Enum as _Enum import _ssl # if we can't import it, let the error propagate @@ -119,19 +119,30 @@ from _ssl import HAS_SNI, HAS_ECDH, HAS_NPN +from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1 from _ssl import _OPENSSL_API_VERSION -_SSLMethod = _IntEnum('_SSLMethod', - {name: value for name, value in vars(_ssl).items() - if name.startswith('PROTOCOL_')}) -globals().update(_SSLMethod.__members__) -_PROTOCOL_NAMES = {value: name for name, value in _SSLMethod.__members__.items()} +_PROTOCOL_NAMES = { + PROTOCOL_TLSv1: "TLSv1", + PROTOCOL_SSLv23: "SSLv23", + PROTOCOL_SSLv3: "SSLv3", +} +try: + from _ssl import PROTOCOL_SSLv2 + _SSLv2_IF_EXISTS = PROTOCOL_SSLv2 +except ImportError: + _SSLv2_IF_EXISTS = None +else: + _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2" try: - _SSLv2_IF_EXISTS = PROTOCOL_SSLv2 -except NameError: - _SSLv2_IF_EXISTS = None + from _ssl import PROTOCOL_TLSv1_1, PROTOCOL_TLSv1_2 +except ImportError: + pass +else: + _PROTOCOL_NAMES[PROTOCOL_TLSv1_1] = "TLSv1.1" + _PROTOCOL_NAMES[PROTOCOL_TLSv1_2] = "TLSv1.2" if sys.platform == "win32": from _ssl import enum_certificates, enum_crls @@ -664,7 +675,17 @@ raise ValueError( "non-zero flags not allowed in calls to send() on %s" % self.__class__) - return self._sslobj.write(data) + try: + v = self._sslobj.write(data) + except SSLError as x: + if x.args[0] == SSL_ERROR_WANT_READ: + return 0 + elif x.args[0] == SSL_ERROR_WANT_WRITE: + return 0 + else: + raise + else: + return v else: return socket.send(self, data, flags) @@ -869,34 +890,12 @@ # some utility functions def cert_time_to_seconds(cert_time): - """Return the time in seconds since the Epoch, given the timestring - representing the "notBefore" or "notAfter" date from a certificate - in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C locale). + """Takes a date-time string in standard ASN1_print form + ("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return + a Python time value in seconds past the epoch.""" - "notBefore" or "notAfter" dates must use UTC (RFC 5280). - - Month is one of: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec - UTC should be specified as GMT (see ASN1_TIME_print()) - """ - from time import strptime - from calendar import timegm - - months = ( - "Jan","Feb","Mar","Apr","May","Jun", - "Jul","Aug","Sep","Oct","Nov","Dec" - ) - time_format = ' %d %H:%M:%S %Y GMT' # NOTE: no month, fixed GMT - try: - month_number = months.index(cert_time[:3].title()) + 1 - except ValueError: - raise ValueError('time data %r does not match ' - 'format "%%b%s"' % (cert_time, time_format)) - else: - # found valid month - tt = strptime(cert_time[3:], time_format) - # return an integer, the previous mktime()-based implementation - # returned a float (fractional seconds are always zero here). - return timegm((tt[0], month_number) + tt[2:6]) + import time + return time.mktime(time.strptime(cert_time, "%b %d %H:%M:%S %Y GMT")) PEM_HEADER = "-----BEGIN CERTIFICATE-----" PEM_FOOTER = "-----END CERTIFICATE-----" @@ -923,7 +922,7 @@ d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)] return base64.decodebytes(d.encode('ASCII', 'strict')) -def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): +def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None): """Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. diff -r ce070040e1a6 -r d7f128afe9db Lib/string.py --- a/Lib/string.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/string.py Sun Mar 23 09:44:28 2014 +0100 @@ -169,8 +169,7 @@ self.check_unused_args(used_args, args, kwargs) return result - def _vformat(self, format_string, args, kwargs, used_args, recursion_depth, - auto_arg_index=0): + def _vformat(self, format_string, args, kwargs, used_args, recursion_depth): if recursion_depth < 0: raise ValueError('Max string recursion exceeded') result = [] @@ -186,23 +185,6 @@ # this is some markup, find the object and do # the formatting - # handle arg indexing when empty field_names are given. - if field_name == '': - if auto_arg_index is False: - raise ValueError('cannot switch from manual field ' - 'specification to automatic field ' - 'numbering') - field_name = str(auto_arg_index) - auto_arg_index += 1 - elif field_name.isdigit(): - if auto_arg_index: - raise ValueError('cannot switch from manual field ' - 'specification to automatic field ' - 'numbering') - # disable auto arg incrementing, if it gets - # used later on, then an exception will be raised - auto_arg_index = False - # given the field_name, find the object it references # and the argument it came from obj, arg_used = self.get_field(field_name, args, kwargs) @@ -213,8 +195,7 @@ # expand the format spec, if needed format_spec = self._vformat(format_spec, args, kwargs, - used_args, recursion_depth-1, - auto_arg_index=auto_arg_index) + used_args, recursion_depth-1) # format the object and append to the result result.append(self.format_field(obj, format_spec)) diff -r ce070040e1a6 -r d7f128afe9db Lib/subprocess.py --- a/Lib/subprocess.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/subprocess.py Sun Mar 23 09:44:28 2014 +0100 @@ -104,21 +104,17 @@ If env is not None, it defines the environment variables for the new process. -If universal_newlines is False, the file objects stdin, stdout and stderr +If universal_newlines is false, the file objects stdin, stdout and stderr are opened as binary files, and no line ending conversion is done. -If universal_newlines is True, the file objects stdout and stderr are -opened as a text file, but lines may be terminated by any of '\n', +If universal_newlines is true, the file objects stdout and stderr are +opened as a text files, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the old Macintosh convention or '\r\n', the Windows convention. All of these external representations are seen as '\n' by the Python program. Also, the newlines attribute of the file objects stdout, stdin and stderr are not updated by the communicate() method. -In either case, the process being communicated with should start up -expecting to receive bytes on its standard input and decode them with -the same encoding they are sent in. - The startupinfo and creationflags, if given, will be passed to the underlying CreateProcess() function. They can specify things such as appearance of the main window and priority for the new process. @@ -188,9 +184,6 @@ pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument. - If universal_newlines is set to True, the "input" argument must - be a string rather than bytes, and the return value will be a string. - Exceptions ---------- Exceptions raised in the child process, before the new program has @@ -232,13 +225,9 @@ communicate(input=None) Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to - terminate. The optional input argument should be data to be + terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to - the child. If the Popen instance was constructed with universal_newlines - set to True, the input argument should be a string and will be encoded - using the preferred system encoding (see locale.getpreferredencoding); - if universal_newlines is False, the input argument should be a - byte string. + the child. communicate() returns a tuple (stdout, stderr). @@ -416,10 +405,6 @@ import _posixsubprocess import select import selectors - try: - import threading - except ImportError: - import dummy_threading as threading # When select or poll has indicated that the file is writable, # we can write up to _PIPE_BUF bytes without risk of blocking. @@ -602,8 +587,8 @@ ... input=b"when in the course of fooman events\n") b'when in the course of barman events\n' - If universal_newlines=True is passed, the "input" argument must be a - string and the return value will be a string rather than bytes. + If universal_newlines=True is passed, the return value will be a + string rather than bytes. """ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') @@ -763,12 +748,6 @@ pass_fds=()): """Create new Popen instance.""" _cleanup() - # Held while anything is calling waitpid before returncode has been - # updated to prevent clobbering returncode if wait() or poll() are - # called from multiple threads at once. After acquiring the lock, - # code must re-check self.returncode to see if another thread just - # finished a waitpid() call. - self._waitpid_lock = threading.Lock() self._input = None self._communication_started = False @@ -929,16 +908,11 @@ def communicate(self, input=None, timeout=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for - process to terminate. + process to terminate. The optional input argument should be + bytes to be sent to the child process, or None, if no data + should be sent to the child. - The optional "input" argument should be data to be sent to the - child process (if self.universal_newlines is True, this should - be a string; if it is False, "input" should be bytes), or - None, if no data should be sent to the child. - - communicate() returns a tuple (stdout, stderr). These will be - bytes or, if self.universal_newlines was True, a string. - """ + communicate() returns a tuple (stdout, stderr).""" if self._communication_started and input: raise ValueError("Cannot send input after starting communication") @@ -1476,7 +1450,6 @@ def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED, _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED, _WEXITSTATUS=os.WEXITSTATUS): - """All callers to this function MUST hold self._waitpid_lock.""" # This method is called (indirectly) by __del__, so it cannot # refer to anything outside of its local scope. if _WIFSIGNALED(sts): @@ -1498,13 +1471,7 @@ """ if self.returncode is None: - if not self._waitpid_lock.acquire(False): - # Something else is busy calling waitpid. Don't allow two - # at once. We know nothing yet. - return None try: - if self.returncode is not None: - return self.returncode # Another thread waited. pid, sts = _waitpid(self.pid, _WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) @@ -1518,13 +1485,10 @@ # can't get the status. # http://bugs.python.org/issue15756 self.returncode = 0 - finally: - self._waitpid_lock.release() return self.returncode def _try_wait(self, wait_flags): - """All callers to this function MUST hold self._waitpid_lock.""" try: (pid, sts) = _eintr_retry_call(os.waitpid, self.pid, wait_flags) except OSError as e: @@ -1557,17 +1521,11 @@ # cribbed from Lib/threading.py in Thread.wait() at r71065. delay = 0.0005 # 500 us -> initial delay of 1 ms while True: - if self._waitpid_lock.acquire(False): - try: - if self.returncode is not None: - break # Another thread waited. - (pid, sts) = self._try_wait(os.WNOHANG) - assert pid == self.pid or pid == 0 - if pid == self.pid: - self._handle_exitstatus(sts) - break - finally: - self._waitpid_lock.release() + (pid, sts) = self._try_wait(os.WNOHANG) + assert pid == self.pid or pid == 0 + if pid == self.pid: + self._handle_exitstatus(sts) + break remaining = self._remaining_time(endtime) if remaining <= 0: raise TimeoutExpired(self.args, timeout) @@ -1575,15 +1533,11 @@ time.sleep(delay) else: while self.returncode is None: - with self._waitpid_lock: - if self.returncode is not None: - break # Another thread waited. - (pid, sts) = self._try_wait(0) - # Check the pid and loop as waitpid has been known to - # return 0 even without WNOHANG in odd situations. - # http://bugs.python.org/issue14396. - if pid == self.pid: - self._handle_exitstatus(sts) + (pid, sts) = self._try_wait(0) + # Check the pid and loop as waitpid has been known to return + # 0 even without WNOHANG in odd situations. issue14396. + if pid == self.pid: + self._handle_exitstatus(sts) return self.returncode diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/both_portions/foo/one.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/both_portions/foo/one.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'both_portions foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/both_portions/foo/two.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/both_portions/foo/two.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'both_portions foo two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/missing_directory.zip Binary file Lib/test/namespace_pkgs/missing_directory.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/module_and_namespace_package/a_test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/module_and_namespace_package/a_test.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'in module' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/nested_portion1.zip Binary file Lib/test/namespace_pkgs/nested_portion1.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/not_a_namespace_pkg/foo/one.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/not_a_namespace_pkg/foo/one.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'portion1 foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/portion1/foo/one.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/portion1/foo/one.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'portion1 foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/portion2/foo/two.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/portion2/foo/two.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'portion2 foo two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/project1/parent/child/one.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/project1/parent/child/one.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'parent child one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/project2/parent/child/two.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/project2/parent/child/two.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'parent child two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/project3/parent/child/three.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/namespace_pkgs/project3/parent/child/three.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,1 @@ +attr = 'parent child three' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/namespace_pkgs/top_level_portion1.zip Binary file Lib/test/namespace_pkgs/top_level_portion1.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/ssl_servers.py --- a/Lib/test/ssl_servers.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/ssl_servers.py Sun Mar 23 09:44:28 2014 +0100 @@ -150,7 +150,7 @@ def make_https_server(case, *, context=None, certfile=CERTFILE, host=HOST, handler_class=None): if context is None: - context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) # We assume the certfile contains both private key and certificate context.load_cert_chain(certfile) server = HTTPSServerThread(context, host, handler_class) @@ -182,8 +182,6 @@ parser.add_argument('--curve-name', dest='curve_name', type=str, action='store', help='curve name for EC-based Diffie-Hellman') - parser.add_argument('--ciphers', dest='ciphers', type=str, - help='allowed cipher list') parser.add_argument('--dh', dest='dh_file', type=str, action='store', help='PEM file containing DH parameters') args = parser.parse_args() @@ -194,14 +192,12 @@ else: handler_class = RootedHTTPRequestHandler handler_class.root = os.getcwd() - context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) if args.curve_name: context.set_ecdh_curve(args.curve_name) if args.dh_file: context.load_dh_params(args.dh_file) - if args.ciphers: - context.set_ciphers(args.ciphers) server = HTTPSServer(("", args.port), handler_class, context) if args.verbose: diff -r ce070040e1a6 -r d7f128afe9db Lib/test/support/__init__.py --- a/Lib/test/support/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/support/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -378,16 +378,12 @@ unlink(importlib.util.cache_from_source(source, debug_override=True)) unlink(importlib.util.cache_from_source(source, debug_override=False)) -# Check whether a gui is actually available -def _is_gui_available(): - if hasattr(_is_gui_available, 'result'): - return _is_gui_available.result - reason = None - if sys.platform.startswith('win'): - # if Python is running as a service (such as the buildbot service), - # gui interaction may be disallowed - import ctypes - import ctypes.wintypes +# On some platforms, should not run gui test even if it is allowed +# in `use_resources'. +if sys.platform.startswith('win'): + import ctypes + import ctypes.wintypes + def _is_gui_available(): UOI_FLAGS = 1 WSF_VISIBLE = 0x0001 class USEROBJECTFLAGS(ctypes.Structure): @@ -407,51 +403,10 @@ ctypes.byref(needed)) if not res: raise ctypes.WinError() - if not bool(uof.dwFlags & WSF_VISIBLE): - reason = "gui not available (WSF_VISIBLE flag not set)" - elif sys.platform == 'darwin': - # The Aqua Tk implementations on OS X can abort the process if - # being called in an environment where a window server connection - # cannot be made, for instance when invoked by a buildbot or ssh - # process not running under the same user id as the current console - # user. To avoid that, raise an exception if the window manager - # connection is not available. - from ctypes import cdll, c_int, pointer, Structure - from ctypes.util import find_library - - app_services = cdll.LoadLibrary(find_library("ApplicationServices")) - - if app_services.CGMainDisplayID() == 0: - reason = "gui tests cannot run without OS X window manager" - else: - class ProcessSerialNumber(Structure): - _fields_ = [("highLongOfPSN", c_int), - ("lowLongOfPSN", c_int)] - psn = ProcessSerialNumber() - psn_p = pointer(psn) - if ( (app_services.GetCurrentProcess(psn_p) < 0) or - (app_services.SetFrontProcess(psn_p) < 0) ): - reason = "cannot run without OS X gui process" - - # check on every platform whether tkinter can actually do anything - # but skip the test on OS X because it can cause segfaults in Cocoa Tk - # when running regrtest with the -j option (multiple threads/subprocesses) - if (not reason) and (sys.platform != 'darwin'): - try: - from tkinter import Tk - root = Tk() - root.destroy() - except Exception as e: - err_string = str(e) - if len(err_string) > 50: - err_string = err_string[:50] + ' [...]' - reason = 'Tk unavailable due to {}: {}'.format(type(e).__name__, - err_string) - - _is_gui_available.reason = reason - _is_gui_available.result = not reason - - return _is_gui_available.result + return bool(uof.dwFlags & WSF_VISIBLE) +else: + def _is_gui_available(): + return True def is_resource_enabled(resource): """Test whether a resource is enabled. Known resources are set by @@ -466,7 +421,7 @@ executing. """ if resource == 'gui' and not _is_gui_available(): - raise ResourceDenied(_is_gui_available.reason) + raise unittest.SkipTest("Cannot use the 'gui' resource") # see if the caller's module is __main__ - if so, treat as if # the resource was set if sys._getframe(1).f_globals.get("__name__") == "__main__": @@ -1634,7 +1589,7 @@ def requires_resource(resource): if resource == 'gui' and not _is_gui_available(): - return unittest.skip(_is_gui_available.reason) + return unittest.skip("resource 'gui' is not available") if is_resource_enabled(resource): return _id else: diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_argparse.py Sun Mar 23 09:44:28 2014 +0100 @@ -47,9 +47,6 @@ def tearDown(self): os.chdir(self.old_dir) - for root, dirs, files in os.walk(self.temp_dir, topdown=False): - for name in files: - os.chmod(os.path.join(self.temp_dir, name), stat.S_IWRITE) shutil.rmtree(self.temp_dir, True) def create_readonly_file(self, filename): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asdl_parser.py --- a/Lib/test/test_asdl_parser.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -"""Tests for the asdl parser in Parser/asdl.py""" - -import importlib.machinery -import os -from os.path import dirname -import sys -import sysconfig -import unittest - - -# This test is only relevant for from-source builds of Python. -if not sysconfig.is_python_build(): - raise unittest.SkipTest('test irrelevant for an installed Python') - -src_base = dirname(dirname(dirname(__file__))) -parser_dir = os.path.join(src_base, 'Parser') - - -class TestAsdlParser(unittest.TestCase): - @classmethod - def setUpClass(cls): - # Loads the asdl module dynamically, since it's not in a real importable - # package. - # Parses Python.asdl into a ast.Module and run the check on it. - # There's no need to do this for each test method, hence setUpClass. - sys.path.insert(0, parser_dir) - loader = importlib.machinery.SourceFileLoader( - 'asdl', os.path.join(parser_dir, 'asdl.py')) - cls.asdl = loader.load_module() - cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl')) - cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed') - - @classmethod - def tearDownClass(cls): - del sys.path[0] - - def setUp(self): - # alias stuff from the class, for convenience - self.asdl = TestAsdlParser.asdl - self.mod = TestAsdlParser.mod - self.types = self.mod.types - - def test_module(self): - self.assertEqual(self.mod.name, 'Python') - self.assertIn('stmt', self.types) - self.assertIn('expr', self.types) - self.assertIn('mod', self.types) - - def test_definitions(self): - defs = self.mod.dfns - self.assertIsInstance(defs[0], self.asdl.Type) - self.assertIsInstance(defs[0].value, self.asdl.Sum) - - self.assertIsInstance(self.types['withitem'], self.asdl.Product) - self.assertIsInstance(self.types['alias'], self.asdl.Product) - - def test_product(self): - alias = self.types['alias'] - self.assertEqual( - str(alias), - 'Product([Field(identifier, name), Field(identifier, asname, opt=True)])') - - def test_attributes(self): - stmt = self.types['stmt'] - self.assertEqual(len(stmt.attributes), 2) - self.assertEqual(str(stmt.attributes[0]), 'Field(int, lineno)') - self.assertEqual(str(stmt.attributes[1]), 'Field(int, col_offset)') - - def test_constructor_fields(self): - ehandler = self.types['excepthandler'] - self.assertEqual(len(ehandler.types), 1) - self.assertEqual(len(ehandler.attributes), 2) - - cons = ehandler.types[0] - self.assertIsInstance(cons, self.asdl.Constructor) - self.assertEqual(len(cons.fields), 3) - - f0 = cons.fields[0] - self.assertEqual(f0.type, 'expr') - self.assertEqual(f0.name, 'type') - self.assertTrue(f0.opt) - - f1 = cons.fields[1] - self.assertEqual(f1.type, 'identifier') - self.assertEqual(f1.name, 'name') - self.assertTrue(f1.opt) - - f2 = cons.fields[2] - self.assertEqual(f2.type, 'stmt') - self.assertEqual(f2.name, 'body') - self.assertFalse(f2.opt) - self.assertTrue(f2.seq) - - def test_visitor(self): - class CustomVisitor(self.asdl.VisitorBase): - def __init__(self): - super().__init__() - self.names_with_seq = [] - - def visitModule(self, mod): - for dfn in mod.dfns: - self.visit(dfn) - - def visitType(self, type): - self.visit(type.value) - - def visitSum(self, sum): - for t in sum.types: - self.visit(t) - - def visitConstructor(self, cons): - for f in cons.fields: - if f.seq: - self.names_with_seq.append(cons.name) - - v = CustomVisitor() - v.visit(self.types['mod']) - self.assertEqual(v.names_with_seq, ['Module', 'Interactive', 'Suite']) - - -if __name__ == '__main__': - unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/__init__.py --- a/Lib/test/test_asyncio/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncio/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -10,18 +10,20 @@ def suite(): + tests_file = os.path.join(os.path.dirname(__file__), 'tests.txt') + with open(tests_file) as fp: + test_names = fp.read().splitlines() tests = unittest.TestSuite() loader = unittest.TestLoader() - for fn in os.listdir(os.path.dirname(__file__)): - if fn.startswith("test") and fn.endswith(".py"): - mod_name = 'test.test_asyncio.' + fn[:-3] - try: - __import__(mod_name) - except unittest.SkipTest: - pass - else: - mod = sys.modules[mod_name] - tests.addTests(loader.loadTestsFromModule(mod)) + for test_name in test_names: + mod_name = 'test.' + test_name + try: + __import__(mod_name) + except unittest.SkipTest: + pass + else: + mod = sys.modules[mod_name] + tests.addTests(loader.loadTestsFromModule(mod)) return tests diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncio/test_events.py Sun Mar 23 09:44:28 2014 +0100 @@ -21,7 +21,6 @@ import errno import unittest from unittest import mock -import weakref from test import support # find_unused_port, IPV6_ENABLED, TEST_HOME_DIR @@ -704,17 +703,6 @@ # close server server.close() - @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets') - def test_create_unix_server_path_socket_error(self): - proto = MyProto(loop=self.loop) - sock = socket.socket() - with sock: - f = self.loop.create_unix_server(lambda: proto, '/test', sock=sock) - with self.assertRaisesRegex(ValueError, - 'path and sock can not be specified ' - 'at the same time'): - server = self.loop.run_until_complete(f) - def _create_ssl_context(self, certfile, keyfile=None): sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslcontext.options |= ssl.OP_NO_SSLv2 @@ -1787,11 +1775,6 @@ 'handle': h }) - def test_handle_weakref(self): - wd = weakref.WeakValueDictionary() - h = asyncio.Handle(lambda: None, (), object()) - wd['h'] = h # Would fail without __weakref__ slot. - class TimerTests(unittest.TestCase): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/test_selector_events.py --- a/Lib/test/test_asyncio/test_selector_events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncio/test_selector_events.py Sun Mar 23 09:44:28 2014 +0100 @@ -121,9 +121,8 @@ self.assertIsNone(self.loop._write_to_self()) def test_write_to_self_exception(self): - # _write_to_self() swallows OSError - self.loop._csock.send.side_effect = RuntimeError() - self.assertRaises(RuntimeError, self.loop._write_to_self) + self.loop._csock.send.side_effect = OSError() + self.assertRaises(OSError, self.loop._write_to_self) def test_sock_recv(self): sock = mock.Mock() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncio/test_tasks.py Sun Mar 23 09:44:28 2014 +0100 @@ -2,9 +2,7 @@ import gc import os.path -import types import unittest -import weakref from test.script_helper import assert_python_ok import asyncio @@ -1388,102 +1386,6 @@ self.assertRaises(ValueError, self.loop.run_until_complete, asyncio.wait([], loop=self.loop)) - def test_corowrapper_mocks_generator(self): - - def check(): - # A function that asserts various things. - # Called twice, with different debug flag values. - - @asyncio.coroutine - def coro(): - # The actual coroutine. - self.assertTrue(gen.gi_running) - yield from fut - - # A completed Future used to run the coroutine. - fut = asyncio.Future(loop=self.loop) - fut.set_result(None) - - # Call the coroutine. - gen = coro() - - # Check some properties. - self.assertTrue(asyncio.iscoroutine(gen)) - self.assertIsInstance(gen.gi_frame, types.FrameType) - self.assertFalse(gen.gi_running) - self.assertIsInstance(gen.gi_code, types.CodeType) - - # Run it. - self.loop.run_until_complete(gen) - - # The frame should have changed. - self.assertIsNone(gen.gi_frame) - - # Save debug flag. - old_debug = asyncio.tasks._DEBUG - try: - # Test with debug flag cleared. - asyncio.tasks._DEBUG = False - check() - - # Test with debug flag set. - asyncio.tasks._DEBUG = True - check() - - finally: - # Restore original debug flag. - asyncio.tasks._DEBUG = old_debug - - def test_yield_from_corowrapper(self): - old_debug = asyncio.tasks._DEBUG - asyncio.tasks._DEBUG = True - try: - @asyncio.coroutine - def t1(): - return (yield from t2()) - - @asyncio.coroutine - def t2(): - f = asyncio.Future(loop=self.loop) - asyncio.Task(t3(f), loop=self.loop) - return (yield from f) - - @asyncio.coroutine - def t3(f): - f.set_result((1, 2, 3)) - - task = asyncio.Task(t1(), loop=self.loop) - val = self.loop.run_until_complete(task) - self.assertEqual(val, (1, 2, 3)) - finally: - asyncio.tasks._DEBUG = old_debug - - def test_yield_from_corowrapper_send(self): - def foo(): - a = yield - return a - - def call(arg): - cw = asyncio.tasks.CoroWrapper(foo(), foo) - cw.send(None) - try: - cw.send(arg) - except StopIteration as ex: - return ex.args[0] - else: - raise AssertionError('StopIteration was expected') - - self.assertEqual(call((1, 2)), (1, 2)) - self.assertEqual(call('spam'), 'spam') - - def test_corowrapper_weakref(self): - wd = weakref.WeakValueDictionary() - def foo(): yield from [] - cw = asyncio.tasks.CoroWrapper(foo(), foo) - wd['cw'] = cw # Would fail without __weakref__ slot. - cw.gen = None # Suppress warning from __del__. - - class GatherTestsBase: def setUp(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/test_unix_events.py --- a/Lib/test/test_asyncio/test_unix_events.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncio/test_unix_events.py Sun Mar 23 09:44:28 2014 +0100 @@ -1335,6 +1335,7 @@ with self.ignore_warnings: self.watcher._sig_chld() + callback.assert_called(m.waitpid) if isinstance(self.watcher, asyncio.FastChildWatcher): # here the FastChildWatche enters a deadlock # (there is no way to prevent it) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncio/tests.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_asyncio/tests.txt Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,14 @@ +test_asyncio.test_base_events +test_asyncio.test_events +test_asyncio.test_futures +test_asyncio.test_locks +test_asyncio.test_proactor_events +test_asyncio.test_queues +test_asyncio.test_selector_events +test_asyncio.test_streams +test_asyncio.test_subprocess +test_asyncio.test_tasks +test_asyncio.test_transports +test_asyncio.test_unix_events +test_asyncio.test_windows_events +test_asyncio.test_windows_utils diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_asyncore.py Sun Mar 23 09:44:28 2014 +0100 @@ -316,6 +316,23 @@ 'warning: unhandled connect event'] self.assertEqual(lines, expected) + def test_issue_8594(self): + # XXX - this test is supposed to be removed in next major Python + # version + d = asyncore.dispatcher(socket.socket()) + # make sure the error message no longer refers to the socket + # object but the dispatcher instance instead + self.assertRaisesRegex(AttributeError, 'dispatcher instance', + getattr, d, 'foo') + # cheap inheritance with the underlying socket is supposed + # to still work but a DeprecationWarning is expected + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + family = d.family + self.assertEqual(family, socket.AF_INET) + self.assertEqual(len(w), 1) + self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) @@ -332,8 +349,9 @@ def handle_connect(self): pass +class DispatcherWithSendTests(unittest.TestCase): + usepoll = False -class DispatcherWithSendTests(unittest.TestCase): def setUp(self): pass @@ -383,6 +401,10 @@ self.fail("join() timed out") + +class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): + usepoll = True + @unittest.skipUnless(hasattr(asyncore, 'file_wrapper'), 'asyncore.file_wrapper required') class FileWrapperTest(unittest.TestCase): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_augassign.py --- a/Lib/test/test_augassign.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_augassign.py Sun Mar 23 09:44:28 2014 +0100 @@ -136,14 +136,6 @@ output.append("__imul__ called") return self - def __matmul__(self, val): - output.append("__matmul__ called") - def __rmatmul__(self, val): - output.append("__rmatmul__ called") - def __imatmul__(self, val): - output.append("__imatmul__ called") - return self - def __div__(self, val): output.append("__div__ called") def __rdiv__(self, val): @@ -241,10 +233,6 @@ 1 * x x *= 1 - x @ 1 - 1 @ x - x @= 1 - x / 1 1 / x x /= 1 @@ -291,9 +279,6 @@ __mul__ called __rmul__ called __imul__ called -__matmul__ called -__rmatmul__ called -__imatmul__ called __truediv__ called __rtruediv__ called __itruediv__ called diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_builtin.py Sun Mar 23 09:44:28 2014 +0100 @@ -1092,7 +1092,7 @@ self.assertAlmostEqual(pow(-1, 0.5), 1j) self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j) - self.assertRaises(ValueError, pow, -1, -2, 3) + self.assertRaises(TypeError, pow, -1, -2, 3) self.assertRaises(ValueError, pow, 1, 2, 0) self.assertRaises(TypeError, pow) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_capi.py --- a/Lib/test/test_capi.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_capi.py Sun Mar 23 09:44:28 2014 +0100 @@ -150,23 +150,6 @@ self.assertEqual(_testcapi.docstring_with_signature_and_extra_newlines.__text_signature__, "($module, /, parameter)") - def test_c_type_with_matrix_multiplication(self): - M = _testcapi.matmulType - m1 = M() - m2 = M() - self.assertEqual(m1 @ m2, ("matmul", m1, m2)) - self.assertEqual(m1 @ 42, ("matmul", m1, 42)) - self.assertEqual(42 @ m1, ("matmul", 42, m1)) - o = m1 - o @= m2 - self.assertEqual(o, ("imatmul", m1, m2)) - o = m1 - o @= 42 - self.assertEqual(o, ("imatmul", m1, 42)) - o = 42 - o @= m1 - self.assertEqual(o, ("matmul", 42, m1)) - @unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_codeccallbacks.py --- a/Lib/test/test_codeccallbacks.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_codeccallbacks.py Sun Mar 23 09:44:28 2014 +0100 @@ -819,7 +819,7 @@ def __getitem__(self, key): raise ValueError #self.assertRaises(ValueError, "\xff".translate, D()) - self.assertRaises(ValueError, "\xff".translate, {0xff: sys.maxunicode+1}) + self.assertRaises(TypeError, "\xff".translate, {0xff: sys.maxunicode+1}) self.assertRaises(TypeError, "\xff".translate, {0xff: ()}) def test_bug828737(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_collections.py --- a/Lib/test/test_collections.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_collections.py Sun Mar 23 09:44:28 2014 +0100 @@ -1187,21 +1187,6 @@ self.assertEqual(list(od.items()), pairs) self.assertEqual(list(reversed(od)), [t[0] for t in reversed(pairs)]) - self.assertEqual(list(reversed(od.keys())), - [t[0] for t in reversed(pairs)]) - self.assertEqual(list(reversed(od.values())), - [t[1] for t in reversed(pairs)]) - self.assertEqual(list(reversed(od.items())), list(reversed(pairs))) - - def test_detect_deletion_during_iteration(self): - od = OrderedDict.fromkeys('abc') - it = iter(od) - key = next(it) - del od[key] - with self.assertRaises(Exception): - # Note, the exact exception raised is not guaranteed - # The only guarantee that the next() will not succeed - next(it) def test_popitem(self): pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_csv.py --- a/Lib/test/test_csv.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_csv.py Sun Mar 23 09:44:28 2014 +0100 @@ -575,16 +575,6 @@ fileobj.readline() # header self.assertEqual(fileobj.read(), "10,,abc\r\n") - def test_write_multiple_dict_rows(self): - fileobj = StringIO() - writer = csv.DictWriter(fileobj, fieldnames=["f1", "f2", "f3"]) - writer.writeheader() - self.assertEqual(fileobj.getvalue(), "f1,f2,f3\r\n") - writer.writerows([{"f1": 1, "f2": "abc", "f3": "f"}, - {"f1": 2, "f2": 5, "f3": "xyz"}]) - self.assertEqual(fileobj.getvalue(), - "f1,f2,f3\r\n1,abc,f\r\n2,5,xyz\r\n") - def test_write_no_fields(self): fileobj = StringIO() self.assertRaises(TypeError, csv.DictWriter, fileobj) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_curses.py --- a/Lib/test/test_curses.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_curses.py Sun Mar 23 09:44:28 2014 +0100 @@ -17,7 +17,6 @@ import unittest from test.support import requires, import_module -import inspect requires('curses') # If either of these don't exist, skip the tests. @@ -332,34 +331,6 @@ else: raise AssertionError("TypeError not raised") -def test_issue21088(stdscr): - # - # http://bugs.python.org/issue21088 - # - # the bug: - # when converting curses.window.addch to Argument Clinic - # the first two parameters were switched. - - # if someday we can represent the signature of addch - # we will need to rewrite this test. - try: - signature = inspect.signature(stdscr.addch) - self.assertFalse(signature) - except ValueError: - # not generating a signature is fine. - pass - - # So. No signature for addch. - # But Argument Clinic gave us a human-readable equivalent - # as the first line of the docstring. So we parse that, - # and ensure that the parameters appear in the correct order. - # Since this is parsing output from Argument Clinic, we can - # be reasonably certain the generated parsing code will be - # correct too. - human_readable_signature = stdscr.addch.__doc__.split("\n")[0] - offset = human_readable_signature.find("[y, x,]") - assert offset >= 0, "" - def main(stdscr): curses.savetty() try: @@ -373,7 +344,6 @@ test_unget_wch(stdscr) test_issue10570() test_encoding(stdscr) - test_issue21088(stdscr) finally: curses.resetty() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_dbm_dumb.py --- a/Lib/test/test_dbm_dumb.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_dbm_dumb.py Sun Mar 23 09:44:28 2014 +0100 @@ -3,12 +3,10 @@ """ import io -import operator import os import unittest import dbm.dumb as dumbdbm from test import support -from functools import partial _fname = support.TESTFN @@ -192,31 +190,12 @@ with dumbdbm.open(_fname, 'r') as db: self.assertEqual(list(db.keys()), [b"dumbdbm context manager"]) - with self.assertRaises(dumbdbm.error): + # This currently just raises AttributeError rather than a specific + # exception like the GNU or NDBM based implementations. See + # http://bugs.python.org/issue19385 for details. + with self.assertRaises(Exception): db.keys() - def test_check_closed(self): - f = dumbdbm.open(_fname, 'c') - f.close() - - for meth in (partial(operator.delitem, f), - partial(operator.setitem, f, 'b'), - partial(operator.getitem, f), - partial(operator.contains, f)): - with self.assertRaises(dumbdbm.error) as cm: - meth('test') - self.assertEqual(str(cm.exception), - "DBM object has already been closed") - - for meth in (operator.methodcaller('keys'), - operator.methodcaller('iterkeys'), - operator.methodcaller('items'), - len): - with self.assertRaises(dumbdbm.error) as cm: - meth(f) - self.assertEqual(str(cm.exception), - "DBM object has already been closed") - def tearDown(self): _delete_files() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_decimal.py Sun Mar 23 09:44:28 2014 +0100 @@ -33,13 +33,12 @@ import numbers import locale from test.support import (run_unittest, run_doctest, is_resource_enabled, - requires_IEEE_754, requires_docstrings) + requires_IEEE_754) from test.support import (check_warnings, import_fresh_module, TestFailed, run_with_locale, cpython_only) import random import time import warnings -import inspect try: import threading except ImportError: @@ -2432,23 +2431,6 @@ self.assertIsInstance(r, C.Decimal) self.assertEqual(r, x) - x = C.Decimal('-3.123e81723').as_tuple() - y = P.Decimal('-3.123e81723').as_tuple() - - sys.modules['decimal'] = C - sx = pickle.dumps(x) - sys.modules['decimal'] = P - r = pickle.loads(sx) - self.assertIsInstance(r, P.DecimalTuple) - self.assertEqual(r, y) - - sys.modules['decimal'] = P - sy = pickle.dumps(y) - sys.modules['decimal'] = C - r = pickle.loads(sy) - self.assertIsInstance(r, C.DecimalTuple) - self.assertEqual(r, x) - sys.modules['decimal'] = savedecimal def test_int(self): @@ -4449,6 +4431,18 @@ class PyFunctionality(unittest.TestCase): """Extra functionality in decimal.py""" + def test_py_quantize_watchexp(self): + # watchexp functionality + Decimal = P.Decimal + localcontext = P.localcontext + + with localcontext() as c: + c.prec = 1 + c.Emax = 1 + c.Emin = -1 + x = Decimal(99999).quantize(Decimal("1e3"), watchexp=False) + self.assertEqual(x, Decimal('1.00E+5')) + def test_py_alternate_formatting(self): # triples giving a format, a Decimal, and the expected result Decimal = P.Decimal @@ -5391,143 +5385,6 @@ y = Decimal(10**(9*25)).__sizeof__() self.assertEqual(y, x+4) -@requires_docstrings -@unittest.skipUnless(C, "test requires C version") -class SignatureTest(unittest.TestCase): - """Function signatures""" - - def test_inspect_module(self): - for attr in dir(P): - if attr.startswith('_'): - continue - p_func = getattr(P, attr) - c_func = getattr(C, attr) - if (attr == 'Decimal' or attr == 'Context' or - inspect.isfunction(p_func)): - p_sig = inspect.signature(p_func) - c_sig = inspect.signature(c_func) - - # parameter names: - c_names = list(c_sig.parameters.keys()) - p_names = [x for x in p_sig.parameters.keys() if not - x.startswith('_')] - - self.assertEqual(c_names, p_names, - msg="parameter name mismatch in %s" % p_func) - - c_kind = [x.kind for x in c_sig.parameters.values()] - p_kind = [x[1].kind for x in p_sig.parameters.items() if not - x[0].startswith('_')] - - # parameters: - if attr != 'setcontext': - self.assertEqual(c_kind, p_kind, - msg="parameter kind mismatch in %s" % p_func) - - def test_inspect_types(self): - - POS = inspect._ParameterKind.POSITIONAL_ONLY - POS_KWD = inspect._ParameterKind.POSITIONAL_OR_KEYWORD - - # Type heuristic (type annotations would help!): - pdict = {C: {'other': C.Decimal(1), - 'third': C.Decimal(1), - 'x': C.Decimal(1), - 'y': C.Decimal(1), - 'z': C.Decimal(1), - 'a': C.Decimal(1), - 'b': C.Decimal(1), - 'c': C.Decimal(1), - 'exp': C.Decimal(1), - 'modulo': C.Decimal(1), - 'num': "1", - 'f': 1.0, - 'rounding': C.ROUND_HALF_UP, - 'context': C.getcontext()}, - P: {'other': P.Decimal(1), - 'third': P.Decimal(1), - 'a': P.Decimal(1), - 'b': P.Decimal(1), - 'c': P.Decimal(1), - 'exp': P.Decimal(1), - 'modulo': P.Decimal(1), - 'num': "1", - 'f': 1.0, - 'rounding': P.ROUND_HALF_UP, - 'context': P.getcontext()}} - - def mkargs(module, sig): - args = [] - kwargs = {} - for name, param in sig.parameters.items(): - if name == 'self': continue - if param.kind == POS: - args.append(pdict[module][name]) - elif param.kind == POS_KWD: - kwargs[name] = pdict[module][name] - else: - raise TestFailed("unexpected parameter kind") - return args, kwargs - - def tr(s): - """The C Context docstrings use 'x' in order to prevent confusion - with the article 'a' in the descriptions.""" - if s == 'x': return 'a' - if s == 'y': return 'b' - if s == 'z': return 'c' - return s - - def doit(ty): - p_type = getattr(P, ty) - c_type = getattr(C, ty) - for attr in dir(p_type): - if attr.startswith('_'): - continue - p_func = getattr(p_type, attr) - c_func = getattr(c_type, attr) - if inspect.isfunction(p_func): - p_sig = inspect.signature(p_func) - c_sig = inspect.signature(c_func) - - # parameter names: - p_names = list(p_sig.parameters.keys()) - c_names = [tr(x) for x in c_sig.parameters.keys()] - - self.assertEqual(c_names, p_names, - msg="parameter name mismatch in %s" % p_func) - - p_kind = [x.kind for x in p_sig.parameters.values()] - c_kind = [x.kind for x in c_sig.parameters.values()] - - # 'self' parameter: - self.assertIs(p_kind[0], POS_KWD) - self.assertIs(c_kind[0], POS) - - # remaining parameters: - if ty == 'Decimal': - self.assertEqual(c_kind[1:], p_kind[1:], - msg="parameter kind mismatch in %s" % p_func) - else: # Context methods are positional only in the C version. - self.assertEqual(len(c_kind), len(p_kind), - msg="parameter kind mismatch in %s" % p_func) - - # Run the function: - args, kwds = mkargs(C, c_sig) - try: - getattr(c_type(9), attr)(*args, **kwds) - except Exception as err: - raise TestFailed("invalid signature for %s: %s %s" % (c_func, args, kwds)) - - args, kwds = mkargs(P, p_sig) - try: - getattr(p_type(9), attr)(*args, **kwds) - except Exception as err: - raise TestFailed("invalid signature for %s: %s %s" % (p_func, args, kwds)) - - doit('Decimal') - doit('Context') - - all_tests = [ CExplicitConstructionTest, PyExplicitConstructionTest, CImplicitConstructionTest, PyImplicitConstructionTest, @@ -5553,7 +5410,6 @@ all_tests = all_tests[1::2] else: all_tests.insert(0, CheckAttributes) - all_tests.insert(1, SignatureTest) def test_main(arith=False, verbose=None, todo_tests=None, debug=None): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_descr.py --- a/Lib/test/test_descr.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_descr.py Sun Mar 23 09:44:28 2014 +0100 @@ -4160,7 +4160,6 @@ ('__add__', 'x + y', 'x += y'), ('__sub__', 'x - y', 'x -= y'), ('__mul__', 'x * y', 'x *= y'), - ('__matmul__', 'x @ y', 'x @= y'), ('__truediv__', 'operator.truediv(x, y)', None), ('__floordiv__', 'operator.floordiv(x, y)', None), ('__div__', 'x / y', 'x /= y'), diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_devpoll.py --- a/Lib/test/test_devpoll.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_devpoll.py Sun Mar 23 09:44:28 2014 +0100 @@ -9,8 +9,10 @@ import unittest from test.support import TESTFN, run_unittest, cpython_only -if not hasattr(select, 'devpoll') : - raise unittest.SkipTest('test works only on Solaris OS family') +try: + select.devpoll +except AttributeError: + raise unittest.SkipTest("select.devpoll not defined") def find_ready_matching(ready, flag): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_doctest.py Sun Mar 23 09:44:28 2014 +0100 @@ -2096,9 +2096,22 @@ >>> suite.run(unittest.TestResult()) - The module need not contain any docstrings either: - - >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings') + However, if DocTestSuite finds no docstrings, it raises an error: + + >>> try: + ... doctest.DocTestSuite('test.sample_doctest_no_docstrings') + ... except ValueError as e: + ... error = e + + >>> print(error.args[1]) + has no docstrings + + You can prevent this error by passing a DocTestFinder instance with + the `exclude_empty` keyword argument set to False: + + >>> finder = doctest.DocTestFinder(exclude_empty=False) + >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings', + ... test_finder=finder) >>> suite.run(unittest.TestResult()) @@ -2108,22 +2121,6 @@ >>> suite.run(unittest.TestResult()) - We can also provide a DocTestFinder: - - >>> finder = doctest.DocTestFinder() - >>> suite = doctest.DocTestSuite('test.sample_doctest', - ... test_finder=finder) - >>> suite.run(unittest.TestResult()) - - - The DocTestFinder need not return any tests: - - >>> finder = doctest.DocTestFinder() - >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings', - ... test_finder=finder) - >>> suite.run(unittest.TestResult()) - - We can supply global variables. If we pass globs, they will be used instead of the module globals. Here we'll pass an empty globals, triggering an extra error: @@ -2171,7 +2168,7 @@ >>> test.test_doctest.sillySetup Traceback (most recent call last): ... - AttributeError: module 'test.test_doctest' has no attribute 'sillySetup' + AttributeError: 'module' object has no attribute 'sillySetup' The setUp and tearDown funtions are passed test objects. Here we'll use the setUp function to supply the missing variable y: @@ -2317,7 +2314,7 @@ >>> test.test_doctest.sillySetup Traceback (most recent call last): ... - AttributeError: module 'test.test_doctest' has no attribute 'sillySetup' + AttributeError: 'module' object has no attribute 'sillySetup' The setUp and tearDown funtions are passed test objects. Here, we'll use a setUp function to set the favorite color in @@ -2900,7 +2897,7 @@ def test_main(): # Check the doctest cases in doctest itself: - ret = support.run_doctest(doctest, verbosity=True) + support.run_doctest(doctest, verbosity=True) # Check the doctest cases defined here: from test import test_doctest support.run_doctest(test_doctest, verbosity=True) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_ensurepip.py --- a/Lib/test/test_ensurepip.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_ensurepip.py Sun Mar 23 09:44:28 2014 +0100 @@ -153,7 +153,7 @@ def test_altinstall_default_pip_conflict(self): with self.assertRaises(ValueError): ensurepip.bootstrap(altinstall=True, default_pip=True) - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() @requires_usable_pip def test_pip_environment_variables_removed(self): @@ -194,7 +194,7 @@ def test_uninstall_skipped_when_not_installed(self): with fake_pip(None): ensurepip._uninstall_helper() - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() def test_uninstall_skipped_with_warning_for_wrong_version(self): with fake_pip("not a valid version"): @@ -202,7 +202,7 @@ ensurepip._uninstall_helper() warning = stderr.getvalue().strip() self.assertIn("only uninstall a matching version", warning) - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() @requires_usable_pip @@ -272,7 +272,7 @@ self.os_environ["PIP_THIS_SHOULD_STAY"] = "test fodder" with self.assertRaisesRegex(RuntimeError, "requires SSL/TLS"): ensurepip_no_ssl.bootstrap() - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ) def test_uninstall_requires_ssl(self): @@ -280,7 +280,7 @@ with self.assertRaisesRegex(RuntimeError, "requires SSL/TLS"): with fake_pip(): ensurepip_no_ssl._uninstall_helper() - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ) def test_main_exits_early_with_warning(self): @@ -288,7 +288,7 @@ ensurepip_no_ssl._main(["--version"]) warning = stderr.getvalue().strip() self.assertTrue(warning.endswith("requires SSL/TLS"), warning) - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() # Basic testing of the main functions and their argument parsing @@ -303,7 +303,7 @@ ensurepip._main(["--version"]) result = stdout.getvalue().strip() self.assertEqual(result, EXPECTED_VERSION_OUTPUT) - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() @requires_usable_pip def test_basic_bootstrapping(self): @@ -328,7 +328,7 @@ ensurepip._uninstall._main(["--version"]) result = stdout.getvalue().strip() self.assertEqual(result, EXPECTED_VERSION_OUTPUT) - self.assertFalse(self.run_pip.called) + self.run_pip.assert_not_called() @requires_usable_pip def test_basic_uninstall(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_exceptions.py --- a/Lib/test/test_exceptions.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_exceptions.py Sun Mar 23 09:44:28 2014 +0100 @@ -763,7 +763,7 @@ pass self.assertEqual(e, (None, None, None)) - def test_unicode_change_attributes(self): + def testUnicodeChangeAttributes(self): # See issue 7309. This was a crasher. u = UnicodeEncodeError('baz', 'xxxxx', 1, 5, 'foo') @@ -800,12 +800,6 @@ u.start = 1000 self.assertEqual(str(u), "can't translate characters in position 1000-4: 965230951443685724997") - def test_unicode_errors_no_object(self): - # See issue #21134. - klasses = UnicodeEncodeError, UnicodeDecodeError, UnicodeTranslateError - for klass in klasses: - self.assertEqual(str(klass.__new__(klass)), "") - @no_tracing def test_badisinstance(self): # Bug #2542: if issubclass(e, MyException) raises an exception, diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_filecmp.py --- a/Lib/test/test_filecmp.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_filecmp.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,12 +1,7 @@ -import filecmp -import os -import shutil -import tempfile +import os, filecmp, shutil, tempfile import unittest - from test import support - class FileCompareTestCase(unittest.TestCase): def setUp(self): self.name = support.TESTFN @@ -14,11 +9,13 @@ self.name_diff = support.TESTFN + '-diff' data = 'Contents of file go here.\n' for name in [self.name, self.name_same, self.name_diff]: - with open(name, 'w') as output: - output.write(data) + output = open(name, 'w') + output.write(data) + output.close() - with open(self.name_diff, 'a+') as output: - output.write('An extra line.\n') + output = open(self.name_diff, 'a+') + output.write('An extra line.\n') + output.close() self.dir = tempfile.gettempdir() def tearDown(self): @@ -69,11 +66,13 @@ fn = 'FiLe' # Verify case-insensitive comparison else: fn = 'file' - with open(os.path.join(dir, fn), 'w') as output: - output.write(data) + output = open(os.path.join(dir, fn), 'w') + output.write(data) + output.close() - with open(os.path.join(self.dir_diff, 'file2'), 'w') as output: - output.write('An extra file.\n') + output = open(os.path.join(self.dir_diff, 'file2'), 'w') + output.write('An extra file.\n') + output.close() def tearDown(self): for dir in (self.dir, self.dir_same, self.dir_diff): @@ -100,8 +99,9 @@ "Comparing directory to same fails") # Add different file2 - with open(os.path.join(self.dir, 'file2'), 'w') as output: - output.write('Different contents.\n') + output = open(os.path.join(self.dir, 'file2'), 'w') + output.write('Different contents.\n') + output.close() self.assertFalse(filecmp.cmpfiles(self.dir, self.dir_same, ['file', 'file2']) == @@ -120,94 +120,30 @@ else: self.assertEqual([d.left_list, d.right_list],[['file'], ['file']]) self.assertEqual(d.common, ['file']) - self.assertEqual(d.left_only, []) - self.assertEqual(d.right_only, []) + self.assertTrue(d.left_only == d.right_only == []) self.assertEqual(d.same_files, ['file']) self.assertEqual(d.diff_files, []) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_same), - "Identical files : ['file']", - ] - self._assert_report(d.report, expected_report) - # Check attributes for comparison of two different directories (right) + # Check attributes for comparison of two different directories left_dir, right_dir = self.dir, self.dir_diff d = filecmp.dircmp(left_dir, right_dir) self.assertEqual(d.left, left_dir) self.assertEqual(d.right, right_dir) self.assertEqual(d.left_list, ['file']) - self.assertEqual(d.right_list, ['file', 'file2']) + self.assertTrue(d.right_list == ['file', 'file2']) self.assertEqual(d.common, ['file']) self.assertEqual(d.left_only, []) self.assertEqual(d.right_only, ['file2']) self.assertEqual(d.same_files, ['file']) self.assertEqual(d.diff_files, []) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_diff), - "Only in {} : ['file2']".format(self.dir_diff), - "Identical files : ['file']", - ] - self._assert_report(d.report, expected_report) - - # Check attributes for comparison of two different directories (left) - left_dir, right_dir = self.dir, self.dir_diff - shutil.move( - os.path.join(self.dir_diff, 'file2'), - os.path.join(self.dir, 'file2') - ) - d = filecmp.dircmp(left_dir, right_dir) - self.assertEqual(d.left, left_dir) - self.assertEqual(d.right, right_dir) - self.assertEqual(d.left_list, ['file', 'file2']) - self.assertEqual(d.right_list, ['file']) - self.assertEqual(d.common, ['file']) - self.assertEqual(d.left_only, ['file2']) - self.assertEqual(d.right_only, []) - self.assertEqual(d.same_files, ['file']) - self.assertEqual(d.diff_files, []) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_diff), - "Only in {} : ['file2']".format(self.dir), - "Identical files : ['file']", - ] - self._assert_report(d.report, expected_report) # Add different file2 - with open(os.path.join(self.dir_diff, 'file2'), 'w') as output: - output.write('Different contents.\n') + output = open(os.path.join(self.dir, 'file2'), 'w') + output.write('Different contents.\n') + output.close() d = filecmp.dircmp(self.dir, self.dir_diff) self.assertEqual(d.same_files, ['file']) self.assertEqual(d.diff_files, ['file2']) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_diff), - "Identical files : ['file']", - "Differing files : ['file2']", - ] - self._assert_report(d.report, expected_report) - - def test_report_partial_closure(self): - left_dir, right_dir = self.dir, self.dir_same - d = filecmp.dircmp(left_dir, right_dir) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_same), - "Identical files : ['file']", - ] - self._assert_report(d.report_partial_closure, expected_report) - - def test_report_full_closure(self): - left_dir, right_dir = self.dir, self.dir_same - d = filecmp.dircmp(left_dir, right_dir) - expected_report = [ - "diff {} {}".format(self.dir, self.dir_same), - "Identical files : ['file']", - ] - self._assert_report(d.report_full_closure, expected_report) - - def _assert_report(self, dircmp_report, expected_report_lines): - with support.captured_stdout() as stdout: - dircmp_report() - report_lines = stdout.getvalue().strip().split('\n') - self.assertEqual(report_lines, expected_report_lines) def test_main(): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_fractions.py --- a/Lib/test/test_fractions.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_fractions.py Sun Mar 23 09:44:28 2014 +0100 @@ -330,6 +330,7 @@ self.assertTypedEquals(F(-2, 10), round(F(-15, 100), 1)) self.assertTypedEquals(F(-2, 10), round(F(-25, 100), 1)) + def testArithmetic(self): self.assertEqual(F(1, 2), F(1, 10) + F(2, 5)) self.assertEqual(F(-3, 10), F(1, 10) - F(2, 5)) @@ -401,8 +402,6 @@ self.assertTypedEquals(2.0 , 4 ** F(1, 2)) self.assertTypedEquals(0.25, 2.0 ** F(-2, 1)) self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** F(1, 10)) - self.assertRaises(ZeroDivisionError, operator.pow, - F(0, 1), -2) def testMixingWithDecimal(self): # Decimal refuses mixed arithmetic (but not mixed comparisons) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_gc.py --- a/Lib/test/test_gc.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_gc.py Sun Mar 23 09:44:28 2014 +0100 @@ -580,38 +580,6 @@ # would be damaged, with an empty __dict__. self.assertEqual(x, None) - def test_bug21435(self): - # This is a poor test - its only virtue is that it happened to - # segfault on Tim's Windows box before the patch for 21435 was - # applied. That's a nasty bug relying on specific pieces of cyclic - # trash appearing in exactly the right order in finalize_garbage()'s - # input list. - # But there's no reliable way to force that order from Python code, - # so over time chances are good this test won't really be testing much - # of anything anymore. Still, if it blows up, there's _some_ - # problem ;-) - gc.collect() - - class A: - pass - - class B: - def __init__(self, x): - self.x = x - - def __del__(self): - self.attr = None - - def do_work(): - a = A() - b = B(A()) - - a.attr = b - b.attr = a - - do_work() - gc.collect() # this blows up (bad C pointer) when it fails - @cpython_only def test_garbage_at_shutdown(self): import subprocess diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_getpass.py --- a/Lib/test/test_getpass.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_getpass.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,7 +1,7 @@ import getpass import os import unittest -from io import BytesIO, StringIO, TextIOWrapper +from io import BytesIO, StringIO from unittest import mock from test import support @@ -69,14 +69,6 @@ getpass._raw_input(stream=StringIO()) mock_input.readline.assert_called_once_with() - @mock.patch('sys.stdin') - def test_uses_stdin_as_different_locale(self, mock_input): - stream = TextIOWrapper(BytesIO(), encoding="ascii") - mock_input.readline.return_value = "HasÅ‚o: " - getpass._raw_input(prompt="HasÅ‚o: ",stream=stream) - mock_input.readline.assert_called_once_with() - - def test_raises_on_empty_input(self): input = StringIO('') self.assertRaises(EOFError, getpass._raw_input, input=input) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_grammar.py --- a/Lib/test/test_grammar.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_grammar.py Sun Mar 23 09:44:28 2014 +0100 @@ -985,20 +985,6 @@ self.assertFalse((False is 2) is 3) self.assertFalse(False is 2 is 3) - def test_matrix_mul(self): - # This is not intended to be a comprehensive test, rather just to be few - # samples of the @ operator in test_grammar.py. - class M: - def __matmul__(self, o): - return 4 - def __imatmul__(self, o): - self.other = o - return self - m = M() - self.assertEqual(m @ m, 4) - m @= 42 - self.assertEqual(m.other, 42) - def test_main(): run_unittest(TokenTests, GrammarTests) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_httplib.py Sun Mar 23 09:44:28 2014 +0100 @@ -41,15 +41,13 @@ HOST = support.HOST class FakeSocket: - def __init__(self, text, fileclass=io.BytesIO, host=None, port=None): + def __init__(self, text, fileclass=io.BytesIO): if isinstance(text, str): text = text.encode("ascii") self.text = text self.fileclass = fileclass self.data = b'' self.sendall_calls = 0 - self.host = host - self.port = port def sendall(self, data): self.sendall_calls += 1 @@ -63,9 +61,6 @@ self.file.close = lambda:None #nerf close () return self.file - def close(self): - pass - class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): @@ -1209,52 +1204,11 @@ header = self.resp.getheader('No-Such-Header',default=42) self.assertEqual(header, 42) -class TunnelTests(TestCase): - - def test_connect(self): - response_text = ( - 'HTTP/1.0 200 OK\r\n\r\n' # Reply to CONNECT - 'HTTP/1.1 200 OK\r\n' # Reply to HEAD - 'Content-Length: 42\r\n\r\n' - ) - - def create_connection(address, timeout=None, source_address=None): - return FakeSocket(response_text, host=address[0], - port=address[1]) - - conn = client.HTTPConnection('proxy.com') - conn._create_connection = create_connection - - # Once connected, we shouldn't be able to tunnel anymore - conn.connect() - self.assertRaises(RuntimeError, conn.set_tunnel, - 'destination.com') - - # But if we close the connection, we're good - conn.close() - conn.set_tunnel('destination.com') - conn.request('HEAD', '/', '') - - self.assertEqual(conn.sock.host, 'proxy.com') - self.assertEqual(conn.sock.port, 80) - self.assertTrue(b'CONNECT destination.com' in conn.sock.data) - self.assertTrue(b'Host: destination.com' in conn.sock.data) - - # This test should be removed when CONNECT gets the HTTP/1.1 blessing - self.assertTrue(b'Host: proxy.com' not in conn.sock.data) - - conn.close() - conn.request('PUT', '/', '') - self.assertEqual(conn.sock.host, 'proxy.com') - self.assertEqual(conn.sock.port, 80) - self.assertTrue(b'CONNECT destination.com' in conn.sock.data) - self.assertTrue(b'Host: destination.com' in conn.sock.data) - def test_main(verbose=None): support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTest, RequestBodyTest, SourceAddressTest, HTTPResponseTest, ExtendedReadTest, - ExtendedReadTestChunked, TunnelTests) + ExtendedReadTestChunked) if __name__ == '__main__': test_main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_idle.py --- a/Lib/test/test_idle.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_idle.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,12 +1,24 @@ import unittest from test import support -from test.support import import_module +from test.support import import_module, use_resources # Skip test if _thread or _tkinter wasn't built or idlelib was deleted. import_module('threading') # imported by PyShell, imports _thread tk = import_module('tkinter') # imports _tkinter idletest = import_module('idlelib.idle_test') +# If buildbot improperly sets gui resource (#18365, #18441), remove it +# so requires('gui') tests are skipped while non-gui tests still run. +# If there is a problem with Macs, see #18441, msg 193805 +if use_resources and 'gui' in use_resources: + try: + root = tk.Tk() + root.destroy() + del root + except tk.TclError: + while 'gui' in use_resources: + use_resources.remove('gui') + # Without test_main present, regrtest.runtest_inner (line1219) calls # unittest.TestLoader().loadTestsFromModule(this_module) which calls # load_tests() if it finds it. (Unittest.main does the same.) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/builtin/test_finder.py --- a/Lib/test/test_importlib/builtin/test_finder.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/builtin/test_finder.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ from .. import abc from .. import util +from . import util as builtin_util frozen_machinery, source_machinery = util.import_importlib('importlib.machinery') @@ -7,15 +8,14 @@ import unittest -@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module') class FindSpecTests(abc.FinderTests): """Test find_spec() for built-in modules.""" def test_module(self): # Common case. - with util.uncache(util.BUILTINS.good_name): - found = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name) + with util.uncache(builtin_util.NAME): + found = self.machinery.BuiltinImporter.find_spec(builtin_util.NAME) self.assertTrue(found) self.assertEqual(found.origin, 'built-in') @@ -39,8 +39,8 @@ def test_ignore_path(self): # The value for 'path' should always trigger a failed import. - with util.uncache(util.BUILTINS.good_name): - spec = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name, + with util.uncache(builtin_util.NAME): + spec = self.machinery.BuiltinImporter.find_spec(builtin_util.NAME, ['pkg']) self.assertIsNone(spec) @@ -48,15 +48,14 @@ machinery=[frozen_machinery, source_machinery]) -@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module') class FinderTests(abc.FinderTests): """Test find_module() for built-in modules.""" def test_module(self): # Common case. - with util.uncache(util.BUILTINS.good_name): - found = self.machinery.BuiltinImporter.find_module(util.BUILTINS.good_name) + with util.uncache(builtin_util.NAME): + found = self.machinery.BuiltinImporter.find_module(builtin_util.NAME) self.assertTrue(found) self.assertTrue(hasattr(found, 'load_module')) @@ -73,8 +72,8 @@ def test_ignore_path(self): # The value for 'path' should always trigger a failed import. - with util.uncache(util.BUILTINS.good_name): - loader = self.machinery.BuiltinImporter.find_module(util.BUILTINS.good_name, + with util.uncache(builtin_util.NAME): + loader = self.machinery.BuiltinImporter.find_module(builtin_util.NAME, ['pkg']) self.assertIsNone(loader) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/builtin/test_loader.py --- a/Lib/test/test_importlib/builtin/test_loader.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/builtin/test_loader.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ from .. import abc from .. import util +from . import util as builtin_util frozen_machinery, source_machinery = util.import_importlib('importlib.machinery') @@ -7,7 +8,7 @@ import types import unittest -@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module') + class LoaderTests(abc.LoaderTests): """Test load_module() for built-in modules.""" @@ -28,8 +29,8 @@ def test_module(self): # Common case. - with util.uncache(util.BUILTINS.good_name): - module = self.load_module(util.BUILTINS.good_name) + with util.uncache(builtin_util.NAME): + module = self.load_module(builtin_util.NAME) self.verify(module) # Built-in modules cannot be a package. @@ -40,9 +41,9 @@ def test_module_reuse(self): # Test that the same module is used in a reload. - with util.uncache(util.BUILTINS.good_name): - module1 = self.load_module(util.BUILTINS.good_name) - module2 = self.load_module(util.BUILTINS.good_name) + with util.uncache(builtin_util.NAME): + module1 = self.load_module(builtin_util.NAME) + module2 = self.load_module(builtin_util.NAME) self.assertIs(module1, module2) def test_unloadable(self): @@ -69,34 +70,32 @@ machinery=[frozen_machinery, source_machinery]) -@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module') class InspectLoaderTests: """Tests for InspectLoader methods for BuiltinImporter.""" def test_get_code(self): # There is no code object. - result = self.machinery.BuiltinImporter.get_code(util.BUILTINS.good_name) + result = self.machinery.BuiltinImporter.get_code(builtin_util.NAME) self.assertIsNone(result) def test_get_source(self): # There is no source. - result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name) + result = self.machinery.BuiltinImporter.get_source(builtin_util.NAME) self.assertIsNone(result) def test_is_package(self): # Cannot be a package. - result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name) + result = self.machinery.BuiltinImporter.is_package(builtin_util.NAME) self.assertTrue(not result) - @unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in') def test_not_builtin(self): # Modules not built-in should raise ImportError. for meth_name in ('get_code', 'get_source', 'is_package'): method = getattr(self.machinery.BuiltinImporter, meth_name) with self.assertRaises(ImportError) as cm: - method(util.BUILTINS.bad_name) - self.assertRaises(util.BUILTINS.bad_name) + method(builtin_util.BAD_NAME) + self.assertRaises(builtin_util.BAD_NAME) Frozen_InspectLoaderTests, Source_InspectLoaderTests = util.test_both( InspectLoaderTests, diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/builtin/util.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_importlib/builtin/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,7 @@ +import sys + +assert 'errno' in sys.builtin_module_names +NAME = 'errno' + +assert 'importlib' not in sys.builtin_module_names +BAD_NAME = 'importlib' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/extension/test_case_sensitivity.py --- a/Lib/test/test_importlib/extension/test_case_sensitivity.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/extension/test_case_sensitivity.py Sun Mar 23 09:44:28 2014 +0100 @@ -4,21 +4,22 @@ import unittest from .. import util +from . import util as ext_util frozen_machinery, source_machinery = util.import_importlib('importlib.machinery') # XXX find_spec tests -@unittest.skipIf(util.EXTENSIONS.filename is None, '_testcapi not available') +@unittest.skipIf(ext_util.FILENAME is None, '_testcapi not available') @util.case_insensitive_tests class ExtensionModuleCaseSensitivityTest: def find_module(self): - good_name = util.EXTENSIONS.name + good_name = ext_util.NAME bad_name = good_name.upper() assert good_name != bad_name - finder = self.machinery.FileFinder(util.EXTENSIONS.path, + finder = self.machinery.FileFinder(ext_util.PATH, (self.machinery.ExtensionFileLoader, self.machinery.EXTENSION_SUFFIXES)) return finder.find_module(bad_name) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/extension/test_finder.py --- a/Lib/test/test_importlib/extension/test_finder.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/extension/test_finder.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,7 +1,8 @@ from .. import abc -from .. import util +from .. import util as test_util +from . import util -machinery = util.import_importlib('importlib.machinery') +machinery = test_util.import_importlib('importlib.machinery') import unittest import warnings @@ -13,7 +14,7 @@ """Test the finder for extension modules.""" def find_module(self, fullname): - importer = self.machinery.FileFinder(util.EXTENSIONS.path, + importer = self.machinery.FileFinder(util.PATH, (self.machinery.ExtensionFileLoader, self.machinery.EXTENSION_SUFFIXES)) with warnings.catch_warnings(): @@ -21,7 +22,7 @@ return importer.find_module(fullname) def test_module(self): - self.assertTrue(self.find_module(util.EXTENSIONS.name)) + self.assertTrue(self.find_module(util.NAME)) # No extension module as an __init__ available for testing. test_package = test_package_in_package = None @@ -35,7 +36,7 @@ def test_failure(self): self.assertIsNone(self.find_module('asdfjkl;')) -Frozen_FinderTests, Source_FinderTests = util.test_both( +Frozen_FinderTests, Source_FinderTests = test_util.test_both( FinderTests, machinery=machinery) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/extension/test_loader.py --- a/Lib/test/test_importlib/extension/test_loader.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/extension/test_loader.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,3 +1,4 @@ +from . import util as ext_util from .. import abc from .. import util @@ -14,8 +15,8 @@ """Test load_module() for extension modules.""" def setUp(self): - self.loader = self.machinery.ExtensionFileLoader(util.EXTENSIONS.name, - util.EXTENSIONS.file_path) + self.loader = self.machinery.ExtensionFileLoader(ext_util.NAME, + ext_util.FILEPATH) def load_module(self, fullname): return self.loader.load_module(fullname) @@ -28,23 +29,23 @@ self.load_module('XXX') def test_equality(self): - other = self.machinery.ExtensionFileLoader(util.EXTENSIONS.name, - util.EXTENSIONS.file_path) + other = self.machinery.ExtensionFileLoader(ext_util.NAME, + ext_util.FILEPATH) self.assertEqual(self.loader, other) def test_inequality(self): - other = self.machinery.ExtensionFileLoader('_' + util.EXTENSIONS.name, - util.EXTENSIONS.file_path) + other = self.machinery.ExtensionFileLoader('_' + ext_util.NAME, + ext_util.FILEPATH) self.assertNotEqual(self.loader, other) def test_module(self): - with util.uncache(util.EXTENSIONS.name): - module = self.load_module(util.EXTENSIONS.name) - for attr, value in [('__name__', util.EXTENSIONS.name), - ('__file__', util.EXTENSIONS.file_path), + with util.uncache(ext_util.NAME): + module = self.load_module(ext_util.NAME) + for attr, value in [('__name__', ext_util.NAME), + ('__file__', ext_util.FILEPATH), ('__package__', '')]: self.assertEqual(getattr(module, attr), value) - self.assertIn(util.EXTENSIONS.name, sys.modules) + self.assertIn(ext_util.NAME, sys.modules) self.assertIsInstance(module.__loader__, self.machinery.ExtensionFileLoader) @@ -55,9 +56,9 @@ test_lacking_parent = None def test_module_reuse(self): - with util.uncache(util.EXTENSIONS.name): - module1 = self.load_module(util.EXTENSIONS.name) - module2 = self.load_module(util.EXTENSIONS.name) + with util.uncache(ext_util.NAME): + module1 = self.load_module(ext_util.NAME) + module2 = self.load_module(ext_util.NAME) self.assertIs(module1, module2) # No easy way to trigger a failure after a successful import. @@ -70,7 +71,7 @@ self.assertEqual(cm.exception.name, name) def test_is_package(self): - self.assertFalse(self.loader.is_package(util.EXTENSIONS.name)) + self.assertFalse(self.loader.is_package(ext_util.NAME)) for suffix in self.machinery.EXTENSION_SUFFIXES: path = os.path.join('some', 'path', 'pkg', '__init__' + suffix) loader = self.machinery.ExtensionFileLoader('pkg', path) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/extension/test_path_hook.py --- a/Lib/test/test_importlib/extension/test_path_hook.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/extension/test_path_hook.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,7 @@ -from .. import util +from .. import util as test_util +from . import util -machinery = util.import_importlib('importlib.machinery') +machinery = test_util.import_importlib('importlib.machinery') import collections import sys @@ -21,9 +22,9 @@ def test_success(self): # Path hook should handle a directory where a known extension module # exists. - self.assertTrue(hasattr(self.hook(util.EXTENSIONS.path), 'find_module')) + self.assertTrue(hasattr(self.hook(util.PATH), 'find_module')) -Frozen_PathHooksTests, Source_PathHooksTests = util.test_both( +Frozen_PathHooksTests, Source_PathHooksTests = test_util.test_both( PathHookTests, machinery=machinery) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/extension/util.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_importlib/extension/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,19 @@ +from importlib import machinery +import os +import sys + +PATH = None +EXT = None +FILENAME = None +NAME = '_testcapi' +try: + for PATH in sys.path: + for EXT in machinery.EXTENSION_SUFFIXES: + FILENAME = NAME + EXT + FILEPATH = os.path.join(PATH, FILENAME) + if os.path.exists(os.path.join(PATH, FILENAME)): + raise StopIteration + else: + PATH = EXT = FILENAME = FILEPATH = None +except StopIteration: + pass diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test___loader__.py --- a/Lib/test/test_importlib/import_/test___loader__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test___loader__.py Sun Mar 23 09:44:28 2014 +0100 @@ -4,6 +4,7 @@ import unittest from .. import util +from . import util as import_util class SpecLoaderMock: @@ -24,7 +25,7 @@ self.assertEqual(loader, module.__loader__) Frozen_SpecTests, Source_SpecTests = util.test_both( - SpecLoaderAttributeTests, __import__=util.__import__) + SpecLoaderAttributeTests, __import__=import_util.__import__) class LoaderMock: @@ -62,7 +63,7 @@ Frozen_Tests, Source_Tests = util.test_both(LoaderAttributeTests, - __import__=util.__import__) + __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test___package__.py --- a/Lib/test/test_importlib/import_/test___package__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test___package__.py Sun Mar 23 09:44:28 2014 +0100 @@ -6,6 +6,7 @@ """ import unittest from .. import util +from . import util as import_util class Using__package__: @@ -73,13 +74,13 @@ mock_modules = util.mock_modules Frozen_UsingPackagePEP302, Source_UsingPackagePEP302 = util.test_both( - Using__package__PEP302, __import__=util.__import__) + Using__package__PEP302, __import__=import_util.__import__) class Using__package__PEP302(Using__package__): mock_modules = util.mock_spec Frozen_UsingPackagePEP451, Source_UsingPackagePEP451 = util.test_both( - Using__package__PEP302, __import__=util.__import__) + Using__package__PEP302, __import__=import_util.__import__) class Setting__package__: @@ -94,7 +95,7 @@ """ - __import__ = util.__import__[1] + __import__ = import_util.__import__[1] # [top-level] def test_top_level(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_api.py --- a/Lib/test/test_importlib/import_/test_api.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_api.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as import_util from importlib import machinery import sys @@ -79,14 +80,14 @@ bad_finder_loader = BadLoaderFinder Frozen_OldAPITests, Source_OldAPITests = util.test_both( - OldAPITests, __import__=util.__import__) + OldAPITests, __import__=import_util.__import__) class SpecAPITests(APITest): bad_finder_loader = BadSpecFinderLoader Frozen_SpecAPITests, Source_SpecAPITests = util.test_both( - SpecAPITests, __import__=util.__import__) + SpecAPITests, __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_caching.py --- a/Lib/test/test_importlib/import_/test_caching.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_caching.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ """Test that sys.modules is used properly by import.""" from .. import util +from . import util as import_util import sys from types import MethodType import unittest @@ -39,14 +40,14 @@ self.assertEqual(cm.exception.name, name) Frozen_UseCache, Source_UseCache = util.test_both( - UseCache, __import__=util.__import__) + UseCache, __import__=import_util.__import__) class ImportlibUseCache(UseCache, unittest.TestCase): # Pertinent only to PEP 302; exec_module() doesn't return a module. - __import__ = util.__import__[1] + __import__ = import_util.__import__[1] def create_mock(self, *names, return_=None): mock = util.mock_modules(*names) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_fromlist.py --- a/Lib/test/test_importlib/import_/test_fromlist.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_fromlist.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ """Test that the semantics relating to the 'fromlist' argument are correct.""" from .. import util +from . import util as import_util import unittest @@ -29,7 +30,7 @@ self.assertEqual(module.__name__, 'pkg.module') Frozen_ReturnValue, Source_ReturnValue = util.test_both( - ReturnValue, __import__=util.__import__) + ReturnValue, __import__=import_util.__import__) class HandlingFromlist: @@ -121,7 +122,7 @@ self.assertEqual(module.module2.__name__, 'pkg.module2') Frozen_FromList, Source_FromList = util.test_both( - HandlingFromlist, __import__=util.__import__) + HandlingFromlist, __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_meta_path.py --- a/Lib/test/test_importlib/import_/test_meta_path.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_meta_path.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as import_util import importlib._bootstrap import sys from types import MethodType @@ -46,7 +47,7 @@ self.assertTrue(issubclass(w[-1].category, ImportWarning)) Frozen_CallingOrder, Source_CallingOrder = util.test_both( - CallingOrder, __import__=util.__import__) + CallingOrder, __import__=import_util.__import__) class CallSignature: @@ -104,14 +105,14 @@ finder_name = 'find_module' Frozen_CallSignaturePEP302, Source_CallSignaturePEP302 = util.test_both( - CallSignaturePEP302, __import__=util.__import__) + CallSignaturePEP302, __import__=import_util.__import__) class CallSignaturePEP451(CallSignature): mock_modules = util.mock_spec finder_name = 'find_spec' Frozen_CallSignaturePEP451, Source_CallSignaturePEP451 = util.test_both( - CallSignaturePEP451, __import__=util.__import__) + CallSignaturePEP451, __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_packages.py --- a/Lib/test/test_importlib/import_/test_packages.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_packages.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as import_util import sys import unittest import importlib @@ -102,7 +103,7 @@ support.unload(subname) Frozen_ParentTests, Source_ParentTests = util.test_both( - ParentModuleTests, __import__=util.__import__) + ParentModuleTests, __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_path.py --- a/Lib/test/test_importlib/import_/test_path.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_path.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as import_util importlib = util.import_importlib('importlib') machinery = util.import_importlib('importlib.machinery') @@ -57,7 +58,7 @@ module = '' path = '' importer = util.mock_spec(module) - hook = util.mock_path_hook(path, importer=importer) + hook = import_util.mock_path_hook(path, importer=importer) with util.import_state(path_hooks=[hook]): loader = self.machinery.PathFinder.find_module(module, [path]) self.assertIs(loader, importer) @@ -82,7 +83,7 @@ path = '' module = '' importer = util.mock_spec(module) - hook = util.mock_path_hook(os.getcwd(), importer=importer) + hook = import_util.mock_path_hook(os.getcwd(), importer=importer) with util.import_state(path=[path], path_hooks=[hook]): loader = self.machinery.PathFinder.find_module(module) self.assertIs(loader, importer) @@ -111,53 +112,6 @@ if email is not missing: sys.modules['email'] = email - def test_finder_with_find_module(self): - class TestFinder: - def find_module(self, fullname): - return self.to_return - failing_finder = TestFinder() - failing_finder.to_return = None - path = 'testing path' - with util.import_state(path_importer_cache={path: failing_finder}): - self.assertIsNone( - self.machinery.PathFinder.find_spec('whatever', [path])) - success_finder = TestFinder() - success_finder.to_return = __loader__ - with util.import_state(path_importer_cache={path: success_finder}): - spec = self.machinery.PathFinder.find_spec('whatever', [path]) - self.assertEqual(spec.loader, __loader__) - - def test_finder_with_find_loader(self): - class TestFinder: - loader = None - portions = [] - def find_loader(self, fullname): - return self.loader, self.portions - path = 'testing path' - with util.import_state(path_importer_cache={path: TestFinder()}): - self.assertIsNone( - self.machinery.PathFinder.find_spec('whatever', [path])) - success_finder = TestFinder() - success_finder.loader = __loader__ - with util.import_state(path_importer_cache={path: success_finder}): - spec = self.machinery.PathFinder.find_spec('whatever', [path]) - self.assertEqual(spec.loader, __loader__) - - def test_finder_with_find_spec(self): - class TestFinder: - spec = None - def find_spec(self, fullname, target=None): - return self.spec - path = 'testing path' - with util.import_state(path_importer_cache={path: TestFinder()}): - self.assertIsNone( - self.machinery.PathFinder.find_spec('whatever', [path])) - success_finder = TestFinder() - success_finder.spec = self.machinery.ModuleSpec('whatever', __loader__) - with util.import_state(path_importer_cache={path: success_finder}): - got = self.machinery.PathFinder.find_spec('whatever', [path]) - self.assertEqual(got, success_finder.spec) - Frozen_FinderTests, Source_FinderTests = util.test_both( FinderTests, importlib=importlib, machinery=machinery) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/test_relative_imports.py --- a/Lib/test/test_importlib/import_/test_relative_imports.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/import_/test_relative_imports.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ """Test relative imports (PEP 328).""" from .. import util +from . import util as import_util import sys import unittest @@ -208,7 +209,7 @@ self.__import__('sys', level=1) Frozen_RelativeImports, Source_RelativeImports = util.test_both( - RelativeImports, __import__=util.__import__) + RelativeImports, __import__=import_util.__import__) if __name__ == '__main__': diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/import_/util.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_importlib/import_/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,20 @@ +from .. import util + +frozen_importlib, source_importlib = util.import_importlib('importlib') + +import builtins +import functools +import importlib +import unittest + + +__import__ = staticmethod(builtins.__import__), staticmethod(source_importlib.__import__) + + +def mock_path_hook(*entries, importer): + """A mock sys.path_hooks entry.""" + def hook(entry): + if entry not in entries: + raise ImportError + return importer + return hook diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py --- a/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'both_portions foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py --- a/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'both_portions foo two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/missing_directory.zip Binary file Lib/test/test_importlib/namespace_pkgs/missing_directory.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py --- a/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'in module' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip Binary file Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py --- a/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'portion1 foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py --- a/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'portion1 foo one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py --- a/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'portion2 foo two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py --- a/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'parent child one' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py --- a/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'parent child two' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py --- a/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -attr = 'parent child three' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip Binary file Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip has changed diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/test_case_sensitivity.py --- a/Lib/test/test_importlib/source/test_case_sensitivity.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/source/test_case_sensitivity.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ """Test case-sensitivity (PEP 235).""" from .. import util +from . import util as source_util importlib = util.import_importlib('importlib') machinery = util.import_importlib('importlib.machinery') @@ -31,7 +32,7 @@ """Look for a module with matching and non-matching sensitivity.""" sensitive_pkg = 'sensitive.{0}'.format(self.name) insensitive_pkg = 'insensitive.{0}'.format(self.name.lower()) - context = util.create_modules(insensitive_pkg, sensitive_pkg) + context = source_util.create_modules(insensitive_pkg, sensitive_pkg) with context as mapping: sensitive_path = os.path.join(mapping['.root'], 'sensitive') insensitive_path = os.path.join(mapping['.root'], 'insensitive') diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/test_file_loader.py --- a/Lib/test/test_importlib/source/test_file_loader.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/source/test_file_loader.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ from .. import abc from .. import util +from . import util as source_util importlib = util.import_importlib('importlib') importlib_abc = util.import_importlib('importlib.abc') @@ -70,7 +71,7 @@ # [basic] def test_module(self): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: loader = self.machinery.SourceFileLoader('_temp', mapping['_temp']) with warnings.catch_warnings(): warnings.simplefilter('ignore', DeprecationWarning) @@ -82,7 +83,7 @@ self.assertEqual(getattr(module, attr), value) def test_package(self): - with util.create_modules('_pkg.__init__') as mapping: + with source_util.create_modules('_pkg.__init__') as mapping: loader = self.machinery.SourceFileLoader('_pkg', mapping['_pkg.__init__']) with warnings.catch_warnings(): @@ -97,7 +98,7 @@ def test_lacking_parent(self): - with util.create_modules('_pkg.__init__', '_pkg.mod')as mapping: + with source_util.create_modules('_pkg.__init__', '_pkg.mod')as mapping: loader = self.machinery.SourceFileLoader('_pkg.mod', mapping['_pkg.mod']) with warnings.catch_warnings(): @@ -114,7 +115,7 @@ return lambda name: fxn(name) + 1 def test_module_reuse(self): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: loader = self.machinery.SourceFileLoader('_temp', mapping['_temp']) with warnings.catch_warnings(): warnings.simplefilter('ignore', DeprecationWarning) @@ -138,7 +139,7 @@ attributes = ('__file__', '__path__', '__package__') value = '' name = '_temp' - with util.create_modules(name) as mapping: + with source_util.create_modules(name) as mapping: orig_module = types.ModuleType(name) for attr in attributes: setattr(orig_module, attr, value) @@ -158,7 +159,7 @@ # [syntax error] def test_bad_syntax(self): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: with open(mapping['_temp'], 'w') as file: file.write('=') loader = self.machinery.SourceFileLoader('_temp', mapping['_temp']) @@ -189,11 +190,11 @@ if os.path.exists(pycache): shutil.rmtree(pycache) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_timestamp_overflow(self): # When a modification timestamp is larger than 2**32, it should be # truncated rather than raise an OverflowError. - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: source = mapping['_temp'] compiled = self.util.cache_from_source(source) with open(source, 'w') as f: @@ -274,45 +275,45 @@ return bytecode_path def _test_empty_file(self, test, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: b'', del_source=del_source) test('_temp', mapping, bc_path) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def _test_partial_magic(self, test, *, del_source=False): # When their are less than 4 bytes to a .pyc, regenerate it if # possible, else raise ImportError. - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:3], del_source=del_source) test('_temp', mapping, bc_path) def _test_magic_only(self, test, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:4], del_source=del_source) test('_temp', mapping, bc_path) def _test_partial_timestamp(self, test, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:7], del_source=del_source) test('_temp', mapping, bc_path) def _test_partial_size(self, test, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:11], del_source=del_source) test('_temp', mapping, bc_path) def _test_no_marshal(self, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:12], del_source=del_source) @@ -321,7 +322,7 @@ self.import_(file_path, '_temp') def _test_non_code_marshal(self, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bytecode_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:12] + marshal.dumps(b'abcd'), del_source=del_source) @@ -332,7 +333,7 @@ self.assertEqual(cm.exception.path, bytecode_path) def _test_bad_marshal(self, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bytecode_path = self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:12] + b'', del_source=del_source) @@ -341,7 +342,7 @@ self.import_(file_path, '_temp') def _test_bad_magic(self, test, *, del_source=False): - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: bc_path = self.manipulate_bytecode('_temp', mapping, lambda bc: b'\x00\x00\x00\x00' + bc[4:]) test('_temp', mapping, bc_path) @@ -370,7 +371,7 @@ def setUpClass(cls): cls.loader = cls.machinery.SourceFileLoader - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_empty_file(self): # When a .pyc is empty, regenerate it if possible, else raise # ImportError. @@ -389,7 +390,7 @@ self._test_partial_magic(test) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_magic_only(self): # When there is only the magic number, regenerate the .pyc if possible, # else raise EOFError. @@ -400,7 +401,7 @@ self._test_magic_only(test) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_bad_magic(self): # When the magic number is different, the bytecode should be # regenerated. @@ -412,7 +413,7 @@ self._test_bad_magic(test) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_partial_timestamp(self): # When the timestamp is partial, regenerate the .pyc, else # raise EOFError. @@ -423,7 +424,7 @@ self._test_partial_timestamp(test) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_partial_size(self): # When the size is partial, regenerate the .pyc, else # raise EOFError. @@ -434,29 +435,29 @@ self._test_partial_size(test) - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_no_marshal(self): # When there is only the magic number and timestamp, raise EOFError. self._test_no_marshal() - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_non_code_marshal(self): self._test_non_code_marshal() # XXX ImportError when sourceless # [bad marshal] - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_bad_marshal(self): # Bad marshal data should raise a ValueError. self._test_bad_marshal() # [bad timestamp] - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_old_timestamp(self): # When the timestamp is older than the source, bytecode should be # regenerated. zeros = b'\x00\x00\x00\x00' - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: py_compile.compile(mapping['_temp']) bytecode_path = self.util.cache_from_source(mapping['_temp']) with open(bytecode_path, 'r+b') as bytecode_file: @@ -470,10 +471,10 @@ self.assertEqual(bytecode_file.read(4), source_timestamp) # [bytecode read-only] - @util.writes_bytecode_files + @source_util.writes_bytecode_files def test_read_only_bytecode(self): # When bytecode is read-only but should be rewritten, fail silently. - with util.create_modules('_temp') as mapping: + with source_util.create_modules('_temp') as mapping: # Create bytecode that will need to be re-created. py_compile.compile(mapping['_temp']) bytecode_path = self.util.cache_from_source(mapping['_temp']) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/test_finder.py --- a/Lib/test/test_importlib/source/test_finder.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/source/test_finder.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,6 @@ from .. import abc from .. import util +from . import util as source_util machinery = util.import_importlib('importlib.machinery') @@ -59,7 +60,7 @@ """ if create is None: create = {test} - with util.create_modules(*create) as mapping: + with source_util.create_modules(*create) as mapping: if compile_: for name in compile_: py_compile.compile(mapping[name]) @@ -99,14 +100,14 @@ # [sub module] def test_module_in_package(self): - with util.create_modules('pkg.__init__', 'pkg.sub') as mapping: + with source_util.create_modules('pkg.__init__', 'pkg.sub') as mapping: pkg_dir = os.path.dirname(mapping['pkg.__init__']) loader = self.import_(pkg_dir, 'pkg.sub') self.assertTrue(hasattr(loader, 'load_module')) # [sub package] def test_package_in_package(self): - context = util.create_modules('pkg.__init__', 'pkg.sub.__init__') + context = source_util.create_modules('pkg.__init__', 'pkg.sub.__init__') with context as mapping: pkg_dir = os.path.dirname(mapping['pkg.__init__']) loader = self.import_(pkg_dir, 'pkg.sub') @@ -119,7 +120,7 @@ self.assertIn('__init__', loader.get_filename(name)) def test_failure(self): - with util.create_modules('blah') as mapping: + with source_util.create_modules('blah') as mapping: nothing = self.import_(mapping['.root'], 'sdfsadsadf') self.assertIsNone(nothing) @@ -146,7 +147,7 @@ # Regression test for http://bugs.python.org/issue14846 def test_dir_removal_handling(self): mod = 'mod' - with util.create_modules(mod) as mapping: + with source_util.create_modules(mod) as mapping: finder = self.get_finder(mapping['.root']) found = self._find(finder, 'mod', loader_only=True) self.assertIsNotNone(found) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/test_path_hook.py --- a/Lib/test/test_importlib/source/test_path_hook.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/source/test_path_hook.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as source_util machinery = util.import_importlib('importlib.machinery') @@ -14,7 +15,7 @@ self.machinery.SOURCE_SUFFIXES)) def test_success(self): - with util.create_modules('dummy') as mapping: + with source_util.create_modules('dummy') as mapping: self.assertTrue(hasattr(self.path_hook()(mapping['.root']), 'find_module')) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/test_source_encoding.py --- a/Lib/test/test_importlib/source/test_source_encoding.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/source/test_source_encoding.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,5 @@ from .. import util +from . import util as source_util machinery = util.import_importlib('importlib.machinery') @@ -36,7 +37,7 @@ module_name = '_temp' def run_test(self, source): - with util.create_modules(self.module_name) as mapping: + with source_util.create_modules(self.module_name) as mapping: with open(mapping[self.module_name], 'wb') as file: file.write(source) loader = self.machinery.SourceFileLoader(self.module_name, @@ -119,7 +120,7 @@ module_name = '_temp' source_lines = [b"a = 42", b"b = -13", b''] source = line_ending.join(source_lines) - with util.create_modules(module_name) as mapping: + with source_util.create_modules(module_name) as mapping: with open(mapping[module_name], 'wb') as file: file.write(source) loader = self.machinery.SourceFileLoader(module_name, diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/source/util.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_importlib/source/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,96 @@ +from .. import util +import contextlib +import errno +import functools +import os +import os.path +import sys +import tempfile +from test import support + + +def writes_bytecode_files(fxn): + """Decorator to protect sys.dont_write_bytecode from mutation and to skip + tests that require it to be set to False.""" + if sys.dont_write_bytecode: + return lambda *args, **kwargs: None + @functools.wraps(fxn) + def wrapper(*args, **kwargs): + original = sys.dont_write_bytecode + sys.dont_write_bytecode = False + try: + to_return = fxn(*args, **kwargs) + finally: + sys.dont_write_bytecode = original + return to_return + return wrapper + + +def ensure_bytecode_path(bytecode_path): + """Ensure that the __pycache__ directory for PEP 3147 pyc file exists. + + :param bytecode_path: File system path to PEP 3147 pyc file. + """ + try: + os.mkdir(os.path.dirname(bytecode_path)) + except OSError as error: + if error.errno != errno.EEXIST: + raise + + +@contextlib.contextmanager +def create_modules(*names): + """Temporarily create each named module with an attribute (named 'attr') + that contains the name passed into the context manager that caused the + creation of the module. + + All files are created in a temporary directory returned by + tempfile.mkdtemp(). This directory is inserted at the beginning of + sys.path. When the context manager exits all created files (source and + bytecode) are explicitly deleted. + + No magic is performed when creating packages! This means that if you create + a module within a package you must also create the package's __init__ as + well. + + """ + source = 'attr = {0!r}' + created_paths = [] + mapping = {} + state_manager = None + uncache_manager = None + try: + temp_dir = tempfile.mkdtemp() + mapping['.root'] = temp_dir + import_names = set() + for name in names: + if not name.endswith('__init__'): + import_name = name + else: + import_name = name[:-len('.__init__')] + import_names.add(import_name) + if import_name in sys.modules: + del sys.modules[import_name] + name_parts = name.split('.') + file_path = temp_dir + for directory in name_parts[:-1]: + file_path = os.path.join(file_path, directory) + if not os.path.exists(file_path): + os.mkdir(file_path) + created_paths.append(file_path) + file_path = os.path.join(file_path, name_parts[-1] + '.py') + with open(file_path, 'w') as file: + file.write(source.format(name)) + created_paths.append(file_path) + mapping[name] = file_path + uncache_manager = util.uncache(*import_names) + uncache_manager.__enter__() + state_manager = util.import_state(path=[temp_dir]) + state_manager.__enter__() + yield mapping + finally: + if state_manager is not None: + state_manager.__exit__(None, None, None) + if uncache_manager is not None: + uncache_manager.__exit__(None, None, None) + support.rmtree(temp_dir) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/test_lazy.py --- a/Lib/test/test_importlib/test_lazy.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -import importlib -from importlib import abc -from importlib import util -import unittest - -from . import util as test_util - - -class CollectInit: - - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - - def exec_module(self, module): - return self - - -class LazyLoaderFactoryTests(unittest.TestCase): - - def test_init(self): - factory = util.LazyLoader.factory(CollectInit) - # E.g. what importlib.machinery.FileFinder instantiates loaders with - # plus keyword arguments. - lazy_loader = factory('module name', 'module path', kw='kw') - loader = lazy_loader.loader - self.assertEqual(('module name', 'module path'), loader.args) - self.assertEqual({'kw': 'kw'}, loader.kwargs) - - def test_validation(self): - # No exec_module(), no lazy loading. - with self.assertRaises(TypeError): - util.LazyLoader.factory(object) - - -class TestingImporter(abc.MetaPathFinder, abc.Loader): - - module_name = 'lazy_loader_test' - mutated_name = 'changed' - loaded = None - source_code = 'attr = 42; __name__ = {!r}'.format(mutated_name) - - def find_spec(self, name, path, target=None): - if name != self.module_name: - return None - return util.spec_from_loader(name, util.LazyLoader(self)) - - def exec_module(self, module): - exec(self.source_code, module.__dict__) - self.loaded = module - - -class LazyLoaderTests(unittest.TestCase): - - def test_init(self): - with self.assertRaises(TypeError): - util.LazyLoader(object) - - def new_module(self, source_code=None): - loader = TestingImporter() - if source_code is not None: - loader.source_code = source_code - spec = util.spec_from_loader(TestingImporter.module_name, - util.LazyLoader(loader)) - module = spec.loader.create_module(spec) - module.__spec__ = spec - module.__loader__ = spec.loader - spec.loader.exec_module(module) - # Module is now lazy. - self.assertIsNone(loader.loaded) - return module - - def test_e2e(self): - # End-to-end test to verify the load is in fact lazy. - importer = TestingImporter() - assert importer.loaded is None - with test_util.uncache(importer.module_name): - with test_util.import_state(meta_path=[importer]): - module = importlib.import_module(importer.module_name) - self.assertIsNone(importer.loaded) - # Trigger load. - self.assertEqual(module.__loader__, importer) - self.assertIsNotNone(importer.loaded) - self.assertEqual(module, importer.loaded) - - def test_attr_unchanged(self): - # An attribute only mutated as a side-effect of import should not be - # changed needlessly. - module = self.new_module() - self.assertEqual(TestingImporter.mutated_name, module.__name__) - - def test_new_attr(self): - # A new attribute should persist. - module = self.new_module() - module.new_attr = 42 - self.assertEqual(42, module.new_attr) - - def test_mutated_preexisting_attr(self): - # Changing an attribute that already existed on the module -- - # e.g. __name__ -- should persist. - module = self.new_module() - module.__name__ = 'bogus' - self.assertEqual('bogus', module.__name__) - - def test_mutated_attr(self): - # Changing an attribute that comes into existence after an import - # should persist. - module = self.new_module() - module.attr = 6 - self.assertEqual(6, module.attr) - - def test_delete_eventual_attr(self): - # Deleting an attribute should stay deleted. - module = self.new_module() - del module.attr - self.assertFalse(hasattr(module, 'attr')) - - def test_delete_preexisting_attr(self): - module = self.new_module() - del module.__name__ - self.assertFalse(hasattr(module, '__name__')) - - def test_module_substitution_error(self): - source_code = 'import sys; sys.modules[__name__] = 42' - module = self.new_module(source_code) - with test_util.uncache(TestingImporter.module_name): - with self.assertRaises(ValueError): - module.__name__ - - -if __name__ == '__main__': - unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/test_namespace_pkgs.py --- a/Lib/test/test_importlib/test_namespace_pkgs.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,293 +0,0 @@ -import contextlib -import importlib.abc -import importlib.machinery -import os -import sys -import types -import unittest - -from test.test_importlib import util -from test.support import run_unittest - -# needed tests: -# -# need to test when nested, so that the top-level path isn't sys.path -# need to test dynamic path detection, both at top-level and nested -# with dynamic path, check when a loader is returned on path reload (that is, -# trying to switch from a namespace package to a regular package) - - -@contextlib.contextmanager -def sys_modules_context(): - """ - Make sure sys.modules is the same object and has the same content - when exiting the context as when entering. - - Similar to importlib.test.util.uncache, but doesn't require explicit - names. - """ - sys_modules_saved = sys.modules - sys_modules_copy = sys.modules.copy() - try: - yield - finally: - sys.modules = sys_modules_saved - sys.modules.clear() - sys.modules.update(sys_modules_copy) - - -@contextlib.contextmanager -def namespace_tree_context(**kwargs): - """ - Save import state and sys.modules cache and restore it on exit. - Typical usage: - - >>> with namespace_tree_context(path=['/tmp/xxyy/portion1', - ... '/tmp/xxyy/portion2']): - ... pass - """ - # use default meta_path and path_hooks unless specified otherwise - kwargs.setdefault('meta_path', sys.meta_path) - kwargs.setdefault('path_hooks', sys.path_hooks) - import_context = util.import_state(**kwargs) - with import_context, sys_modules_context(): - yield - -class NamespacePackageTest(unittest.TestCase): - """ - Subclasses should define self.root and self.paths (under that root) - to be added to sys.path. - """ - root = os.path.join(os.path.dirname(__file__), 'namespace_pkgs') - - def setUp(self): - self.resolved_paths = [ - os.path.join(self.root, path) for path in self.paths - ] - self.ctx = namespace_tree_context(path=self.resolved_paths) - self.ctx.__enter__() - - def tearDown(self): - # TODO: will we ever want to pass exc_info to __exit__? - self.ctx.__exit__(None, None, None) - -class SingleNamespacePackage(NamespacePackageTest): - paths = ['portion1'] - - def test_simple_package(self): - import foo.one - self.assertEqual(foo.one.attr, 'portion1 foo one') - - def test_cant_import_other(self): - with self.assertRaises(ImportError): - import foo.two - - def test_module_repr(self): - import foo.one - self.assertEqual(repr(foo), "") - - -class DynamicPatheNamespacePackage(NamespacePackageTest): - paths = ['portion1'] - - def test_dynamic_path(self): - # Make sure only 'foo.one' can be imported - import foo.one - self.assertEqual(foo.one.attr, 'portion1 foo one') - - with self.assertRaises(ImportError): - import foo.two - - # Now modify sys.path - sys.path.append(os.path.join(self.root, 'portion2')) - - # And make sure foo.two is now importable - import foo.two - self.assertEqual(foo.two.attr, 'portion2 foo two') - - -class CombinedNamespacePackages(NamespacePackageTest): - paths = ['both_portions'] - - def test_imports(self): - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'both_portions foo one') - self.assertEqual(foo.two.attr, 'both_portions foo two') - - -class SeparatedNamespacePackages(NamespacePackageTest): - paths = ['portion1', 'portion2'] - - def test_imports(self): - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'portion1 foo one') - self.assertEqual(foo.two.attr, 'portion2 foo two') - - -class SeparatedOverlappingNamespacePackages(NamespacePackageTest): - paths = ['portion1', 'both_portions'] - - def test_first_path_wins(self): - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'portion1 foo one') - self.assertEqual(foo.two.attr, 'both_portions foo two') - - def test_first_path_wins_again(self): - sys.path.reverse() - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'both_portions foo one') - self.assertEqual(foo.two.attr, 'both_portions foo two') - - def test_first_path_wins_importing_second_first(self): - import foo.two - import foo.one - self.assertEqual(foo.one.attr, 'portion1 foo one') - self.assertEqual(foo.two.attr, 'both_portions foo two') - - -class SingleZipNamespacePackage(NamespacePackageTest): - paths = ['top_level_portion1.zip'] - - def test_simple_package(self): - import foo.one - self.assertEqual(foo.one.attr, 'portion1 foo one') - - def test_cant_import_other(self): - with self.assertRaises(ImportError): - import foo.two - - -class SeparatedZipNamespacePackages(NamespacePackageTest): - paths = ['top_level_portion1.zip', 'portion2'] - - def test_imports(self): - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'portion1 foo one') - self.assertEqual(foo.two.attr, 'portion2 foo two') - self.assertIn('top_level_portion1.zip', foo.one.__file__) - self.assertNotIn('.zip', foo.two.__file__) - - -class SingleNestedZipNamespacePackage(NamespacePackageTest): - paths = ['nested_portion1.zip/nested_portion1'] - - def test_simple_package(self): - import foo.one - self.assertEqual(foo.one.attr, 'portion1 foo one') - - def test_cant_import_other(self): - with self.assertRaises(ImportError): - import foo.two - - -class SeparatedNestedZipNamespacePackages(NamespacePackageTest): - paths = ['nested_portion1.zip/nested_portion1', 'portion2'] - - def test_imports(self): - import foo.one - import foo.two - self.assertEqual(foo.one.attr, 'portion1 foo one') - self.assertEqual(foo.two.attr, 'portion2 foo two') - fn = os.path.join('nested_portion1.zip', 'nested_portion1') - self.assertIn(fn, foo.one.__file__) - self.assertNotIn('.zip', foo.two.__file__) - - -class LegacySupport(NamespacePackageTest): - paths = ['not_a_namespace_pkg', 'portion1', 'portion2', 'both_portions'] - - def test_non_namespace_package_takes_precedence(self): - import foo.one - with self.assertRaises(ImportError): - import foo.two - self.assertIn('__init__', foo.__file__) - self.assertNotIn('namespace', str(foo.__loader__).lower()) - - -class DynamicPathCalculation(NamespacePackageTest): - paths = ['project1', 'project2'] - - def test_project3_fails(self): - import parent.child.one - self.assertEqual(len(parent.__path__), 2) - self.assertEqual(len(parent.child.__path__), 2) - import parent.child.two - self.assertEqual(len(parent.__path__), 2) - self.assertEqual(len(parent.child.__path__), 2) - - self.assertEqual(parent.child.one.attr, 'parent child one') - self.assertEqual(parent.child.two.attr, 'parent child two') - - with self.assertRaises(ImportError): - import parent.child.three - - self.assertEqual(len(parent.__path__), 2) - self.assertEqual(len(parent.child.__path__), 2) - - def test_project3_succeeds(self): - import parent.child.one - self.assertEqual(len(parent.__path__), 2) - self.assertEqual(len(parent.child.__path__), 2) - import parent.child.two - self.assertEqual(len(parent.__path__), 2) - self.assertEqual(len(parent.child.__path__), 2) - - self.assertEqual(parent.child.one.attr, 'parent child one') - self.assertEqual(parent.child.two.attr, 'parent child two') - - with self.assertRaises(ImportError): - import parent.child.three - - # now add project3 - sys.path.append(os.path.join(self.root, 'project3')) - import parent.child.three - - # the paths dynamically get longer, to include the new directories - self.assertEqual(len(parent.__path__), 3) - self.assertEqual(len(parent.child.__path__), 3) - - self.assertEqual(parent.child.three.attr, 'parent child three') - - -class ZipWithMissingDirectory(NamespacePackageTest): - paths = ['missing_directory.zip'] - - @unittest.expectedFailure - def test_missing_directory(self): - # This will fail because missing_directory.zip contains: - # Length Date Time Name - # --------- ---------- ----- ---- - # 29 2012-05-03 18:13 foo/one.py - # 0 2012-05-03 20:57 bar/ - # 38 2012-05-03 20:57 bar/two.py - # --------- ------- - # 67 3 files - - # Because there is no 'foo/', the zipimporter currently doesn't - # know that foo is a namespace package - - import foo.one - - def test_present_directory(self): - # This succeeds because there is a "bar/" in the zip file - import bar.two - self.assertEqual(bar.two.attr, 'missing_directory foo two') - - -class ModuleAndNamespacePackageInSameDir(NamespacePackageTest): - paths = ['module_and_namespace_package'] - - def test_module_before_namespace_package(self): - # Make sure we find the module in preference to the - # namespace package. - import a_test - self.assertEqual(a_test.attr, 'in module') - - -if __name__ == "__main__": - unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_importlib/util.py --- a/Lib/test/test_importlib/util.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_importlib/util.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,49 +1,12 @@ -import builtins -import contextlib -import errno -import functools -import importlib -from importlib import machinery, util, invalidate_caches -import os +from contextlib import contextmanager +from importlib import util, invalidate_caches import os.path from test import support import unittest import sys -import tempfile import types -BUILTINS = types.SimpleNamespace() -BUILTINS.good_name = None -BUILTINS.bad_name = None -if 'errno' in sys.builtin_module_names: - BUILTINS.good_name = 'errno' -if 'importlib' not in sys.builtin_module_names: - BUILTINS.bad_name = 'importlib' - -EXTENSIONS = types.SimpleNamespace() -EXTENSIONS.path = None -EXTENSIONS.ext = None -EXTENSIONS.filename = None -EXTENSIONS.file_path = None -EXTENSIONS.name = '_testcapi' - -def _extension_details(): - global EXTENSIONS - for path in sys.path: - for ext in machinery.EXTENSION_SUFFIXES: - filename = EXTENSIONS.name + ext - file_path = os.path.join(path, filename) - if os.path.exists(file_path): - EXTENSIONS.path = path - EXTENSIONS.ext = ext - EXTENSIONS.filename = filename - EXTENSIONS.file_path = file_path - return - -_extension_details() - - def import_importlib(module_name): """Import a module from importlib both w/ and w/o _frozen_importlib.""" fresh = ('importlib',) if '.' in module_name else () @@ -75,9 +38,6 @@ if not os.path.exists(changed_name): CASE_INSENSITIVE_FS = False -_, source_importlib = import_importlib('importlib') -__import__ = staticmethod(builtins.__import__), staticmethod(source_importlib.__import__) - def case_insensitive_tests(test): """Class decorator that nullifies tests requiring a case-insensitive @@ -93,7 +53,7 @@ return '{}.{}'.format(parent, name), path -@contextlib.contextmanager +@contextmanager def uncache(*names): """Uncache a module from sys.modules. @@ -119,7 +79,7 @@ pass -@contextlib.contextmanager +@contextmanager def temp_module(name, content='', *, pkg=False): conflicts = [n for n in sys.modules if n.partition('.')[0] == name] with support.temp_cwd(None) as cwd: @@ -143,7 +103,7 @@ yield location -@contextlib.contextmanager +@contextmanager def import_state(**kwargs): """Context manager to manage the various importers and stored state in the sys module. @@ -238,7 +198,6 @@ raise return self.modules[fullname] - class mock_spec(_ImporterMock): """Importer mock using PEP 451 APIs.""" @@ -264,99 +223,3 @@ self.module_code[module.__spec__.name]() except KeyError: pass - - -def writes_bytecode_files(fxn): - """Decorator to protect sys.dont_write_bytecode from mutation and to skip - tests that require it to be set to False.""" - if sys.dont_write_bytecode: - return lambda *args, **kwargs: None - @functools.wraps(fxn) - def wrapper(*args, **kwargs): - original = sys.dont_write_bytecode - sys.dont_write_bytecode = False - try: - to_return = fxn(*args, **kwargs) - finally: - sys.dont_write_bytecode = original - return to_return - return wrapper - - -def ensure_bytecode_path(bytecode_path): - """Ensure that the __pycache__ directory for PEP 3147 pyc file exists. - - :param bytecode_path: File system path to PEP 3147 pyc file. - """ - try: - os.mkdir(os.path.dirname(bytecode_path)) - except OSError as error: - if error.errno != errno.EEXIST: - raise - - -@contextlib.contextmanager -def create_modules(*names): - """Temporarily create each named module with an attribute (named 'attr') - that contains the name passed into the context manager that caused the - creation of the module. - - All files are created in a temporary directory returned by - tempfile.mkdtemp(). This directory is inserted at the beginning of - sys.path. When the context manager exits all created files (source and - bytecode) are explicitly deleted. - - No magic is performed when creating packages! This means that if you create - a module within a package you must also create the package's __init__ as - well. - - """ - source = 'attr = {0!r}' - created_paths = [] - mapping = {} - state_manager = None - uncache_manager = None - try: - temp_dir = tempfile.mkdtemp() - mapping['.root'] = temp_dir - import_names = set() - for name in names: - if not name.endswith('__init__'): - import_name = name - else: - import_name = name[:-len('.__init__')] - import_names.add(import_name) - if import_name in sys.modules: - del sys.modules[import_name] - name_parts = name.split('.') - file_path = temp_dir - for directory in name_parts[:-1]: - file_path = os.path.join(file_path, directory) - if not os.path.exists(file_path): - os.mkdir(file_path) - created_paths.append(file_path) - file_path = os.path.join(file_path, name_parts[-1] + '.py') - with open(file_path, 'w') as file: - file.write(source.format(name)) - created_paths.append(file_path) - mapping[name] = file_path - uncache_manager = uncache(*import_names) - uncache_manager.__enter__() - state_manager = import_state(path=[temp_dir]) - state_manager.__enter__() - yield mapping - finally: - if state_manager is not None: - state_manager.__exit__(None, None, None) - if uncache_manager is not None: - uncache_manager.__exit__(None, None, None) - support.rmtree(temp_dir) - - -def mock_path_hook(*entries, importer): - """A mock sys.path_hooks entry.""" - def hook(entry): - if entry not in entries: - raise ImportError - return importer - return hook diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_inspect.py Sun Mar 23 09:44:28 2014 +0100 @@ -8,7 +8,6 @@ import os from os.path import normcase import _pickle -import pickle import re import shutil import sys @@ -74,7 +73,6 @@ for i in range(2): yield i - class TestPredicates(IsTestBase): def test_sixteen(self): count = len([x for x in dir(inspect) if x.startswith('is')]) @@ -1208,20 +1206,6 @@ self.assertEqualException(f3, '1, 2') self.assertEqualException(f3, '1, 2, a=1, b=2') - # issue #20816: getcallargs() fails to iterate over non-existent - # kwonlydefaults and raises a wrong TypeError - def f5(*, a): pass - with self.assertRaisesRegex(TypeError, - 'missing 1 required keyword-only'): - inspect.getcallargs(f5) - - - # issue20817: - def f6(a, b, c): - pass - with self.assertRaisesRegex(TypeError, "'a', 'b' and 'c'"): - inspect.getcallargs(f6) - class TestGetcallargsMethods(TestGetcallargsFunctions): def setUp(self): @@ -1613,17 +1597,6 @@ self.assertRaises(TypeError, inspect.getgeneratorlocals, (2,3)) -class MySignature(inspect.Signature): - # Top-level to make it picklable; - # used in test_signature_object_pickle - pass - -class MyParameter(inspect.Parameter): - # Top-level to make it picklable; - # used in test_signature_object_pickle - pass - - class TestSignatureObject(unittest.TestCase): @staticmethod def signature(func): @@ -1681,37 +1654,6 @@ with self.assertRaisesRegex(ValueError, 'follows default argument'): S((pkd, pk)) - self.assertTrue(repr(sig).startswith(' {42:'ham'}: pass - foo_partial = functools.partial(foo, a=1) - - sig = inspect.signature(foo_partial) - - for ver in range(pickle.HIGHEST_PROTOCOL + 1): - with self.subTest(pickle_ver=ver, subclass=False): - sig_pickled = pickle.loads(pickle.dumps(sig, ver)) - self.assertEqual(sig, sig_pickled) - - # Test that basic sub-classing works - sig = inspect.signature(foo) - myparam = MyParameter(name='z', kind=inspect.Parameter.POSITIONAL_ONLY) - myparams = collections.OrderedDict(sig.parameters, a=myparam) - mysig = MySignature().replace(parameters=myparams.values(), - return_annotation=sig.return_annotation) - self.assertTrue(isinstance(mysig, MySignature)) - self.assertTrue(isinstance(mysig.parameters['z'], MyParameter)) - - for ver in range(pickle.HIGHEST_PROTOCOL + 1): - with self.subTest(pickle_ver=ver, subclass=True): - sig_pickled = pickle.loads(pickle.dumps(mysig, ver)) - self.assertEqual(mysig, sig_pickled) - self.assertTrue(isinstance(sig_pickled, MySignature)) - self.assertTrue(isinstance(sig_pickled.parameters['z'], - MyParameter)) - def test_signature_immutability(self): def test(a): pass @@ -2003,8 +1945,6 @@ def test_signature_on_partial(self): from functools import partial - Parameter = inspect.Parameter - def test(): pass @@ -2040,22 +1980,15 @@ self.assertEqual(self.signature(partial(test, b=1, c=2)), ((('a', ..., ..., "positional_or_keyword"), - ('b', 1, ..., "keyword_only"), + ('b', 1, ..., "positional_or_keyword"), ('c', 2, ..., "keyword_only"), ('d', ..., ..., "keyword_only")), ...)) self.assertEqual(self.signature(partial(test, 0, b=1, c=2)), - ((('b', 1, ..., "keyword_only"), + ((('b', 1, ..., "positional_or_keyword"), ('c', 2, ..., "keyword_only"), - ('d', ..., ..., "keyword_only")), - ...)) - - self.assertEqual(self.signature(partial(test, a=1)), - ((('a', 1, ..., "keyword_only"), - ('b', ..., ..., "keyword_only"), - ('c', ..., ..., "keyword_only"), - ('d', ..., ..., "keyword_only")), + ('d', ..., ..., "keyword_only"),), ...)) def test(a, *args, b, **kwargs): @@ -2067,18 +2000,13 @@ ('kwargs', ..., ..., "var_keyword")), ...)) - self.assertEqual(self.signature(partial(test, a=1)), - ((('a', 1, ..., "keyword_only"), - ('b', ..., ..., "keyword_only"), - ('kwargs', ..., ..., "var_keyword")), - ...)) - self.assertEqual(self.signature(partial(test, 1, 2, 3)), ((('args', ..., ..., "var_positional"), ('b', ..., ..., "keyword_only"), ('kwargs', ..., ..., "var_keyword")), ...)) + self.assertEqual(self.signature(partial(test, 1, 2, 3, test=True)), ((('args', ..., ..., "var_positional"), ('b', ..., ..., "keyword_only"), @@ -2125,7 +2053,7 @@ return a _foo = partial(partial(foo, a=10), a=20) self.assertEqual(self.signature(_foo), - ((('a', 20, ..., "keyword_only"),), + ((('a', 20, ..., "positional_or_keyword"),), ...)) # check that we don't have any side-effects in signature(), # and the partial object is still functioning @@ -2134,87 +2062,42 @@ def foo(a, b, c): return a, b, c _foo = partial(partial(foo, 1, b=20), b=30) - self.assertEqual(self.signature(_foo), - ((('b', 30, ..., "keyword_only"), - ('c', ..., ..., "keyword_only")), + ((('b', 30, ..., "positional_or_keyword"), + ('c', ..., ..., "positional_or_keyword")), ...)) self.assertEqual(_foo(c=10), (1, 30, 10)) + _foo = partial(_foo, 2) # now 'b' has two values - + # positional and keyword + with self.assertRaisesRegex(ValueError, "has incorrect arguments"): + inspect.signature(_foo) def foo(a, b, c, *, d): return a, b, c, d _foo = partial(partial(foo, d=20, c=20), b=10, d=30) self.assertEqual(self.signature(_foo), ((('a', ..., ..., "positional_or_keyword"), - ('b', 10, ..., "keyword_only"), - ('c', 20, ..., "keyword_only"), - ('d', 30, ..., "keyword_only"), - ), + ('b', 10, ..., "positional_or_keyword"), + ('c', 20, ..., "positional_or_keyword"), + ('d', 30, ..., "keyword_only")), ...)) ba = inspect.signature(_foo).bind(a=200, b=11) self.assertEqual(_foo(*ba.args, **ba.kwargs), (200, 11, 20, 30)) def foo(a=1, b=2, c=3): return a, b, c - _foo = partial(foo, c=13) # (a=1, b=2, *, c=13) - - ba = inspect.signature(_foo).bind(a=11) + _foo = partial(foo, a=10, c=13) + ba = inspect.signature(_foo).bind(11) self.assertEqual(_foo(*ba.args, **ba.kwargs), (11, 2, 13)) - ba = inspect.signature(_foo).bind(11, 12) self.assertEqual(_foo(*ba.args, **ba.kwargs), (11, 12, 13)) - ba = inspect.signature(_foo).bind(11, b=12) self.assertEqual(_foo(*ba.args, **ba.kwargs), (11, 12, 13)) - ba = inspect.signature(_foo).bind(b=12) - self.assertEqual(_foo(*ba.args, **ba.kwargs), (1, 12, 13)) - - _foo = partial(_foo, b=10, c=20) - ba = inspect.signature(_foo).bind(12) - self.assertEqual(_foo(*ba.args, **ba.kwargs), (12, 10, 20)) - - - def foo(a, b, c, d, **kwargs): - pass - sig = inspect.signature(foo) - params = sig.parameters.copy() - params['a'] = params['a'].replace(kind=Parameter.POSITIONAL_ONLY) - params['b'] = params['b'].replace(kind=Parameter.POSITIONAL_ONLY) - foo.__signature__ = inspect.Signature(params.values()) - sig = inspect.signature(foo) - self.assertEqual(str(sig), '(a, b, /, c, d, **kwargs)') - - self.assertEqual(self.signature(partial(foo, 1)), - ((('b', ..., ..., 'positional_only'), - ('c', ..., ..., 'positional_or_keyword'), - ('d', ..., ..., 'positional_or_keyword'), - ('kwargs', ..., ..., 'var_keyword')), - ...)) - - self.assertEqual(self.signature(partial(foo, 1, 2)), - ((('c', ..., ..., 'positional_or_keyword'), - ('d', ..., ..., 'positional_or_keyword'), - ('kwargs', ..., ..., 'var_keyword')), - ...)) - - self.assertEqual(self.signature(partial(foo, 1, 2, 3)), - ((('d', ..., ..., 'positional_or_keyword'), - ('kwargs', ..., ..., 'var_keyword')), - ...)) - - self.assertEqual(self.signature(partial(foo, 1, 2, c=3)), - ((('c', 3, ..., 'keyword_only'), - ('d', ..., ..., 'keyword_only'), - ('kwargs', ..., ..., 'var_keyword')), - ...)) - - self.assertEqual(self.signature(partial(foo, 1, c=3)), - ((('b', ..., ..., 'positional_only'), - ('c', 3, ..., 'keyword_only'), - ('d', ..., ..., 'keyword_only'), - ('kwargs', ..., ..., 'var_keyword')), - ...)) + self.assertEqual(_foo(*ba.args, **ba.kwargs), (10, 12, 13)) + _foo = partial(_foo, b=10) + ba = inspect.signature(_foo).bind(12, 14) + self.assertEqual(_foo(*ba.args, **ba.kwargs), (12, 14, 13)) def test_signature_on_partialmethod(self): from functools import partialmethod @@ -2513,29 +2396,11 @@ def bar(pos, *args, c, b, a=42, **kwargs:int): pass self.assertEqual(inspect.signature(foo), inspect.signature(bar)) - def test_signature_hashable(self): - S = inspect.Signature - P = inspect.Parameter - + def test_signature_unhashable(self): def foo(a): pass - foo_sig = inspect.signature(foo) - - manual_sig = S(parameters=[P('a', P.POSITIONAL_OR_KEYWORD)]) - - self.assertEqual(hash(foo_sig), hash(manual_sig)) - self.assertNotEqual(hash(foo_sig), - hash(manual_sig.replace(return_annotation='spam'))) - - def bar(a) -> 1: pass - self.assertNotEqual(hash(foo_sig), hash(inspect.signature(bar))) - - def foo(a={}): pass + sig = inspect.signature(foo) with self.assertRaisesRegex(TypeError, 'unhashable type'): - hash(inspect.signature(foo)) - - def foo(a) -> {}: pass - with self.assertRaisesRegex(TypeError, 'unhashable type'): - hash(inspect.signature(foo)) + hash(sig) def test_signature_str(self): def foo(a:int=1, *, b, c=None, **kwargs) -> 42: @@ -2609,19 +2474,6 @@ self.assertEqual(self.signature(Spam.foo), self.signature(Ham.foo)) - def test_signature_from_callable_python_obj(self): - class MySignature(inspect.Signature): pass - def foo(a, *, b:1): pass - foo_sig = MySignature.from_callable(foo) - self.assertTrue(isinstance(foo_sig, MySignature)) - - @unittest.skipIf(MISSING_C_DOCSTRINGS, - "Signature information for builtins requires docstrings") - def test_signature_from_callable_builtin_obj(self): - class MySignature(inspect.Signature): pass - sig = MySignature.from_callable(_pickle.Pickler) - self.assertTrue(isinstance(sig, MySignature)) - class TestParameterObject(unittest.TestCase): def test_signature_parameter_kinds(self): @@ -2667,16 +2519,6 @@ p.replace(kind=inspect.Parameter.VAR_POSITIONAL) self.assertTrue(repr(p).startswith(' {42:'ham'}: pass - sig = inspect.signature(foo) - ba = sig.bind(20, 30, z={}) - - for ver in range(pickle.HIGHEST_PROTOCOL + 1): - with self.subTest(pickle_ver=ver): - ba_pickled = pickle.loads(pickle.dumps(ba, ver)) - self.assertEqual(ba, ba_pickled) - class TestSignaturePrivateHelpers(unittest.TestCase): def test_signature_get_bound_param(self): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_io.py --- a/Lib/test/test_io.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_io.py Sun Mar 23 09:44:28 2014 +0100 @@ -2615,38 +2615,6 @@ txt.write('5') self.assertEqual(b''.join(raw._write_stack), b'123\n45') - def test_bufio_write_through(self): - # Issue #21396: write_through=True doesn't force a flush() - # on the underlying binary buffered object. - flush_called, write_called = [], [] - class BufferedWriter(self.BufferedWriter): - def flush(self, *args, **kwargs): - flush_called.append(True) - return super().flush(*args, **kwargs) - def write(self, *args, **kwargs): - write_called.append(True) - return super().write(*args, **kwargs) - - rawio = self.BytesIO() - data = b"a" - bufio = BufferedWriter(rawio, len(data)*2) - textio = self.TextIOWrapper(bufio, encoding='ascii', - write_through=True) - # write to the buffered io but don't overflow the buffer - text = data.decode('ascii') - textio.write(text) - - # buffer.flush is not called with write_through=True - self.assertFalse(flush_called) - # buffer.write *is* called with write_through=True - self.assertTrue(write_called) - self.assertEqual(rawio.getvalue(), b"") # no flush - - write_called = [] # reset - textio.write(text * 10) # total content is larger than bufio buffer - self.assertTrue(write_called) - self.assertEqual(rawio.getvalue(), data * 11) # all flushed - def test_read_nonbytes(self): # Issue #17106 # Crash when underlying read() returns non-bytes @@ -2713,34 +2681,6 @@ self.assertFalse(err) self.assertEqual("ok", out.decode().strip()) - def test_read_byteslike(self): - r = MemviewBytesIO(b'Just some random string\n') - t = self.TextIOWrapper(r, 'utf-8') - - # TextIOwrapper will not read the full string, because - # we truncate it to a multiple of the native int size - # so that we can construct a more complex memoryview. - bytes_val = _to_memoryview(r.getvalue()).tobytes() - - self.assertEqual(t.read(200), bytes_val.decode('utf-8')) - -class MemviewBytesIO(io.BytesIO): - '''A BytesIO object whose read method returns memoryviews - rather than bytes''' - - def read1(self, len_): - return _to_memoryview(super().read1(len_)) - - def read(self, len_): - return _to_memoryview(super().read(len_)) - -def _to_memoryview(buf): - '''Convert bytes-object *buf* to a non-trivial memoryview''' - - arr = array.array('i') - idx = len(buf) - len(buf) % arr.itemsize - arr.frombytes(buf[:idx]) - return memoryview(arr) class CTextIOWrapperTest(TextIOWrapperTest): io = io diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_ipaddress.py --- a/Lib/test/test_ipaddress.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_ipaddress.py Sun Mar 23 09:44:28 2014 +0100 @@ -1593,14 +1593,6 @@ addr3.exploded) self.assertEqual('192.168.178.1', addr4.exploded) - def testReversePointer(self): - addr1 = ipaddress.IPv4Address('127.0.0.1') - addr2 = ipaddress.IPv6Address('2001:db8::1') - self.assertEqual('1.0.0.127.in-addr.arpa', addr1.reverse_pointer) - self.assertEqual('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.' + - 'b.d.0.1.0.0.2.ip6.arpa', - addr2.reverse_pointer) - def testIntRepresentation(self): self.assertEqual(16909060, int(self.ipv4_address)) self.assertEqual(42540616829182469433547762482097946625, diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_itertools.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,7 +1,7 @@ import unittest from test import support from itertools import * -import weakref +from weakref import proxy from decimal import Decimal from fractions import Fraction import sys @@ -411,7 +411,7 @@ self.pickletest(permutations(values, r)) # test pickling - @support.impl_detail("tuple reuse is specific to CPython") + @support.impl_detail("tuple resuse is CPython specific") def test_permutations_tuple_reuse(self): self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1) self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1) @@ -1087,15 +1087,6 @@ list(range(*args))) self.pickletest(islice(range(100), *args)) - # Issue #21321: check source iterator is not referenced - # from islice() after the latter has been exhausted - it = (x for x in (1, 2)) - wr = weakref.ref(it) - it = islice(it, 1) - self.assertIsNotNone(wr()) - list(it) # exhaust the iterator - self.assertIsNone(wr()) - def test_takewhile(self): data = [1, 3, 5, 20, 2, 4, 6, 8] self.assertEqual(list(takewhile(underten, data)), [1, 3, 5]) @@ -1212,7 +1203,7 @@ # test that tee objects are weak referencable a, b = tee(range(10)) - p = weakref.proxy(a) + p = proxy(a) self.assertEqual(getattr(p, '__class__'), type(b)) del a self.assertRaises(ReferenceError, getattr, p, '__class__') @@ -2007,19 +1998,6 @@ ... # unique_justseen('ABBCcAD', str.lower) --> A B C A D ... return map(next, map(itemgetter(1), groupby(iterable, key))) ->>> def first_true(iterable, default=False, pred=None): -... '''Returns the first true value in the iterable. -... -... If no true value is found, returns *default* -... -... If *pred* is not None, returns the first item -... for which pred(item) is true. -... -... ''' -... # first_true([a,b,c], x) --> a or b or c or x -... # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x -... return next(filter(pred, iterable), default) - This is not part of the examples but it tests to make sure the definitions perform as purported. @@ -2097,9 +2075,6 @@ >>> list(unique_justseen('ABBCcAD', str.lower)) ['A', 'B', 'C', 'A', 'D'] ->>> first_true('ABC0DEF1', '9', str.isdigit) -'0' - """ __test__ = {'libreftest' : libreftest} diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_json/test_decode.py --- a/Lib/test/test_json/test_decode.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_json/test_decode.py Sun Mar 23 09:44:28 2014 +0100 @@ -91,9 +91,5 @@ self.assertEqual(self.loads(bom_in_str), '\ufeff') self.assertEqual(self.json.load(StringIO(bom_in_str)), '\ufeff') - def test_negative_index(self): - d = self.json.JSONDecoder() - self.assertRaises(ValueError, d.raw_decode, 'a'*42, -50000) - class TestPyDecode(TestDecode, PyTest): pass class TestCDecode(TestDecode, CTest): pass diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_math.py --- a/Lib/test/test_math.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_math.py Sun Mar 23 09:44:28 2014 +0100 @@ -422,17 +422,9 @@ self.assertEqual(math.factorial(i), py_factorial(i)) self.assertRaises(ValueError, math.factorial, -1) self.assertRaises(ValueError, math.factorial, -1.0) - self.assertRaises(ValueError, math.factorial, -10**100) - self.assertRaises(ValueError, math.factorial, -1e100) self.assertRaises(ValueError, math.factorial, math.pi) - - # Other implementations may place different upper bounds. - @support.cpython_only - def testFactorialHugeInputs(self): - # Currently raises ValueError for inputs that are too large - # to fit into a C long. - self.assertRaises(OverflowError, math.factorial, 10**100) - self.assertRaises(OverflowError, math.factorial, 1e100) + self.assertRaises(OverflowError, math.factorial, sys.maxsize+1) + self.assertRaises(OverflowError, math.factorial, 10e100) def testFloor(self): self.assertRaises(TypeError, math.floor) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_minidom.py --- a/Lib/test/test_minidom.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_minidom.py Sun Mar 23 09:44:28 2014 +0100 @@ -1518,10 +1518,6 @@ doc2 = parseString(doc.toxml()) self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) - def testExceptionOnSpacesInXMLNSValue(self): - with self.assertRaisesRegex(ValueError, 'Unsupported syntax'): - parseString('') - def testDocRemoveChild(self): doc = parse(tstfile) title_tag = doc.documentElement.getElementsByTagName("TITLE")[0] diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_module.py --- a/Lib/test/test_module.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_module.py Sun Mar 23 09:44:28 2014 +0100 @@ -30,22 +30,6 @@ pass self.assertEqual(foo.__doc__, ModuleType.__doc__) - def test_unintialized_missing_getattr(self): - # Issue 8297 - # test the text in the AttributeError of an uninitialized module - foo = ModuleType.__new__(ModuleType) - self.assertRaisesRegex( - AttributeError, "module has no attribute 'not_here'", - getattr, foo, "not_here") - - def test_missing_getattr(self): - # Issue 8297 - # test the text in the AttributeError - foo = ModuleType("foo") - self.assertRaisesRegex( - AttributeError, "module 'foo' has no attribute 'not_here'", - getattr, foo, "not_here") - def test_no_docstring(self): # Regularly initialized module, no docstring foo = ModuleType("foo") @@ -227,14 +211,6 @@ b"len = len", b"shutil.rmtree = rmtree"}) - def test_descriptor_errors_propogate(self): - class Descr: - def __get__(self, o, t): - raise RuntimeError - class M(ModuleType): - melon = Descr() - self.assertRaises(RuntimeError, getattr, M("mymod"), "melon") - # frozen and namespace module reprs are tested in importlib. diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_namespace_pkgs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_namespace_pkgs.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,293 @@ +import contextlib +import importlib.abc +import importlib.machinery +import os +import sys +import types +import unittest + +from test.test_importlib import util +from test.support import run_unittest + +# needed tests: +# +# need to test when nested, so that the top-level path isn't sys.path +# need to test dynamic path detection, both at top-level and nested +# with dynamic path, check when a loader is returned on path reload (that is, +# trying to switch from a namespace package to a regular package) + + +@contextlib.contextmanager +def sys_modules_context(): + """ + Make sure sys.modules is the same object and has the same content + when exiting the context as when entering. + + Similar to importlib.test.util.uncache, but doesn't require explicit + names. + """ + sys_modules_saved = sys.modules + sys_modules_copy = sys.modules.copy() + try: + yield + finally: + sys.modules = sys_modules_saved + sys.modules.clear() + sys.modules.update(sys_modules_copy) + + +@contextlib.contextmanager +def namespace_tree_context(**kwargs): + """ + Save import state and sys.modules cache and restore it on exit. + Typical usage: + + >>> with namespace_tree_context(path=['/tmp/xxyy/portion1', + ... '/tmp/xxyy/portion2']): + ... pass + """ + # use default meta_path and path_hooks unless specified otherwise + kwargs.setdefault('meta_path', sys.meta_path) + kwargs.setdefault('path_hooks', sys.path_hooks) + import_context = util.import_state(**kwargs) + with import_context, sys_modules_context(): + yield + +class NamespacePackageTest(unittest.TestCase): + """ + Subclasses should define self.root and self.paths (under that root) + to be added to sys.path. + """ + root = os.path.join(os.path.dirname(__file__), 'namespace_pkgs') + + def setUp(self): + self.resolved_paths = [ + os.path.join(self.root, path) for path in self.paths + ] + self.ctx = namespace_tree_context(path=self.resolved_paths) + self.ctx.__enter__() + + def tearDown(self): + # TODO: will we ever want to pass exc_info to __exit__? + self.ctx.__exit__(None, None, None) + +class SingleNamespacePackage(NamespacePackageTest): + paths = ['portion1'] + + def test_simple_package(self): + import foo.one + self.assertEqual(foo.one.attr, 'portion1 foo one') + + def test_cant_import_other(self): + with self.assertRaises(ImportError): + import foo.two + + def test_module_repr(self): + import foo.one + self.assertEqual(repr(foo), "") + + +class DynamicPatheNamespacePackage(NamespacePackageTest): + paths = ['portion1'] + + def test_dynamic_path(self): + # Make sure only 'foo.one' can be imported + import foo.one + self.assertEqual(foo.one.attr, 'portion1 foo one') + + with self.assertRaises(ImportError): + import foo.two + + # Now modify sys.path + sys.path.append(os.path.join(self.root, 'portion2')) + + # And make sure foo.two is now importable + import foo.two + self.assertEqual(foo.two.attr, 'portion2 foo two') + + +class CombinedNamespacePackages(NamespacePackageTest): + paths = ['both_portions'] + + def test_imports(self): + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'both_portions foo one') + self.assertEqual(foo.two.attr, 'both_portions foo two') + + +class SeparatedNamespacePackages(NamespacePackageTest): + paths = ['portion1', 'portion2'] + + def test_imports(self): + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'portion1 foo one') + self.assertEqual(foo.two.attr, 'portion2 foo two') + + +class SeparatedOverlappingNamespacePackages(NamespacePackageTest): + paths = ['portion1', 'both_portions'] + + def test_first_path_wins(self): + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'portion1 foo one') + self.assertEqual(foo.two.attr, 'both_portions foo two') + + def test_first_path_wins_again(self): + sys.path.reverse() + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'both_portions foo one') + self.assertEqual(foo.two.attr, 'both_portions foo two') + + def test_first_path_wins_importing_second_first(self): + import foo.two + import foo.one + self.assertEqual(foo.one.attr, 'portion1 foo one') + self.assertEqual(foo.two.attr, 'both_portions foo two') + + +class SingleZipNamespacePackage(NamespacePackageTest): + paths = ['top_level_portion1.zip'] + + def test_simple_package(self): + import foo.one + self.assertEqual(foo.one.attr, 'portion1 foo one') + + def test_cant_import_other(self): + with self.assertRaises(ImportError): + import foo.two + + +class SeparatedZipNamespacePackages(NamespacePackageTest): + paths = ['top_level_portion1.zip', 'portion2'] + + def test_imports(self): + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'portion1 foo one') + self.assertEqual(foo.two.attr, 'portion2 foo two') + self.assertIn('top_level_portion1.zip', foo.one.__file__) + self.assertNotIn('.zip', foo.two.__file__) + + +class SingleNestedZipNamespacePackage(NamespacePackageTest): + paths = ['nested_portion1.zip/nested_portion1'] + + def test_simple_package(self): + import foo.one + self.assertEqual(foo.one.attr, 'portion1 foo one') + + def test_cant_import_other(self): + with self.assertRaises(ImportError): + import foo.two + + +class SeparatedNestedZipNamespacePackages(NamespacePackageTest): + paths = ['nested_portion1.zip/nested_portion1', 'portion2'] + + def test_imports(self): + import foo.one + import foo.two + self.assertEqual(foo.one.attr, 'portion1 foo one') + self.assertEqual(foo.two.attr, 'portion2 foo two') + fn = os.path.join('nested_portion1.zip', 'nested_portion1') + self.assertIn(fn, foo.one.__file__) + self.assertNotIn('.zip', foo.two.__file__) + + +class LegacySupport(NamespacePackageTest): + paths = ['not_a_namespace_pkg', 'portion1', 'portion2', 'both_portions'] + + def test_non_namespace_package_takes_precedence(self): + import foo.one + with self.assertRaises(ImportError): + import foo.two + self.assertIn('__init__', foo.__file__) + self.assertNotIn('namespace', str(foo.__loader__).lower()) + + +class DynamicPathCalculation(NamespacePackageTest): + paths = ['project1', 'project2'] + + def test_project3_fails(self): + import parent.child.one + self.assertEqual(len(parent.__path__), 2) + self.assertEqual(len(parent.child.__path__), 2) + import parent.child.two + self.assertEqual(len(parent.__path__), 2) + self.assertEqual(len(parent.child.__path__), 2) + + self.assertEqual(parent.child.one.attr, 'parent child one') + self.assertEqual(parent.child.two.attr, 'parent child two') + + with self.assertRaises(ImportError): + import parent.child.three + + self.assertEqual(len(parent.__path__), 2) + self.assertEqual(len(parent.child.__path__), 2) + + def test_project3_succeeds(self): + import parent.child.one + self.assertEqual(len(parent.__path__), 2) + self.assertEqual(len(parent.child.__path__), 2) + import parent.child.two + self.assertEqual(len(parent.__path__), 2) + self.assertEqual(len(parent.child.__path__), 2) + + self.assertEqual(parent.child.one.attr, 'parent child one') + self.assertEqual(parent.child.two.attr, 'parent child two') + + with self.assertRaises(ImportError): + import parent.child.three + + # now add project3 + sys.path.append(os.path.join(self.root, 'project3')) + import parent.child.three + + # the paths dynamically get longer, to include the new directories + self.assertEqual(len(parent.__path__), 3) + self.assertEqual(len(parent.child.__path__), 3) + + self.assertEqual(parent.child.three.attr, 'parent child three') + + +class ZipWithMissingDirectory(NamespacePackageTest): + paths = ['missing_directory.zip'] + + @unittest.expectedFailure + def test_missing_directory(self): + # This will fail because missing_directory.zip contains: + # Length Date Time Name + # --------- ---------- ----- ---- + # 29 2012-05-03 18:13 foo/one.py + # 0 2012-05-03 20:57 bar/ + # 38 2012-05-03 20:57 bar/two.py + # --------- ------- + # 67 3 files + + # Because there is no 'foo/', the zipimporter currently doesn't + # know that foo is a namespace package + + import foo.one + + def test_present_directory(self): + # This succeeds because there is a "bar/" in the zip file + import bar.two + self.assertEqual(bar.two.attr, 'missing_directory foo two') + + +class ModuleAndNamespacePackageInSameDir(NamespacePackageTest): + paths = ['module_and_namespace_package'] + + def test_module_before_namespace_package(self): + # Make sure we find the module in preference to the + # namespace package. + import a_test + self.assertEqual(a_test.attr, 'in module') + + +if __name__ == "__main__": + unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_operator.py --- a/Lib/test/test_operator.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_operator.py Sun Mar 23 09:44:28 2014 +0100 @@ -203,15 +203,6 @@ self.assertRaises(TypeError, operator.mul, None, None) self.assertTrue(operator.mul(5, 2) == 10) - def test_matmul(self): - operator = self.module - self.assertRaises(TypeError, operator.matmul) - self.assertRaises(TypeError, operator.matmul, 42, 42) - class M: - def __matmul__(self, other): - return other - 1 - self.assertEqual(M() @ 42, 41) - def test_neg(self): operator = self.module self.assertRaises(TypeError, operator.neg) @@ -425,7 +416,6 @@ def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" - def __imatmul__ (self, other): return "imatmul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" @@ -440,7 +430,6 @@ self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") - self.assertEqual(operator.imatmul (c, 5), "imatmul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_optparse.py --- a/Lib/test/test_optparse.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_optparse.py Sun Mar 23 09:44:28 2014 +0100 @@ -395,7 +395,6 @@ self.assertRaises(self.parser.remove_option, ('foo',), None, ValueError, "no such option 'foo'") - @support.impl_detail('Relies on sys.getrefcount', cpython=True) def test_refleak(self): # If an OptionParser is carrying around a reference to a large # object, various cycles can prevent it from being GC'd in diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_os.py --- a/Lib/test/test_os.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_os.py Sun Mar 23 09:44:28 2014 +0100 @@ -39,10 +39,6 @@ import fcntl except ImportError: fcntl = None -try: - import _winapi -except ImportError: - _winapi = None from test.script_helper import assert_python_ok @@ -905,7 +901,7 @@ os.makedirs(path, mode) self.assertRaises(OSError, os.makedirs, path, mode) self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False) - os.makedirs(path, 0o776, exist_ok=True) + self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True) os.makedirs(path, mode=mode, exist_ok=True) os.umask(old_mask) @@ -942,8 +938,9 @@ os.makedirs(path, mode, exist_ok=True) # remove the bit. os.chmod(path, stat.S_IMODE(os.lstat(path).st_mode) & ~S_ISGID) - # May work even when the bit is not already set when demanded. - os.makedirs(path, mode | S_ISGID, exist_ok=True) + with self.assertRaises(OSError): + # Should fail when the bit is not already set when demanded. + os.makedirs(path, mode | S_ISGID, exist_ok=True) finally: os.umask(old_mask) @@ -1074,49 +1071,6 @@ """ assert_python_ok('-c', code) - def test_urandom_fd_closed(self): - # Issue #21207: urandom() should reopen its fd to /dev/urandom if - # closed. - code = """if 1: - import os - import sys - os.urandom(4) - os.closerange(3, 256) - sys.stdout.buffer.write(os.urandom(4)) - """ - rc, out, err = assert_python_ok('-Sc', code) - - def test_urandom_fd_reopened(self): - # Issue #21207: urandom() should detect its fd to /dev/urandom - # changed to something else, and reopen it. - with open(support.TESTFN, 'wb') as f: - f.write(b"x" * 256) - self.addCleanup(os.unlink, support.TESTFN) - code = """if 1: - import os - import sys - os.urandom(4) - for fd in range(3, 256): - try: - os.close(fd) - except OSError: - pass - else: - # Found the urandom fd (XXX hopefully) - break - os.closerange(3, 256) - with open({TESTFN!r}, 'rb') as f: - os.dup2(f.fileno(), fd) - sys.stdout.buffer.write(os.urandom(4)) - sys.stdout.buffer.write(os.urandom(4)) - """.format(TESTFN=support.TESTFN) - rc, out, err = assert_python_ok('-Sc', code) - self.assertEqual(len(out), 8) - self.assertNotEqual(out[0:4], out[4:8]) - rc, out2, err2 = assert_python_ok('-Sc', code) - self.assertEqual(len(out2), 8) - self.assertNotEqual(out2, out) - @contextlib.contextmanager def _execvpe_mockup(defpath=None): @@ -1777,37 +1731,6 @@ shutil.rmtree(level1) -@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") -class Win32JunctionTests(unittest.TestCase): - junction = 'junctiontest' - junction_target = os.path.dirname(os.path.abspath(__file__)) - - def setUp(self): - assert os.path.exists(self.junction_target) - assert not os.path.exists(self.junction) - - def tearDown(self): - if os.path.exists(self.junction): - # os.rmdir delegates to Windows' RemoveDirectoryW, - # which removes junction points safely. - os.rmdir(self.junction) - - def test_create_junction(self): - _winapi.CreateJunction(self.junction_target, self.junction) - self.assertTrue(os.path.exists(self.junction)) - self.assertTrue(os.path.isdir(self.junction)) - - # Junctions are not recognized as links. - self.assertFalse(os.path.islink(self.junction)) - - def test_unlink_removes_junction(self): - _winapi.CreateJunction(self.junction_target, self.junction) - self.assertTrue(os.path.exists(self.junction)) - - os.unlink(self.junction) - self.assertFalse(os.path.exists(self.junction)) - - @support.skip_unless_symlink class NonLocalSymlinkTests(unittest.TestCase): @@ -2579,7 +2502,6 @@ RemoveDirsTests, CPUCountTests, FDInheritanceTests, - Win32JunctionTests, ) if __name__ == "__main__": diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_pathlib.py Sun Mar 23 09:44:28 2014 +0100 @@ -197,25 +197,6 @@ self.assertEqual(P(P('a'), 'b'), P('a/b')) self.assertEqual(P(P('a'), P('b')), P('a/b')) - def _check_str_subclass(self, *args): - # Issue #21127: it should be possible to construct a PurePath object - # from an str subclass instance, and it then gets converted to - # a pure str object. - class StrSubclass(str): - pass - P = self.cls - p = P(*(StrSubclass(x) for x in args)) - self.assertEqual(p, P(*args)) - for part in p.parts: - self.assertIs(type(part), str) - - def test_str_subclass_common(self): - self._check_str_subclass('') - self._check_str_subclass('.') - self._check_str_subclass('a') - self._check_str_subclass('a/b.txt') - self._check_str_subclass('/a/b.txt') - def test_join_common(self): P = self.cls p = P('a/b') @@ -709,17 +690,6 @@ p = self.cls('//a/b/c/d') self.assertEqual(str(p), '\\\\a\\b\\c\\d') - def test_str_subclass(self): - self._check_str_subclass('c:') - self._check_str_subclass('c:a') - self._check_str_subclass('c:a\\b.txt') - self._check_str_subclass('c:\\') - self._check_str_subclass('c:\\a') - self._check_str_subclass('c:\\a\\b.txt') - self._check_str_subclass('\\\\some\\share') - self._check_str_subclass('\\\\some\\share\\a') - self._check_str_subclass('\\\\some\\share\\a\\b.txt') - def test_eq(self): P = self.cls self.assertEqual(P('c:a/b'), P('c:a/b')) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_pep380.py --- a/Lib/test/test_pep380.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_pep380.py Sun Mar 23 09:44:28 2014 +0100 @@ -993,25 +993,6 @@ del inner_gen gc_collect() - def test_send_tuple_with_custom_generator(self): - # See issue #21209. - class MyGen: - def __iter__(self): - return self - def __next__(self): - return 42 - def send(self, what): - nonlocal v - v = what - return None - def outer(): - v = yield from MyGen() - g = outer() - next(g) - v = None - g.send((1, 2, 3, 4)) - self.assertEqual(v, (1, 2, 3, 4)) - def test_main(): from test import support diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_pkgutil.py --- a/Lib/test/test_pkgutil.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_pkgutil.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,4 +1,4 @@ -from test.support import run_unittest, unload, check_warnings, CleanImport +from test.support import run_unittest, unload, check_warnings import unittest import sys import importlib @@ -345,23 +345,6 @@ finally: __loader__ = this_loader - def test_get_loader_handles_missing_spec_attribute(self): - name = 'spam' - mod = type(sys)(name) - del mod.__spec__ - with CleanImport(name): - sys.modules[name] = mod - loader = pkgutil.get_loader(name) - self.assertIsNone(loader) - - def test_get_loader_handles_spec_attribute_none(self): - name = 'spam' - mod = type(sys)(name) - mod.__spec__ = None - with CleanImport(name): - sys.modules[name] = mod - loader = pkgutil.get_loader(name) - self.assertIsNone(loader) def test_find_loader_avoids_emulation(self): with check_warnings() as w: diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_poplib.py --- a/Lib/test/test_poplib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_poplib.py Sun Mar 23 09:44:28 2014 +0100 @@ -349,18 +349,23 @@ if SUPPORTS_SSL: - from test.test_ftplib import SSLConnection - class DummyPOP3_SSLHandler(SSLConnection, DummyPOP3Handler): + class DummyPOP3_SSLHandler(DummyPOP3Handler): def __init__(self, conn): asynchat.async_chat.__init__(self, conn) - self.secure_connection() + ssl_socket = ssl.wrap_socket(self.socket, certfile=CERTFILE, + server_side=True, + do_handshake_on_connect=False) + self.del_channel() + self.set_socket(ssl_socket) + # Must try handshake before calling push() + self.tls_active = True + self.tls_starting = True + self._do_tls_handshake() self.set_terminator(b"\r\n") self.in_buffer = [] self.push('+OK dummy pop3 server ready. ') - self.tls_active = True - self.tls_starting = False @requires_ssl diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_pyexpat.py --- a/Lib/test/test_pyexpat.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_pyexpat.py Sun Mar 23 09:44:28 2014 +0100 @@ -236,18 +236,6 @@ operations = out.out self._verify_parse_output(operations) - def test_parse_again(self): - parser = expat.ParserCreate() - file = BytesIO(data) - parser.ParseFile(file) - # Issue 6676: ensure a meaningful exception is raised when attempting - # to parse more than one XML document per xmlparser instance, - # a limitation of the Expat library. - with self.assertRaises(expat.error) as cm: - parser.ParseFile(file) - self.assertEqual(expat.ErrorString(cm.exception.code), - expat.errors.XML_ERROR_FINISHED) - class NamespaceSeparatorTest(unittest.TestCase): def test_legal(self): # Tests that make sure we get errors when the namespace_separator value diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_set.py --- a/Lib/test/test_set.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_set.py Sun Mar 23 09:44:28 2014 +0100 @@ -929,7 +929,7 @@ class TestBasicOpsBytes(TestBasicOps, unittest.TestCase): def setUp(self): - self.case = "bytes set" + self.case = "string set" self.values = [b"a", b"b", b"c"] self.set = set(self.values) self.dup = set(self.values) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_signal.py --- a/Lib/test/test_signal.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_signal.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,7 +1,6 @@ import unittest from test import support from contextlib import closing -import enum import gc import pickle import select @@ -40,23 +39,6 @@ return None -class GenericTests(unittest.TestCase): - - @unittest.skipIf(threading is None, "test needs threading module") - def test_enums(self): - for name in dir(signal): - sig = getattr(signal, name) - if name in {'SIG_DFL', 'SIG_IGN'}: - self.assertIsInstance(sig, signal.Handlers) - elif name in {'SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'}: - self.assertIsInstance(sig, signal.Sigmasks) - elif name.startswith('SIG') and not name.startswith('SIG_'): - self.assertIsInstance(sig, signal.Signals) - elif name.startswith('CTRL_'): - self.assertIsInstance(sig, signal.Signals) - self.assertEqual(sys.platform, "win32") - - @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. @@ -213,7 +195,6 @@ def test_getsignal(self): hup = signal.signal(signal.SIGHUP, self.trivial_signal_handler) - self.assertIsInstance(hup, signal.Handlers) self.assertEqual(signal.getsignal(signal.SIGHUP), self.trivial_signal_handler) signal.signal(signal.SIGHUP, hup) @@ -290,7 +271,7 @@ os.close(read) os.close(write) - """.format(tuple(map(int, signals)), ordered, test_body) + """.format(signals, ordered, test_body) assert_python_ok('-c', code) @@ -623,8 +604,6 @@ signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) os.kill(os.getpid(), signum) pending = signal.sigpending() - for sig in pending: - assert isinstance(sig, signal.Signals), repr(pending) if pending != {signum}: raise Exception('%s != {%s}' % (pending, signum)) try: @@ -681,7 +660,6 @@ code = '''if 1: import signal import sys - from signal import Signals def handler(signum, frame): 1/0 @@ -724,7 +702,6 @@ def test(signum): signal.alarm(1) received = signal.sigwait([signum]) - assert isinstance(received, signal.Signals), received if received != signum: raise Exception('received %s, not %s' % (received, signum)) ''') @@ -865,14 +842,8 @@ def kill(signum): os.kill(os.getpid(), signum) - def check_mask(mask): - for sig in mask: - assert isinstance(sig, signal.Signals), repr(sig) - def read_sigmask(): - sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, []) - check_mask(sigmask) - return sigmask + return signal.pthread_sigmask(signal.SIG_BLOCK, []) signum = signal.SIGUSR1 @@ -881,7 +852,6 @@ # Unblock SIGUSR1 (and copy the old mask) to test our signal handler old_mask = signal.pthread_sigmask(signal.SIG_UNBLOCK, [signum]) - check_mask(old_mask) try: kill(signum) except ZeroDivisionError: @@ -891,13 +861,11 @@ # Block and then raise SIGUSR1. The signal is blocked: the signal # handler is not called, and the signal is now pending - mask = signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) - check_mask(mask) + signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) kill(signum) # Check the new mask blocked = read_sigmask() - check_mask(blocked) if signum not in blocked: raise Exception("%s not in %s" % (signum, blocked)) if old_mask ^ blocked != {signum}: @@ -960,7 +928,7 @@ def test_main(): try: - support.run_unittest(GenericTests, PosixTests, InterProcessSignalTests, + support.run_unittest(PosixTests, InterProcessSignalTests, WakeupFDTests, WakeupSignalTests, SiginterruptTest, ItimerTest, WindowsSignalTests, PendingSignalsTests) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_site.py --- a/Lib/test/test_site.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_site.py Sun Mar 23 09:44:28 2014 +0100 @@ -414,8 +414,6 @@ @test.support.requires_resource('network') @unittest.skipUnless(sys.version_info[3] == 'final', 'only for released versions') - @unittest.skipUnless(hasattr(urllib.request, "HTTPSHandler"), - 'need SSL support to download license') def test_license_exists_at_url(self): # This test is a bit fragile since it depends on the format of the # string displayed by license in the absence of a LICENSE file. @@ -459,8 +457,7 @@ # http://bugs.python.org/issue19218> collection_mods = {'_collections', 'collections', 'functools', 'heapq', 'itertools', 'keyword', 'operator', - 'reprlib', 'types', 'weakref' - }.difference(sys.builtin_module_names) + 'reprlib', 'types', 'weakref'} self.assertFalse(modules.intersection(collection_mods), stderr) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_smtplib.py --- a/Lib/test/test_smtplib.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_smtplib.py Sun Mar 23 09:44:28 2014 +0100 @@ -619,7 +619,6 @@ data_response = None rcpt_count = 0 rset_count = 0 - disconnect = 0 def __init__(self, extra_features, *args, **kw): self._extrafeatures = ''.join( @@ -685,8 +684,6 @@ super().smtp_MAIL(arg) else: self.push(self.mail_response) - if self.disconnect: - self.close_when_done() def smtp_RCPT(self, arg): if self.rcpt_response is None: @@ -878,16 +875,6 @@ #TODO: add tests for correct AUTH method fallback now that the #test infrastructure can support it. - # Issue 17498: make sure _rset does not raise SMTPServerDisconnected exception - def test__rest_from_mail_cmd(self): - smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) - smtp.noop() - self.serv._SMTPchannel.mail_response = '451 Requested action aborted' - self.serv._SMTPchannel.disconnect = True - with self.assertRaises(smtplib.SMTPSenderRefused): - smtp.sendmail('John', 'Sally', 'test message') - self.assertIsNone(smtp.sock) - # Issue 5713: make sure close, not rset, is called if we get a 421 error def test_421_from_mail_cmd(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_socket.py --- a/Lib/test/test_socket.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_socket.py Sun Mar 23 09:44:28 2014 +0100 @@ -867,7 +867,7 @@ # Find one service that exists, then check all the related interfaces. # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. - if (sys.platform.startswith(('freebsd', 'netbsd', 'gnukfreebsd')) + if (sys.platform.startswith(('freebsd', 'netbsd')) or sys.platform in ('linux', 'darwin')): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_ssl.py Sun Mar 23 09:44:28 2014 +0100 @@ -86,12 +86,6 @@ # 0.9.8 or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 0, 15) -def utc_offset(): #NOTE: ignore issues like #1647654 - # local time = utc time + utc offset - if time.daylight and time.localtime().tm_isdst > 0: - return -time.altzone # seconds - return -time.timezone - def asn1time(cert_time): # Some versions of OpenSSL ignore seconds, see #18207 # 0.9.8.i @@ -140,14 +134,6 @@ self.assertIn(ssl.HAS_SNI, {True, False}) self.assertIn(ssl.HAS_ECDH, {True, False}) - def test_str_for_enums(self): - # Make sure that the PROTOCOL_* constants have enum-like string - # reprs. - proto = ssl.PROTOCOL_SSLv3 - self.assertEqual(str(proto), '_SSLMethod.PROTOCOL_SSLv3') - ctx = ssl.SSLContext(proto) - self.assertIs(ctx.protocol, proto) - def test_random(self): v = ssl.RAND_status() if support.verbose: @@ -657,71 +643,6 @@ ctx.wrap_socket(s) self.assertEqual(str(cx.exception), "only stream sockets are supported") - def cert_time_ok(self, timestring, timestamp): - self.assertEqual(ssl.cert_time_to_seconds(timestring), timestamp) - - def cert_time_fail(self, timestring): - with self.assertRaises(ValueError): - ssl.cert_time_to_seconds(timestring) - - @unittest.skipUnless(utc_offset(), - 'local time needs to be different from UTC') - def test_cert_time_to_seconds_timezone(self): - # Issue #19940: ssl.cert_time_to_seconds() returns wrong - # results if local timezone is not UTC - self.cert_time_ok("May 9 00:00:00 2007 GMT", 1178668800.0) - self.cert_time_ok("Jan 5 09:34:43 2018 GMT", 1515144883.0) - - def test_cert_time_to_seconds(self): - timestring = "Jan 5 09:34:43 2018 GMT" - ts = 1515144883.0 - self.cert_time_ok(timestring, ts) - # accept keyword parameter, assert its name - self.assertEqual(ssl.cert_time_to_seconds(cert_time=timestring), ts) - # accept both %e and %d (space or zero generated by strftime) - self.cert_time_ok("Jan 05 09:34:43 2018 GMT", ts) - # case-insensitive - self.cert_time_ok("JaN 5 09:34:43 2018 GmT", ts) - self.cert_time_fail("Jan 5 09:34 2018 GMT") # no seconds - self.cert_time_fail("Jan 5 09:34:43 2018") # no GMT - self.cert_time_fail("Jan 5 09:34:43 2018 UTC") # not GMT timezone - self.cert_time_fail("Jan 35 09:34:43 2018 GMT") # invalid day - self.cert_time_fail("Jon 5 09:34:43 2018 GMT") # invalid month - self.cert_time_fail("Jan 5 24:00:00 2018 GMT") # invalid hour - self.cert_time_fail("Jan 5 09:60:43 2018 GMT") # invalid minute - - newyear_ts = 1230768000.0 - # leap seconds - self.cert_time_ok("Dec 31 23:59:60 2008 GMT", newyear_ts) - # same timestamp - self.cert_time_ok("Jan 1 00:00:00 2009 GMT", newyear_ts) - - self.cert_time_ok("Jan 5 09:34:59 2018 GMT", 1515144899) - # allow 60th second (even if it is not a leap second) - self.cert_time_ok("Jan 5 09:34:60 2018 GMT", 1515144900) - # allow 2nd leap second for compatibility with time.strptime() - self.cert_time_ok("Jan 5 09:34:61 2018 GMT", 1515144901) - self.cert_time_fail("Jan 5 09:34:62 2018 GMT") # invalid seconds - - # no special treatement for the special value: - # 99991231235959Z (rfc 5280) - self.cert_time_ok("Dec 31 23:59:59 9999 GMT", 253402300799.0) - - @support.run_with_locale('LC_ALL', '') - def test_cert_time_to_seconds_locale(self): - # `cert_time_to_seconds()` should be locale independent - - def local_february_name(): - return time.strftime('%b', (1, 2, 3, 4, 5, 6, 0, 0, 0)) - - if local_february_name().lower() == 'feb': - self.skipTest("locale-specific month name needs to be " - "different from C locale") - - # locale-independent - self.cert_time_ok("Feb 9 00:00:00 2007 GMT", 1170979200.0) - self.cert_time_fail(local_february_name() + " 9 00:00:00 2007 GMT") - class ContextTests(unittest.TestCase): @@ -1450,12 +1371,14 @@ def test_get_server_certificate(self): def _test_get_server_certificate(host, port, cert=None): with support.transient_internet(host): - pem = ssl.get_server_certificate((host, port)) + pem = ssl.get_server_certificate((host, port), + ssl.PROTOCOL_SSLv23) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) try: pem = ssl.get_server_certificate((host, port), + ssl.PROTOCOL_SSLv23, ca_certs=CERTFILE) except ssl.SSLError as x: #should fail @@ -1465,6 +1388,7 @@ self.fail("Got server certificate %s for %s:%s!" % (pem, host, port)) pem = ssl.get_server_certificate((host, port), + ssl.PROTOCOL_SSLv23, ca_certs=cert) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) @@ -2547,36 +2471,6 @@ s.write(b"over\n") s.close() - def test_nonblocking_send(self): - server = ThreadedEchoServer(CERTFILE, - certreqs=ssl.CERT_NONE, - ssl_version=ssl.PROTOCOL_TLSv1, - cacerts=CERTFILE, - chatty=True, - connectionchatty=False) - with server: - s = ssl.wrap_socket(socket.socket(), - server_side=False, - certfile=CERTFILE, - ca_certs=CERTFILE, - cert_reqs=ssl.CERT_NONE, - ssl_version=ssl.PROTOCOL_TLSv1) - s.connect((HOST, server.port)) - s.setblocking(False) - - # If we keep sending data, at some point the buffers - # will be full and the call will block - buf = bytearray(8192) - def fill_buffer(): - while True: - s.send(buf) - self.assertRaises((ssl.SSLWantWriteError, - ssl.SSLWantReadError), fill_buffer) - - # Now read all the output and discard it - s.setblocking(True) - s.close() - def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) @@ -2699,12 +2593,7 @@ # should be enabled by default on SSL contexts. context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.load_cert_chain(CERTFILE) - # Prior to OpenSSL 1.0.0, ECDH ciphers have to be enabled - # explicitly using the 'ECCdraft' cipher alias. Otherwise, - # our default cipher list should prefer ECDH-based ciphers - # automatically. - if ssl.OPENSSL_VERSION_INFO < (1, 0, 0): - context.set_ciphers("ECCdraft:ECDH") + context.set_ciphers("ECDH") with ThreadedEchoServer(context=context) as server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_string.py --- a/Lib/test/test_string.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_string.py Sun Mar 23 09:44:28 2014 +0100 @@ -32,23 +32,6 @@ self.assertEqual(fmt.format("foo{0}", "bar"), "foobar") self.assertEqual(fmt.format("foo{1}{0}-{1}", "bar", 6), "foo6bar-6") - def test_auto_numbering(self): - fmt = string.Formatter() - self.assertEqual(fmt.format('foo{}{}', 'bar', 6), - 'foo{}{}'.format('bar', 6)) - self.assertEqual(fmt.format('foo{1}{num}{1}', None, 'bar', num=6), - 'foo{1}{num}{1}'.format(None, 'bar', num=6)) - self.assertEqual(fmt.format('{:^{}}', 'bar', 6), - '{:^{}}'.format('bar', 6)) - self.assertEqual(fmt.format('{:^{pad}}{}', 'foo', 'bar', pad=6), - '{:^{pad}}{}'.format('foo', 'bar', pad=6)) - - with self.assertRaises(ValueError): - fmt.format('foo{1}{}', 'bar', 6) - - with self.assertRaises(ValueError): - fmt.format('foo{}{1}', 'bar', 6) - def test_conversion_specifiers(self): fmt = string.Formatter() self.assertEqual(fmt.format("-{arg!r}-", arg='test'), "-'test'-") diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_subprocess.py Sun Mar 23 09:44:28 2014 +0100 @@ -786,7 +786,6 @@ stdout=subprocess.PIPE, universal_newlines=1) p.stdin.write("line1\n") - p.stdin.flush() self.assertEqual(p.stdout.readline(), "line1\n") p.stdin.write("line3\n") p.stdin.close() @@ -1053,59 +1052,6 @@ if exc is not None: raise exc - @unittest.skipIf(threading is None, "threading required") - def test_threadsafe_wait(self): - """Issue21291: Popen.wait() needs to be threadsafe for returncode.""" - proc = subprocess.Popen([sys.executable, '-c', - 'import time; time.sleep(12)']) - self.assertEqual(proc.returncode, None) - results = [] - - def kill_proc_timer_thread(): - results.append(('thread-start-poll-result', proc.poll())) - # terminate it from the thread and wait for the result. - proc.kill() - proc.wait() - results.append(('thread-after-kill-and-wait', proc.returncode)) - # this wait should be a no-op given the above. - proc.wait() - results.append(('thread-after-second-wait', proc.returncode)) - - # This is a timing sensitive test, the failure mode is - # triggered when both the main thread and this thread are in - # the wait() call at once. The delay here is to allow the - # main thread to most likely be blocked in its wait() call. - t = threading.Timer(0.2, kill_proc_timer_thread) - t.start() - - if mswindows: - expected_errorcode = 1 - else: - # Should be -9 because of the proc.kill() from the thread. - expected_errorcode = -9 - - # Wait for the process to finish; the thread should kill it - # long before it finishes on its own. Supplying a timeout - # triggers a different code path for better coverage. - proc.wait(timeout=20) - self.assertEqual(proc.returncode, expected_errorcode, - msg="unexpected result in wait from main thread") - - # This should be a no-op with no change in returncode. - proc.wait() - self.assertEqual(proc.returncode, expected_errorcode, - msg="unexpected result in second main wait.") - - t.join() - # Ensure that all of the thread results are as expected. - # When a race condition occurs in wait(), the returncode could - # be set by the wrong thread that doesn't actually have it - # leading to an incorrect value. - self.assertEqual([('thread-start-poll-result', None), - ('thread-after-kill-and-wait', expected_errorcode), - ('thread-after-second-wait', expected_errorcode)], - results) - def test_issue8780(self): # Ensure that stdout is inherited from the parent # if stdout=PIPE is not used diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_sys.py --- a/Lib/test/test_sys.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_sys.py Sun Mar 23 09:44:28 2014 +0100 @@ -519,26 +519,6 @@ self.assertTrue(repr(sys.flags)) self.assertEqual(len(sys.flags), len(attrs)) - def assert_raise_on_new_sys_type(self, sys_attr): - # Users are intentionally prevented from creating new instances of - # sys.flags, sys.version_info, and sys.getwindowsversion. - attr_type = type(sys_attr) - with self.assertRaises(TypeError): - attr_type() - with self.assertRaises(TypeError): - attr_type.__new__(attr_type) - - def test_sys_flags_no_instantiation(self): - self.assert_raise_on_new_sys_type(sys.flags) - - def test_sys_version_info_no_instantiation(self): - self.assert_raise_on_new_sys_type(sys.version_info) - - def test_sys_getwindowsversion_no_instantiation(self): - # Skip if not being run on Windows. - test.support.get_attribute(sys, "getwindowsversion") - self.assert_raise_on_new_sys_type(sys.getwindowsversion()) - def test_clear_type_cache(self): sys._clear_type_cache() @@ -972,7 +952,7 @@ check(int, s) # (PyTypeObject + PyNumberMethods + PyMappingMethods + # PySequenceMethods + PyBufferProcs + 4P) - s = vsize('P2n17Pl4Pn9Pn11PIP') + struct.calcsize('34P 3P 10P 2P 4P') + s = vsize('P2n15Pl4Pn9Pn11PIP') + struct.calcsize('34P 3P 10P 2P 4P') # Separate block for PyDictKeysObject with 4 entries s += struct.calcsize("2nPn") + 4*struct.calcsize("n2P") # class diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_tarfile.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,7 @@ import sys import os import io +import shutil from hashlib import md5 import unittest @@ -455,16 +456,16 @@ # Test hardlink extraction (e.g. bug #857297). with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar: tar.extract("ustar/regtype", TEMPDIR) - self.addCleanup(support.unlink, os.path.join(TEMPDIR, "ustar/regtype")) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/regtype")) tar.extract("ustar/lnktype", TEMPDIR) - self.addCleanup(support.unlink, os.path.join(TEMPDIR, "ustar/lnktype")) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/lnktype")) with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f: data = f.read() self.assertEqual(md5sum(data), md5_regtype) tar.extract("ustar/symtype", TEMPDIR) - self.addCleanup(support.unlink, os.path.join(TEMPDIR, "ustar/symtype")) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/symtype")) with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f: data = f.read() self.assertEqual(md5sum(data), md5_regtype) @@ -497,7 +498,7 @@ self.assertEqual(tarinfo.mtime, file_mtime, errmsg) finally: tar.close() - support.rmtree(DIR) + shutil.rmtree(DIR) def test_extract_directory(self): dirtype = "ustar/dirtype" @@ -512,7 +513,7 @@ if sys.platform != "win32": self.assertEqual(os.stat(extracted).st_mode & 0o777, 0o755) finally: - support.rmtree(DIR) + shutil.rmtree(DIR) def test_init_close_fobj(self): # Issue #7341: Close the internal file object in the TarFile @@ -876,7 +877,7 @@ fobj.seek(4096) fobj.truncate() s = os.stat(name) - support.unlink(name) + os.remove(name) return s.st_blocks == 0 else: return False @@ -1009,7 +1010,7 @@ finally: tar.close() finally: - support.rmdir(path) + os.rmdir(path) @unittest.skipUnless(hasattr(os, "link"), "Missing hardlink implementation") @@ -1029,8 +1030,8 @@ finally: tar.close() finally: - support.unlink(target) - support.unlink(link) + os.remove(target) + os.remove(link) @support.skip_unless_symlink def test_symlink_size(self): @@ -1044,7 +1045,7 @@ finally: tar.close() finally: - support.unlink(path) + os.remove(path) def test_add_self(self): # Test for #1257255. @@ -1091,7 +1092,7 @@ finally: tar.close() finally: - support.rmtree(tempdir) + shutil.rmtree(tempdir) def test_filter(self): tempdir = os.path.join(TEMPDIR, "filter") @@ -1127,7 +1128,7 @@ finally: tar.close() finally: - support.rmtree(tempdir) + shutil.rmtree(tempdir) # Guarantee that stored pathnames are not modified. Don't # remove ./ or ../ or double slashes. Still make absolute @@ -1155,9 +1156,9 @@ tar.close() if not dir: - support.unlink(foo) + os.remove(foo) else: - support.rmdir(foo) + os.rmdir(foo) self.assertEqual(t.name, cmp_path or path.replace(os.sep, "/")) @@ -1188,8 +1189,8 @@ finally: tar.close() finally: - support.unlink(temparchive) - support.rmtree(tempdir) + os.unlink(temparchive) + shutil.rmtree(tempdir) def test_pathnames(self): self._test_pathname("foo") @@ -1289,7 +1290,7 @@ # Test for issue #8464: Create files with correct # permissions. if os.path.exists(tmpname): - support.unlink(tmpname) + os.remove(tmpname) original_umask = os.umask(0o022) try: @@ -1643,7 +1644,7 @@ def setUp(self): self.tarname = tmpname if os.path.exists(self.tarname): - support.unlink(self.tarname) + os.remove(self.tarname) def _create_testtar(self, mode="w:"): with tarfile.open(tarname, encoding="iso8859-1") as src: @@ -2150,7 +2151,7 @@ def tearDownModule(): if os.path.exists(TEMPDIR): - support.rmtree(TEMPDIR) + shutil.rmtree(TEMPDIR) if __name__ == "__main__": unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_tempfile.py Sun Mar 23 09:44:28 2014 +0100 @@ -760,7 +760,7 @@ self.assertRaises(ValueError, use_closed) def test_no_leak_fd(self): - # Issue #21058: don't leak file descriptor when io.open() fails + # Issue #21058: don't leak file descriptor when io.pen() fails closed = [] def close(fd): closed.append(fd) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_tk.py --- a/Lib/test/test_tk.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_tk.py Sun Mar 23 09:44:28 2014 +0100 @@ -6,7 +6,8 @@ support.import_fresh_module('tkinter') # Skip test if tk cannot be initialized. -support.requires('gui') +from tkinter.test.support import check_tk_availability +check_tk_availability() from tkinter.test import runtktests diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_tokenize.py --- a/Lib/test/test_tokenize.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_tokenize.py Sun Mar 23 09:44:28 2014 +0100 @@ -464,7 +464,7 @@ Multiplicative - >>> dump_tokens("x = 1//1*1/5*12%0x12@42") + >>> dump_tokens("x = 1//1*1/5*12%0x12") ENCODING 'utf-8' (0, 0) (0, 0) NAME 'x' (1, 0) (1, 1) OP '=' (1, 2) (1, 3) @@ -479,8 +479,6 @@ NUMBER '12' (1, 13) (1, 15) OP '%' (1, 15) (1, 16) NUMBER '0x12' (1, 16) (1, 20) - OP '@' (1, 20) (1, 21) - NUMBER '42' (1, 21) (1, 23) Unary @@ -1156,7 +1154,6 @@ self.assertExactTypeEqual('//', token.DOUBLESLASH) self.assertExactTypeEqual('//=', token.DOUBLESLASHEQUAL) self.assertExactTypeEqual('@', token.AT) - self.assertExactTypeEqual('@=', token.ATEQUAL) self.assertExactTypeEqual('a**2+b**2==c**2', NAME, token.DOUBLESTAR, NUMBER, diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_ttk_guionly.py --- a/Lib/test/test_ttk_guionly.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_ttk_guionly.py Sun Mar 23 09:44:28 2014 +0100 @@ -9,7 +9,8 @@ support.import_fresh_module('tkinter') # Skip test if tk cannot be initialized. -support.requires('gui') +from tkinter.test.support import check_tk_availability +check_tk_availability() from _tkinter import TclError from tkinter import ttk diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_tuple.py --- a/Lib/test/test_tuple.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_tuple.py Sun Mar 23 09:44:28 2014 +0100 @@ -201,14 +201,6 @@ with self.assertRaises(TypeError): [3,] + T((1,2)) - def test_lexicographic_ordering(self): - # Issue 21100 - a = self.type2test([1, 2]) - b = self.type2test([1, 2, 0]) - c = self.type2test([1, 3]) - self.assertLess(a, b) - self.assertLess(b, c) - def test_main(): support.run_unittest(TupleTest) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_types.py --- a/Lib/test/test_types.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_types.py Sun Mar 23 09:44:28 2014 +0100 @@ -343,8 +343,6 @@ self.assertRaises(ValueError, 3 .__format__, ",n") # can't have ',' with 'c' self.assertRaises(ValueError, 3 .__format__, ",c") - # can't have '#' with 'c' - self.assertRaises(ValueError, 3 .__format__, "#c") # ensure that only int and float type specifiers work for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_unicode.py Sun Mar 23 09:44:28 2014 +0100 @@ -251,7 +251,6 @@ {ord('a'): None, ord('b'): ''}) self.checkequalnofix('xyyx', 'xzx', 'translate', {ord('z'): 'yy'}) - # this needs maketrans() self.checkequalnofix('abababc', 'abababc', 'translate', {'b': ''}) @@ -261,33 +260,6 @@ tbl = self.type2test.maketrans('abc', 'xyz', 'd') self.checkequalnofix('xyzzy', 'abdcdcbdddd', 'translate', tbl) - # various tests switching from ASCII to latin1 or the opposite; - # same length, remove a letter, or replace with a longer string. - self.assertEqual("[a]".translate(str.maketrans('a', 'X')), - "[X]") - self.assertEqual("[a]".translate(str.maketrans({'a': 'X'})), - "[X]") - self.assertEqual("[a]".translate(str.maketrans({'a': None})), - "[]") - self.assertEqual("[a]".translate(str.maketrans({'a': 'XXX'})), - "[XXX]") - self.assertEqual("[a]".translate(str.maketrans({'a': '\xe9'})), - "[\xe9]") - self.assertEqual("[a]".translate(str.maketrans({'a': '<\xe9>'})), - "[<\xe9>]") - self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': 'a'})), - "[a]") - self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': None})), - "[]") - - # invalid Unicode characters - invalid_char = 0x10ffff+1 - for before in "a\xe9\u20ac\U0010ffff": - mapping = str.maketrans({before: invalid_char}) - text = "[%s]" % before - self.assertRaises(ValueError, text.translate, mapping) - - # errors self.assertRaises(TypeError, self.type2test.maketrans) self.assertRaises(ValueError, self.type2test.maketrans, 'abc', 'defg') self.assertRaises(TypeError, self.type2test.maketrans, 2, 'def') @@ -874,27 +846,6 @@ self.assertEqual('{0:10000}'.format(''), ' ' * 10000) self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000) - # issue 12546: use \x00 as a fill character - self.assertEqual('{0:\x00<6s}'.format('foo'), 'foo\x00\x00\x00') - self.assertEqual('{0:\x01<6s}'.format('foo'), 'foo\x01\x01\x01') - self.assertEqual('{0:\x00^6s}'.format('foo'), '\x00foo\x00\x00') - self.assertEqual('{0:^6s}'.format('foo'), ' foo ') - - self.assertEqual('{0:\x00<6}'.format(3), '3\x00\x00\x00\x00\x00') - self.assertEqual('{0:\x01<6}'.format(3), '3\x01\x01\x01\x01\x01') - self.assertEqual('{0:\x00^6}'.format(3), '\x00\x003\x00\x00\x00') - self.assertEqual('{0:<6}'.format(3), '3 ') - - self.assertEqual('{0:\x00<6}'.format(3.14), '3.14\x00\x00') - self.assertEqual('{0:\x01<6}'.format(3.14), '3.14\x01\x01') - self.assertEqual('{0:\x00^6}'.format(3.14), '\x003.14\x00') - self.assertEqual('{0:^6}'.format(3.14), ' 3.14 ') - - self.assertEqual('{0:\x00<12}'.format(3+2.0j), '(3+2j)\x00\x00\x00\x00\x00\x00') - self.assertEqual('{0:\x01<12}'.format(3+2.0j), '(3+2j)\x01\x01\x01\x01\x01\x01') - self.assertEqual('{0:\x00^12}'.format(3+2.0j), '\x00\x00\x00(3+2j)\x00\x00\x00') - self.assertEqual('{0:^12}'.format(3+2.0j), ' (3+2j) ') - # format specifiers for user defined type self.assertEqual('{0:abc}'.format(C()), 'abc') diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_urllib2.py Sun Mar 23 09:44:28 2014 +0100 @@ -6,11 +6,15 @@ import socket import array import sys +try: + import ssl +except ImportError: + ssl = None import urllib.request # The proxy bypass method imported below has logic specific to the OSX # proxy config data structure but is testable on all platforms. -from urllib.request import Request, OpenerDirector, _parse_proxy, _proxy_bypass_macosx_sysconf +from urllib.request import Request, OpenerDirector, _proxy_bypass_macosx_sysconf from urllib.parse import urlparse import urllib.error @@ -1438,9 +1442,11 @@ @unittest.skipUnless(support.is_resource_enabled('network'), 'test requires network access') + @unittest.skipIf(ssl is None, + 'test requires the ssl module') def test_issue16464(self): opener = urllib.request.build_opener() - request = urllib.request.Request("http://www.example.com/") + request = urllib.request.Request("http://www.python.org/~jeremy/") self.assertEqual(None, request.data) opener.open(request, "1".encode("us-ascii")) @@ -1467,43 +1473,6 @@ expected_errmsg = 'HTTP Error %s: %s' % (err.code, err.msg) self.assertEqual(str(err), expected_errmsg) - def test_parse_proxy(self): - parse_proxy_test_cases = [ - ('proxy.example.com', - (None, None, None, 'proxy.example.com')), - ('proxy.example.com:3128', - (None, None, None, 'proxy.example.com:3128')), - ('proxy.example.com', (None, None, None, 'proxy.example.com')), - ('proxy.example.com:3128', - (None, None, None, 'proxy.example.com:3128')), - # The authority component may optionally include userinfo - # (assumed to be # username:password): - ('joe:password@proxy.example.com', - (None, 'joe', 'password', 'proxy.example.com')), - ('joe:password@proxy.example.com:3128', - (None, 'joe', 'password', 'proxy.example.com:3128')), - #Examples with URLS - ('http://proxy.example.com/', - ('http', None, None, 'proxy.example.com')), - ('http://proxy.example.com:3128/', - ('http', None, None, 'proxy.example.com:3128')), - ('http://joe:password@proxy.example.com/', - ('http', 'joe', 'password', 'proxy.example.com')), - ('http://joe:password@proxy.example.com:3128', - ('http', 'joe', 'password', 'proxy.example.com:3128')), - # Everything after the authority is ignored - ('ftp://joe:password@proxy.example.com/rubbish:3128', - ('ftp', 'joe', 'password', 'proxy.example.com')), - # Test for no trailing '/' case - ('http://joe:password@proxy.example.com', - ('http', 'joe', 'password', 'proxy.example.com')) - ] - - for tc, expected in parse_proxy_test_cases: - self.assertEqual(_parse_proxy(tc), expected) - - self.assertRaises(ValueError, _parse_proxy, 'file:/ftp.example.com'), - class RequestTests(unittest.TestCase): class PutRequest(Request): method='PUT' diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_urllib2_localnet.py Sun Mar 23 09:44:28 2014 +0100 @@ -5,11 +5,8 @@ import http.server import unittest import hashlib - from test import support - threading = support.import_module('threading') - try: import ssl except ImportError: @@ -60,11 +57,14 @@ request_handler.protocol_version = "HTTP/1.0" self.httpd = LoopbackHttpServer(("127.0.0.1", 0), request_handler) + #print "Serving HTTP on %s port %s" % (self.httpd.server_name, + # self.httpd.server_port) self.port = self.httpd.server_port def stop(self): """Stops the webserver if it's currently running.""" + # Set the stop flag. self._stop_server = True self.join() @@ -232,7 +232,6 @@ # Test cases -@unittest.skipUnless(threading, "Threading required for this test.") class ProxyAuthTests(unittest.TestCase): URL = "http://localhost" @@ -344,7 +343,6 @@ return FakeHTTPRequestHandler -@unittest.skipUnless(threading, "Threading required for this test.") class TestUrlopen(unittest.TestCase): """Tests urllib.request.urlopen using the network. @@ -592,17 +590,9 @@ self.assertEqual(index + 1, len(lines)) -threads_key = None - -def setUpModule(): - # Store the threading_setup in a key and ensure that it is cleaned up - # in the tearDown - global threads_key - threads_key = support.threading_setup() - -def tearDownModule(): - if threads_key: - support.threading_cleanup(threads_key) +@support.reap_threads +def test_main(): + support.run_unittest(ProxyAuthTests, TestUrlopen) if __name__ == "__main__": - unittest.main() + test_main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_urllib2net.py --- a/Lib/test/test_urllib2net.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_urllib2net.py Sun Mar 23 09:44:28 2014 +0100 @@ -83,7 +83,7 @@ def test_close(self): # calling .close() on urllib2's response objects should close the # underlying socket - url = "http://www.example.com/" + url = "http://www.python.org/" with support.transient_internet(url): response = _urlopen_with_retry(url) sock = response.fp @@ -157,20 +157,20 @@ ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def test_urlwithfrag(self): - urlwith_frag = "https://docs.python.org/2/glossary.html#glossary" + urlwith_frag = "http://docs.python.org/2/glossary.html#glossary" with support.transient_internet(urlwith_frag): req = urllib.request.Request(urlwith_frag) res = urllib.request.urlopen(req) self.assertEqual(res.geturl(), - "https://docs.python.org/2/glossary.html#glossary") + "http://docs.python.org/2/glossary.html#glossary") def test_redirect_url_withfrag(self): - redirect_url_with_frag = "http://bit.ly/1iSHToT" + redirect_url_with_frag = "http://bitly.com/urllibredirecttest" with support.transient_internet(redirect_url_with_frag): req = urllib.request.Request(redirect_url_with_frag) res = urllib.request.urlopen(req) self.assertEqual(res.geturl(), - "https://docs.python.org/3.4/glossary.html#term-global-interpreter-lock") + "http://docs.python.org/3.4/glossary.html#term-global-interpreter-lock") def test_custom_headers(self): url = "http://www.example.com" @@ -263,7 +263,7 @@ class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + url = "http://www.python.org" with support.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) self.addCleanup(u.close) @@ -271,7 +271,7 @@ def test_http_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + url = "http://www.python.org" with support.transient_internet(url): socket.setdefaulttimeout(60) try: @@ -283,7 +283,7 @@ def test_http_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + url = "http://www.python.org" with support.transient_internet(url): socket.setdefaulttimeout(60) try: @@ -294,7 +294,7 @@ self.assertIsNone(u.fp.raw._sock.gettimeout()) def test_http_timeout(self): - url = "http://www.example.com" + url = "http://www.python.org" with support.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.addCleanup(u.close) diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_urllib_response.py --- a/Lib/test/test_urllib_response.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_urllib_response.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,59 +1,42 @@ """Unit tests for code in urllib.response.""" -import socket -import tempfile +import test.support import urllib.response import unittest -class TestResponse(unittest.TestCase): +class TestFile(object): + + def __init__(self): + self.closed = False + + def read(self, bytes): + pass + + def readline(self): + pass + + def close(self): + self.closed = True + +class Testaddbase(unittest.TestCase): + + # TODO(jhylton): Write tests for other functionality of addbase() def setUp(self): - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.fp = self.sock.makefile('rb') - self.test_headers = {"Host": "www.python.org", - "Connection": "close"} + self.fp = TestFile() + self.addbase = urllib.response.addbase(self.fp) def test_with(self): - addbase = urllib.response.addbase(self.fp) - - self.assertIsInstance(addbase, tempfile._TemporaryFileWrapper) - def f(): - with addbase as spam: + with self.addbase as spam: pass self.assertFalse(self.fp.closed) f() self.assertTrue(self.fp.closed) self.assertRaises(ValueError, f) - def test_addclosehook(self): - closehook_called = False - - def closehook(): - nonlocal closehook_called - closehook_called = True - - closehook = urllib.response.addclosehook(self.fp, closehook) - closehook.close() - - self.assertTrue(self.fp.closed) - self.assertTrue(closehook_called) - - def test_addinfo(self): - info = urllib.response.addinfo(self.fp, self.test_headers) - self.assertEqual(info.info(), self.test_headers) - - def test_addinfourl(self): - url = "http://www.python.org" - code = 200 - infourl = urllib.response.addinfourl(self.fp, self.test_headers, - url, code) - self.assertEqual(infourl.info(), self.test_headers) - self.assertEqual(infourl.geturl(), url) - self.assertEqual(infourl.getcode(), code) - - def tearDown(self): - self.sock.close() +def test_main(): + test.support.run_unittest(Testaddbase) if __name__ == '__main__': - unittest.main() + test_main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_urllibnet.py Sun Mar 23 09:44:28 2014 +0100 @@ -10,8 +10,6 @@ import time -support.requires('network') - class URLTimeoutTest(unittest.TestCase): # XXX this test doesn't seem to test anything useful. @@ -24,8 +22,8 @@ socket.setdefaulttimeout(None) def testURLread(self): - with support.transient_internet("www.example.com"): - f = urllib.request.urlopen("http://www.example.com/") + with support.transient_internet("www.python.org"): + f = urllib.request.urlopen("http://www.python.org/") x = f.read() @@ -38,7 +36,7 @@ for transparent redirection have been written. setUp is not used for always constructing a connection to - http://www.example.com/ since there a few tests that don't use that address + http://www.python.org/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. @@ -56,7 +54,7 @@ def test_basic(self): # Simple test expected to pass. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen("http://www.python.org/") as open_url: for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " @@ -65,7 +63,7 @@ def test_readlines(self): # Test both readline and readlines. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen("http://www.python.org/") as open_url: self.assertIsInstance(open_url.readline(), bytes, "readline did not return a string") self.assertIsInstance(open_url.readlines(), list, @@ -73,7 +71,7 @@ def test_info(self): # Test 'info'. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen("http://www.python.org/") as open_url: info_obj = open_url.info() self.assertIsInstance(info_obj, email.message.Message, "object returned by 'info' is not an " @@ -82,14 +80,14 @@ def test_geturl(self): # Make sure same URL as opened is returned by geturl. - URL = "http://www.example.com/" + URL = "https://www.python.org/" with self.urlopen(URL) as open_url: gotten_url = open_url.geturl() self.assertEqual(gotten_url, URL) def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.example.com/XXXinvalidXXX" + URL = "http://www.python.org/XXXinvalidXXX" with support.transient_internet(URL): open_url = urllib.request.FancyURLopener().open(URL) try: @@ -103,7 +101,7 @@ @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows') def test_fileno(self): # Make sure fd returned by fileno is valid. - with self.urlopen("http://www.google.com/", timeout=None) as open_url: + with self.urlopen("http://www.python.org/", timeout=None) as open_url: fd = open_url.fileno() with os.fdopen(fd, 'rb') as f: self.assertTrue(f.read(), "reading from file created using fd " @@ -149,7 +147,7 @@ def test_basic(self): # Test basic functionality. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve("http://www.python.org/") as (file_location, info): self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") with open(file_location, 'rb') as f: @@ -158,7 +156,7 @@ def test_specified_path(self): # Make sure that specifying the location of the file to write to works. - with self.urlretrieve("http://www.example.com/", + with self.urlretrieve("http://www.python.org/", support.TESTFN) as (file_location, info): self.assertEqual(file_location, support.TESTFN) self.assertTrue(os.path.exists(file_location)) @@ -167,11 +165,11 @@ def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve("http://www.python.org/") as (file_location, info): self.assertIsInstance(info, email.message.Message, "info is not an instance of email.message.Message") - logo = "http://www.example.com/" + logo = "http://www.python.org/static/community_logos/python-logo-master-v3-TM.png" def test_data_header(self): with self.urlretrieve(self.logo) as (file_location, fileheaders): @@ -208,5 +206,11 @@ " >= total size in %s" % records_repr) +def test_main(): + support.requires('network') + support.run_unittest(URLTimeoutTest, + urlopenNetworkTests, + urlretrieveNetworkTests) + if __name__ == "__main__": - unittest.main() + test_main() diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_venv.py --- a/Lib/test/test_venv.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_venv.py Sun Mar 23 09:44:28 2014 +0100 @@ -9,7 +9,6 @@ import os import os.path import shutil -import struct import subprocess import sys import tempfile @@ -88,14 +87,6 @@ self.isdir(self.bindir) self.isdir(self.include) self.isdir(*self.lib) - # Issue 21197 - p = self.get_env_file('lib64') - conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and - (sys.platform != 'darwin')) - if conditions: - self.assertTrue(os.path.islink(p)) - else: - self.assertFalse(os.path.exists(p)) data = self.get_text_file_contents('pyvenv.cfg') if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__' in os.environ): diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_warnings.py Sun Mar 23 09:44:28 2014 +0100 @@ -5,7 +5,7 @@ import sys import unittest from test import support -from test.script_helper import assert_python_ok, assert_python_failure +from test.script_helper import assert_python_ok from test import warning_tests @@ -748,19 +748,7 @@ "import sys; sys.stdout.write(str(sys.warnoptions))", PYTHONWARNINGS="ignore::DeprecationWarning") self.assertEqual(stdout, - b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']") - - def test_conflicting_envvar_and_command_line(self): - rc, stdout, stderr = assert_python_failure("-Werror::DeprecationWarning", "-c", - "import sys, warnings; sys.stdout.write(str(sys.warnoptions)); " - "warnings.warn('Message', DeprecationWarning)", - PYTHONWARNINGS="default::DeprecationWarning") - self.assertEqual(stdout, - b"['default::DeprecationWarning', 'error::DeprecationWarning']") - self.assertEqual(stderr.splitlines(), - [b"Traceback (most recent call last):", - b" File \"\", line 1, in ", - b"DeprecationWarning: Message"]) + b"['ignore::UnicodeWarning', 'ignore::DeprecationWarning']") @unittest.skipUnless(sys.getfilesystemencoding() != 'ascii', 'requires non-ascii filesystemencoding') diff -r ce070040e1a6 -r d7f128afe9db Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/test/test_zipfile.py Sun Mar 23 09:44:28 2014 +0100 @@ -3,6 +3,7 @@ import sys import importlib.util import time +import shutil import struct import zipfile import unittest @@ -11,7 +12,7 @@ from tempfile import TemporaryFile from random import randint, random, getrandbits -from test.support import (TESTFN, findfile, unlink, rmtree, +from test.support import (TESTFN, findfile, unlink, requires_zlib, requires_bz2, requires_lzma, captured_stdout, check_warnings) @@ -690,7 +691,7 @@ self.assertNotIn('mod2.txt', names) finally: - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) def test_write_python_directory_filtered(self): os.mkdir(TESTFN2) @@ -710,7 +711,7 @@ self.assertNotIn('mod2.py', names) finally: - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) def test_write_non_pyfile(self): with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: @@ -740,7 +741,7 @@ self.assertNotIn('mod1.pyo', names) finally: - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) class ExtractTests(unittest.TestCase): @@ -766,7 +767,7 @@ os.remove(writtenfile) # remove the test file subdirectories - rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) def test_extract_all(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: @@ -784,7 +785,7 @@ os.remove(outfile) # remove the test file subdirectories - rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) def check_file(self, filename, content): self.assertTrue(os.path.isfile(filename)) @@ -866,12 +867,12 @@ msg='extract %r: %r != %r' % (arcname, writtenfile, correctfile)) self.check_file(correctfile, content) - rmtree('target') + shutil.rmtree('target') with zipfile.ZipFile(TESTFN2, 'r') as zipfp: zipfp.extractall(targetpath) self.check_file(correctfile, content) - rmtree('target') + shutil.rmtree('target') correctfile = os.path.join(os.getcwd(), *fixedname.split('/')) @@ -880,12 +881,12 @@ self.assertEqual(writtenfile, correctfile, msg="extract %r" % arcname) self.check_file(correctfile, content) - rmtree(fixedname.split('/')[0]) + shutil.rmtree(fixedname.split('/')[0]) with zipfile.ZipFile(TESTFN2, 'r') as zipfp: zipfp.extractall() self.check_file(correctfile, content) - rmtree(fixedname.split('/')[0]) + shutil.rmtree(fixedname.split('/')[0]) os.remove(TESTFN2) @@ -1627,7 +1628,7 @@ self.assertTrue(zipf.filelist[0].filename.endswith("x/")) def tearDown(self): - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) if os.path.exists(TESTFN): unlink(TESTFN) diff -r ce070040e1a6 -r d7f128afe9db Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/tkinter/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -1280,11 +1280,6 @@ def __str__(self): """Return the window path name of this widget.""" return self._w - - def __repr__(self): - return '<%s.%s object %s>' % ( - self.__class__.__module__, self.__class__.__qualname__, self._w) - # Pack methods that apply to the master _noarg_ = ['_noarg_'] def pack_propagate(self, flag=_noarg_): diff -r ce070040e1a6 -r d7f128afe9db Lib/tkinter/test/support.py --- a/Lib/tkinter/test/support.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/tkinter/test/support.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,10 +1,52 @@ import sys import tkinter import unittest -from test.support import requires + +_tk_unavailable = None + +def check_tk_availability(): + """Check that Tk is installed and available.""" + global _tk_unavailable + + if _tk_unavailable is None: + _tk_unavailable = False + if sys.platform == 'darwin': + # The Aqua Tk implementations on OS X can abort the process if + # being called in an environment where a window server connection + # cannot be made, for instance when invoked by a buildbot or ssh + # process not running under the same user id as the current console + # user. To avoid that, raise an exception if the window manager + # connection is not available. + from ctypes import cdll, c_int, pointer, Structure + from ctypes.util import find_library + + app_services = cdll.LoadLibrary(find_library("ApplicationServices")) + + if app_services.CGMainDisplayID() == 0: + _tk_unavailable = "cannot run without OS X window manager" + else: + class ProcessSerialNumber(Structure): + _fields_ = [("highLongOfPSN", c_int), + ("lowLongOfPSN", c_int)] + psn = ProcessSerialNumber() + psn_p = pointer(psn) + if ( (app_services.GetCurrentProcess(psn_p) < 0) or + (app_services.SetFrontProcess(psn_p) < 0) ): + _tk_unavailable = "cannot run without OS X gui process" + else: # not OS X + import tkinter + try: + tkinter.Button() + except tkinter.TclError as msg: + # assuming tk is not available + _tk_unavailable = "tk not available: %s" % msg + + if _tk_unavailable: + raise unittest.SkipTest(_tk_unavailable) + return def get_tk_root(): - requires('gui') # raise exception if tk unavailable + check_tk_availability() # raise exception if tk unavailable try: root = tkinter._default_root except AttributeError: diff -r ce070040e1a6 -r d7f128afe9db Lib/tkinter/test/test_tkinter/test_geometry_managers.py --- a/Lib/tkinter/test/test_tkinter/test_geometry_managers.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,902 +0,0 @@ -import unittest -import re -import tkinter -from tkinter import TclError -from test.support import requires - -from tkinter.test.support import pixels_conv, tcl_version, requires_tcl -from tkinter.test.widget_tests import AbstractWidgetTest - -requires('gui') - - -class PackTest(AbstractWidgetTest, unittest.TestCase): - - def create2(self): - pack = tkinter.Toplevel(self.root, name='pack') - pack.wm_geometry('300x200+0+0') - pack.wm_minsize(1, 1) - a = tkinter.Frame(pack, name='a', width=20, height=40, bg='red') - b = tkinter.Frame(pack, name='b', width=50, height=30, bg='blue') - c = tkinter.Frame(pack, name='c', width=80, height=80, bg='green') - d = tkinter.Frame(pack, name='d', width=40, height=30, bg='yellow') - return pack, a, b, c, d - - def test_pack_configure_after(self): - pack, a, b, c, d = self.create2() - with self.assertRaisesRegex(TclError, 'window "%s" isn\'t packed' % b): - a.pack_configure(after=b) - with self.assertRaisesRegex(TclError, 'bad window path name ".foo"'): - a.pack_configure(after='.foo') - a.pack_configure(side='top') - b.pack_configure(side='top') - c.pack_configure(side='top') - d.pack_configure(side='top') - self.assertEqual(pack.pack_slaves(), [a, b, c, d]) - a.pack_configure(after=b) - self.assertEqual(pack.pack_slaves(), [b, a, c, d]) - a.pack_configure(after=a) - self.assertEqual(pack.pack_slaves(), [b, a, c, d]) - - def test_pack_configure_anchor(self): - pack, a, b, c, d = self.create2() - def check(anchor, geom): - a.pack_configure(side='top', ipadx=5, padx=10, ipady=15, pady=20, - expand=True, anchor=anchor) - self.root.update() - self.assertEqual(a.winfo_geometry(), geom) - check('n', '30x70+135+20') - check('ne', '30x70+260+20') - check('e', '30x70+260+65') - check('se', '30x70+260+110') - check('s', '30x70+135+110') - check('sw', '30x70+10+110') - check('w', '30x70+10+65') - check('nw', '30x70+10+20') - check('center', '30x70+135+65') - - def test_pack_configure_before(self): - pack, a, b, c, d = self.create2() - with self.assertRaisesRegex(TclError, 'window "%s" isn\'t packed' % b): - a.pack_configure(before=b) - with self.assertRaisesRegex(TclError, 'bad window path name ".foo"'): - a.pack_configure(before='.foo') - a.pack_configure(side='top') - b.pack_configure(side='top') - c.pack_configure(side='top') - d.pack_configure(side='top') - self.assertEqual(pack.pack_slaves(), [a, b, c, d]) - a.pack_configure(before=d) - self.assertEqual(pack.pack_slaves(), [b, c, a, d]) - a.pack_configure(before=a) - self.assertEqual(pack.pack_slaves(), [b, c, a, d]) - - def test_pack_configure_expand(self): - pack, a, b, c, d = self.create2() - def check(*geoms): - self.root.update() - self.assertEqual(a.winfo_geometry(), geoms[0]) - self.assertEqual(b.winfo_geometry(), geoms[1]) - self.assertEqual(c.winfo_geometry(), geoms[2]) - self.assertEqual(d.winfo_geometry(), geoms[3]) - a.pack_configure(side='left') - b.pack_configure(side='top') - c.pack_configure(side='right') - d.pack_configure(side='bottom') - check('20x40+0+80', '50x30+135+0', '80x80+220+75', '40x30+100+170') - a.pack_configure(side='left', expand='yes') - b.pack_configure(side='top', expand='on') - c.pack_configure(side='right', expand=True) - d.pack_configure(side='bottom', expand=1) - check('20x40+40+80', '50x30+175+35', '80x80+180+110', '40x30+100+135') - a.pack_configure(side='left', expand='yes', fill='both') - b.pack_configure(side='top', expand='on', fill='both') - c.pack_configure(side='right', expand=True, fill='both') - d.pack_configure(side='bottom', expand=1, fill='both') - check('100x200+0+0', '200x100+100+0', '160x100+140+100', '40x100+100+100') - - def test_pack_configure_in(self): - pack, a, b, c, d = self.create2() - a.pack_configure(side='top') - b.pack_configure(side='top') - c.pack_configure(side='top') - d.pack_configure(side='top') - a.pack_configure(in_=pack) - self.assertEqual(pack.pack_slaves(), [b, c, d, a]) - a.pack_configure(in_=c) - self.assertEqual(pack.pack_slaves(), [b, c, d]) - self.assertEqual(c.pack_slaves(), [a]) - with self.assertRaisesRegex(TclError, - 'can\'t pack %s inside itself' % (a,)): - a.pack_configure(in_=a) - with self.assertRaisesRegex(TclError, 'bad window path name ".foo"'): - a.pack_configure(in_='.foo') - - def test_pack_configure_padx_ipadx_fill(self): - pack, a, b, c, d = self.create2() - def check(geom1, geom2, **kwargs): - a.pack_forget() - b.pack_forget() - a.pack_configure(**kwargs) - b.pack_configure(expand=True, fill='both') - self.root.update() - self.assertEqual(a.winfo_geometry(), geom1) - self.assertEqual(b.winfo_geometry(), geom2) - check('20x40+260+80', '240x200+0+0', side='right', padx=20) - check('20x40+250+80', '240x200+0+0', side='right', padx=(10, 30)) - check('60x40+240+80', '240x200+0+0', side='right', ipadx=20) - check('30x40+260+80', '250x200+0+0', side='right', ipadx=5, padx=10) - check('20x40+260+80', '240x200+0+0', side='right', padx=20, fill='x') - check('20x40+249+80', '240x200+0+0', - side='right', padx=(9, 31), fill='x') - check('60x40+240+80', '240x200+0+0', side='right', ipadx=20, fill='x') - check('30x40+260+80', '250x200+0+0', - side='right', ipadx=5, padx=10, fill='x') - check('30x40+255+80', '250x200+0+0', - side='right', ipadx=5, padx=(5, 15), fill='x') - check('20x40+140+0', '300x160+0+40', side='top', padx=20) - check('20x40+120+0', '300x160+0+40', side='top', padx=(0, 40)) - check('60x40+120+0', '300x160+0+40', side='top', ipadx=20) - check('30x40+135+0', '300x160+0+40', side='top', ipadx=5, padx=10) - check('30x40+130+0', '300x160+0+40', side='top', ipadx=5, padx=(5, 15)) - check('260x40+20+0', '300x160+0+40', side='top', padx=20, fill='x') - check('260x40+25+0', '300x160+0+40', - side='top', padx=(25, 15), fill='x') - check('300x40+0+0', '300x160+0+40', side='top', ipadx=20, fill='x') - check('280x40+10+0', '300x160+0+40', - side='top', ipadx=5, padx=10, fill='x') - check('280x40+5+0', '300x160+0+40', - side='top', ipadx=5, padx=(5, 15), fill='x') - a.pack_configure(padx='1c') - self.assertEqual(a.pack_info()['padx'], - self._str(pack.winfo_pixels('1c'))) - a.pack_configure(ipadx='1c') - self.assertEqual(a.pack_info()['ipadx'], - self._str(pack.winfo_pixels('1c'))) - - def test_pack_configure_pady_ipady_fill(self): - pack, a, b, c, d = self.create2() - def check(geom1, geom2, **kwargs): - a.pack_forget() - b.pack_forget() - a.pack_configure(**kwargs) - b.pack_configure(expand=True, fill='both') - self.root.update() - self.assertEqual(a.winfo_geometry(), geom1) - self.assertEqual(b.winfo_geometry(), geom2) - check('20x40+280+80', '280x200+0+0', side='right', pady=20) - check('20x40+280+70', '280x200+0+0', side='right', pady=(10, 30)) - check('20x80+280+60', '280x200+0+0', side='right', ipady=20) - check('20x50+280+75', '280x200+0+0', side='right', ipady=5, pady=10) - check('20x40+280+80', '280x200+0+0', side='right', pady=20, fill='x') - check('20x40+280+69', '280x200+0+0', - side='right', pady=(9, 31), fill='x') - check('20x80+280+60', '280x200+0+0', side='right', ipady=20, fill='x') - check('20x50+280+75', '280x200+0+0', - side='right', ipady=5, pady=10, fill='x') - check('20x50+280+70', '280x200+0+0', - side='right', ipady=5, pady=(5, 15), fill='x') - check('20x40+140+20', '300x120+0+80', side='top', pady=20) - check('20x40+140+0', '300x120+0+80', side='top', pady=(0, 40)) - check('20x80+140+0', '300x120+0+80', side='top', ipady=20) - check('20x50+140+10', '300x130+0+70', side='top', ipady=5, pady=10) - check('20x50+140+5', '300x130+0+70', side='top', ipady=5, pady=(5, 15)) - check('300x40+0+20', '300x120+0+80', side='top', pady=20, fill='x') - check('300x40+0+25', '300x120+0+80', - side='top', pady=(25, 15), fill='x') - check('300x80+0+0', '300x120+0+80', side='top', ipady=20, fill='x') - check('300x50+0+10', '300x130+0+70', - side='top', ipady=5, pady=10, fill='x') - check('300x50+0+5', '300x130+0+70', - side='top', ipady=5, pady=(5, 15), fill='x') - a.pack_configure(pady='1c') - self.assertEqual(a.pack_info()['pady'], - self._str(pack.winfo_pixels('1c'))) - a.pack_configure(ipady='1c') - self.assertEqual(a.pack_info()['ipady'], - self._str(pack.winfo_pixels('1c'))) - - def test_pack_configure_side(self): - pack, a, b, c, d = self.create2() - def check(side, geom1, geom2): - a.pack_configure(side=side) - self.assertEqual(a.pack_info()['side'], side) - b.pack_configure(expand=True, fill='both') - self.root.update() - self.assertEqual(a.winfo_geometry(), geom1) - self.assertEqual(b.winfo_geometry(), geom2) - check('top', '20x40+140+0', '300x160+0+40') - check('bottom', '20x40+140+160', '300x160+0+0') - check('left', '20x40+0+80', '280x200+20+0') - check('right', '20x40+280+80', '280x200+0+0') - - def test_pack_forget(self): - pack, a, b, c, d = self.create2() - a.pack_configure() - b.pack_configure() - c.pack_configure() - self.assertEqual(pack.pack_slaves(), [a, b, c]) - b.pack_forget() - self.assertEqual(pack.pack_slaves(), [a, c]) - b.pack_forget() - self.assertEqual(pack.pack_slaves(), [a, c]) - d.pack_forget() - - def test_pack_info(self): - pack, a, b, c, d = self.create2() - with self.assertRaisesRegex(TclError, 'window "%s" isn\'t packed' % a): - a.pack_info() - a.pack_configure() - b.pack_configure(side='right', in_=a, anchor='s', expand=True, fill='x', - ipadx=5, padx=10, ipady=2, pady=(5, 15)) - info = a.pack_info() - self.assertIsInstance(info, dict) - self.assertEqual(info['anchor'], 'center') - self.assertEqual(info['expand'], self._str(0)) - self.assertEqual(info['fill'], 'none') - self.assertEqual(info['in'], pack) - self.assertEqual(info['ipadx'], self._str(0)) - self.assertEqual(info['ipady'], self._str(0)) - self.assertEqual(info['padx'], self._str(0)) - self.assertEqual(info['pady'], self._str(0)) - self.assertEqual(info['side'], 'top') - info = b.pack_info() - self.assertIsInstance(info, dict) - self.assertEqual(info['anchor'], 's') - self.assertEqual(info['expand'], self._str(1)) - self.assertEqual(info['fill'], 'x') - self.assertEqual(info['in'], a) - self.assertEqual(info['ipadx'], self._str(5)) - self.assertEqual(info['ipady'], self._str(2)) - self.assertEqual(info['padx'], self._str(10)) - self.assertEqual(info['pady'], self._str((5, 15))) - self.assertEqual(info['side'], 'right') - - def test_pack_propagate(self): - pack, a, b, c, d = self.create2() - pack.configure(width=300, height=200) - a.pack_configure() - pack.pack_propagate(False) - self.root.update() - self.assertEqual(pack.winfo_reqwidth(), 300) - self.assertEqual(pack.winfo_reqheight(), 200) - pack.pack_propagate(True) - self.root.update() - self.assertEqual(pack.winfo_reqwidth(), 20) - self.assertEqual(pack.winfo_reqheight(), 40) - - def test_pack_slaves(self): - pack, a, b, c, d = self.create2() - self.assertEqual(pack.pack_slaves(), []) - a.pack_configure() - self.assertEqual(pack.pack_slaves(), [a]) - b.pack_configure() - self.assertEqual(pack.pack_slaves(), [a, b]) - - -class PlaceTest(AbstractWidgetTest, unittest.TestCase): - - def create2(self): - t = tkinter.Toplevel(self.root, width=300, height=200, bd=0) - t.wm_geometry('+0+0') - f = tkinter.Frame(t, width=154, height=84, bd=2, relief='raised') - f.place_configure(x=48, y=38) - f2 = tkinter.Frame(t, width=30, height=60, bd=2, relief='raised') - self.root.update() - return t, f, f2 - - def test_place_configure_in(self): - t, f, f2 = self.create2() - self.assertEqual(f2.winfo_manager(), '') - with self.assertRaisesRegex(TclError, "can't place %s relative to " - "itself" % re.escape(str(f2))): - f2.place_configure(in_=f2) - if tcl_version >= (8, 5): - self.assertEqual(f2.winfo_manager(), '') - with self.assertRaisesRegex(TclError, 'bad window path name'): - f2.place_configure(in_='spam') - f2.place_configure(in_=f) - self.assertEqual(f2.winfo_manager(), 'place') - - def test_place_configure_x(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f) - self.assertEqual(f2.place_info()['x'], '0') - self.root.update() - self.assertEqual(f2.winfo_x(), 50) - f2.place_configure(x=100) - self.assertEqual(f2.place_info()['x'], '100') - self.root.update() - self.assertEqual(f2.winfo_x(), 150) - f2.place_configure(x=-10, relx=1) - self.assertEqual(f2.place_info()['x'], '-10') - self.root.update() - self.assertEqual(f2.winfo_x(), 190) - with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'): - f2.place_configure(in_=f, x='spam') - - def test_place_configure_y(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f) - self.assertEqual(f2.place_info()['y'], '0') - self.root.update() - self.assertEqual(f2.winfo_y(), 40) - f2.place_configure(y=50) - self.assertEqual(f2.place_info()['y'], '50') - self.root.update() - self.assertEqual(f2.winfo_y(), 90) - f2.place_configure(y=-10, rely=1) - self.assertEqual(f2.place_info()['y'], '-10') - self.root.update() - self.assertEqual(f2.winfo_y(), 110) - with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'): - f2.place_configure(in_=f, y='spam') - - def test_place_configure_relx(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f) - self.assertEqual(f2.place_info()['relx'], '0') - self.root.update() - self.assertEqual(f2.winfo_x(), 50) - f2.place_configure(relx=0.5) - self.assertEqual(f2.place_info()['relx'], '0.5') - self.root.update() - self.assertEqual(f2.winfo_x(), 125) - f2.place_configure(relx=1) - self.assertEqual(f2.place_info()['relx'], '1') - self.root.update() - self.assertEqual(f2.winfo_x(), 200) - with self.assertRaisesRegex(TclError, 'expected floating-point number ' - 'but got "spam"'): - f2.place_configure(in_=f, relx='spam') - - def test_place_configure_rely(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f) - self.assertEqual(f2.place_info()['rely'], '0') - self.root.update() - self.assertEqual(f2.winfo_y(), 40) - f2.place_configure(rely=0.5) - self.assertEqual(f2.place_info()['rely'], '0.5') - self.root.update() - self.assertEqual(f2.winfo_y(), 80) - f2.place_configure(rely=1) - self.assertEqual(f2.place_info()['rely'], '1') - self.root.update() - self.assertEqual(f2.winfo_y(), 120) - with self.assertRaisesRegex(TclError, 'expected floating-point number ' - 'but got "spam"'): - f2.place_configure(in_=f, rely='spam') - - def test_place_configure_anchor(self): - f = tkinter.Frame(self.root) - with self.assertRaisesRegex(TclError, 'bad anchor "j"'): - f.place_configure(anchor='j') - with self.assertRaisesRegex(TclError, 'ambiguous anchor ""'): - f.place_configure(anchor='') - for value in 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center': - f.place_configure(anchor=value) - self.assertEqual(f.place_info()['anchor'], value) - - def test_place_configure_width(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f, width=120) - self.root.update() - self.assertEqual(f2.winfo_width(), 120) - f2.place_configure(width='') - self.root.update() - self.assertEqual(f2.winfo_width(), 30) - with self.assertRaisesRegex(TclError, 'bad screen distance "abcd"'): - f2.place_configure(width='abcd') - - def test_place_configure_height(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f, height=120) - self.root.update() - self.assertEqual(f2.winfo_height(), 120) - f2.place_configure(height='') - self.root.update() - self.assertEqual(f2.winfo_height(), 60) - with self.assertRaisesRegex(TclError, 'bad screen distance "abcd"'): - f2.place_configure(height='abcd') - - def test_place_configure_relwidth(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f, relwidth=0.5) - self.root.update() - self.assertEqual(f2.winfo_width(), 75) - f2.place_configure(relwidth='') - self.root.update() - self.assertEqual(f2.winfo_width(), 30) - with self.assertRaisesRegex(TclError, 'expected floating-point number ' - 'but got "abcd"'): - f2.place_configure(relwidth='abcd') - - def test_place_configure_relheight(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f, relheight=0.5) - self.root.update() - self.assertEqual(f2.winfo_height(), 40) - f2.place_configure(relheight='') - self.root.update() - self.assertEqual(f2.winfo_height(), 60) - with self.assertRaisesRegex(TclError, 'expected floating-point number ' - 'but got "abcd"'): - f2.place_configure(relheight='abcd') - - def test_place_configure_bordermode(self): - f = tkinter.Frame(self.root) - with self.assertRaisesRegex(TclError, 'bad bordermode "j"'): - f.place_configure(bordermode='j') - with self.assertRaisesRegex(TclError, 'ambiguous bordermode ""'): - f.place_configure(bordermode='') - for value in 'inside', 'outside', 'ignore': - f.place_configure(bordermode=value) - self.assertEqual(f.place_info()['bordermode'], value) - - def test_place_forget(self): - foo = tkinter.Frame(self.root) - foo.place_configure(width=50, height=50) - self.root.update() - foo.place_forget() - self.root.update() - self.assertFalse(foo.winfo_ismapped()) - with self.assertRaises(TypeError): - foo.place_forget(0) - - def test_place_info(self): - t, f, f2 = self.create2() - f2.place_configure(in_=f, x=1, y=2, width=3, height=4, - relx=0.1, rely=0.2, relwidth=0.3, relheight=0.4, - anchor='se', bordermode='outside') - info = f2.place_info() - self.assertIsInstance(info, dict) - self.assertEqual(info['x'], '1') - self.assertEqual(info['y'], '2') - self.assertEqual(info['width'], '3') - self.assertEqual(info['height'], '4') - self.assertEqual(info['relx'], '0.1') - self.assertEqual(info['rely'], '0.2') - self.assertEqual(info['relwidth'], '0.3') - self.assertEqual(info['relheight'], '0.4') - self.assertEqual(info['anchor'], 'se') - self.assertEqual(info['bordermode'], 'outside') - self.assertEqual(info['x'], '1') - self.assertEqual(info['x'], '1') - with self.assertRaises(TypeError): - f2.place_info(0) - - def test_place_slaves(self): - foo = tkinter.Frame(self.root) - bar = tkinter.Frame(self.root) - self.assertEqual(foo.place_slaves(), []) - bar.place_configure(in_=foo) - self.assertEqual(foo.place_slaves(), [bar]) - with self.assertRaises(TypeError): - foo.place_slaves(0) - - -class GridTest(AbstractWidgetTest, unittest.TestCase): - - def tearDown(self): - super().tearDown() - cols, rows = self.root.grid_size() - for i in range(cols + 1): - self.root.grid_columnconfigure(i, weight=0, minsize=0, pad=0, uniform='') - for i in range(rows + 1): - self.root.grid_rowconfigure(i, weight=0, minsize=0, pad=0, uniform='') - self.root.grid_propagate(1) - if tcl_version >= (8, 5): - self.root.grid_anchor('nw') - - def test_grid_configure(self): - b = tkinter.Button(self.root) - self.addCleanup(b.destroy) - self.assertEqual(b.grid_info(), {}) - b.grid_configure() - self.assertEqual(b.grid_info()['in'], self.root) - self.assertEqual(b.grid_info()['column'], self._str(0)) - self.assertEqual(b.grid_info()['row'], self._str(0)) - b.grid_configure({'column': 1}, row=2) - self.assertEqual(b.grid_info()['column'], self._str(1)) - self.assertEqual(b.grid_info()['row'], self._str(2)) - - def test_grid_configure_column(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad column value "-1": ' - 'must be a non-negative integer'): - b.grid_configure(column=-1) - b.grid_configure(column=2) - self.assertEqual(b.grid_info()['column'], self._str(2)) - - def test_grid_configure_columnspan(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad columnspan value "0": ' - 'must be a positive integer'): - b.grid_configure(columnspan=0) - b.grid_configure(columnspan=2) - self.assertEqual(b.grid_info()['columnspan'], self._str(2)) - - def test_grid_configure_in(self): - f = tkinter.Frame(self.root) - b = tkinter.Button(self.root) - self.assertEqual(b.grid_info(), {}) - b.grid_configure() - self.assertEqual(b.grid_info()['in'], self.root) - b.grid_configure(in_=f) - self.assertEqual(b.grid_info()['in'], f) - b.grid_configure({'in': self.root}) - self.assertEqual(b.grid_info()['in'], self.root) - - def test_grid_configure_ipadx(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad ipadx value "-1": ' - 'must be positive screen distance'): - b.grid_configure(ipadx=-1) - b.grid_configure(ipadx=1) - self.assertEqual(b.grid_info()['ipadx'], self._str(1)) - b.grid_configure(ipadx='.5c') - self.assertEqual(b.grid_info()['ipadx'], - self._str(round(pixels_conv('.5c') * self.scaling))) - - def test_grid_configure_ipady(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad ipady value "-1": ' - 'must be positive screen distance'): - b.grid_configure(ipady=-1) - b.grid_configure(ipady=1) - self.assertEqual(b.grid_info()['ipady'], self._str(1)) - b.grid_configure(ipady='.5c') - self.assertEqual(b.grid_info()['ipady'], - self._str(round(pixels_conv('.5c') * self.scaling))) - - def test_grid_configure_padx(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad pad value "-1": ' - 'must be positive screen distance'): - b.grid_configure(padx=-1) - b.grid_configure(padx=1) - self.assertEqual(b.grid_info()['padx'], self._str(1)) - b.grid_configure(padx=(10, 5)) - self.assertEqual(b.grid_info()['padx'], self._str((10, 5))) - b.grid_configure(padx='.5c') - self.assertEqual(b.grid_info()['padx'], - self._str(round(pixels_conv('.5c') * self.scaling))) - - def test_grid_configure_pady(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad pad value "-1": ' - 'must be positive screen distance'): - b.grid_configure(pady=-1) - b.grid_configure(pady=1) - self.assertEqual(b.grid_info()['pady'], self._str(1)) - b.grid_configure(pady=(10, 5)) - self.assertEqual(b.grid_info()['pady'], self._str((10, 5))) - b.grid_configure(pady='.5c') - self.assertEqual(b.grid_info()['pady'], - self._str(round(pixels_conv('.5c') * self.scaling))) - - def test_grid_configure_row(self): - b = tkinter.Button(self.root) - self.addCleanup(b.destroy) - with self.assertRaisesRegex(TclError, 'bad (row|grid) value "-1": ' - 'must be a non-negative integer'): - b.grid_configure(row=-1) - b.grid_configure(row=2) - self.assertEqual(b.grid_info()['row'], self._str(2)) - - def test_grid_configure_rownspan(self): - b = tkinter.Button(self.root) - with self.assertRaisesRegex(TclError, 'bad rowspan value "0": ' - 'must be a positive integer'): - b.grid_configure(rowspan=0) - b.grid_configure(rowspan=2) - self.assertEqual(b.grid_info()['rowspan'], self._str(2)) - - def test_grid_configure_sticky(self): - f = tkinter.Frame(self.root, bg='red') - with self.assertRaisesRegex(TclError, 'bad stickyness value "glue"'): - f.grid_configure(sticky='glue') - f.grid_configure(sticky='ne') - self.assertEqual(f.grid_info()['sticky'], 'ne') - f.grid_configure(sticky='n,s,e,w') - self.assertEqual(f.grid_info()['sticky'], 'nesw') - - def test_grid_columnconfigure(self): - with self.assertRaises(TypeError): - self.root.grid_columnconfigure() - self.assertEqual(self.root.grid_columnconfigure(0), - {'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0}) - with self.assertRaisesRegex(TclError, 'bad option "-foo"'): - self.root.grid_columnconfigure(0, 'foo') - self.root.grid_columnconfigure((0, 3), weight=2) - with self.assertRaisesRegex(TclError, - 'must specify a single element on retrieval'): - self.root.grid_columnconfigure((0, 3)) - b = tkinter.Button(self.root) - b.grid_configure(column=0, row=0) - if tcl_version >= (8, 5): - self.root.grid_columnconfigure('all', weight=3) - with self.assertRaisesRegex(TclError, 'expected integer but got "all"'): - self.root.grid_columnconfigure('all') - self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3) - self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2) - self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0) - if tcl_version >= (8, 5): - self.root.grid_columnconfigure(b, weight=4) - self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4) - - def test_grid_columnconfigure_minsize(self): - with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'): - self.root.grid_columnconfigure(0, minsize='foo') - self.root.grid_columnconfigure(0, minsize=10) - self.assertEqual(self.root.grid_columnconfigure(0, 'minsize'), 10) - self.assertEqual(self.root.grid_columnconfigure(0)['minsize'], 10) - - def test_grid_columnconfigure_weight(self): - with self.assertRaisesRegex(TclError, 'expected integer but got "bad"'): - self.root.grid_columnconfigure(0, weight='bad') - with self.assertRaisesRegex(TclError, 'invalid arg "-weight": ' - 'should be non-negative'): - self.root.grid_columnconfigure(0, weight=-3) - self.root.grid_columnconfigure(0, weight=3) - self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3) - self.assertEqual(self.root.grid_columnconfigure(0)['weight'], 3) - - def test_grid_columnconfigure_pad(self): - with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'): - self.root.grid_columnconfigure(0, pad='foo') - with self.assertRaisesRegex(TclError, 'invalid arg "-pad": ' - 'should be non-negative'): - self.root.grid_columnconfigure(0, pad=-3) - self.root.grid_columnconfigure(0, pad=3) - self.assertEqual(self.root.grid_columnconfigure(0, 'pad'), 3) - self.assertEqual(self.root.grid_columnconfigure(0)['pad'], 3) - - def test_grid_columnconfigure_uniform(self): - self.root.grid_columnconfigure(0, uniform='foo') - self.assertEqual(self.root.grid_columnconfigure(0, 'uniform'), 'foo') - self.assertEqual(self.root.grid_columnconfigure(0)['uniform'], 'foo') - - def test_grid_rowconfigure(self): - with self.assertRaises(TypeError): - self.root.grid_rowconfigure() - self.assertEqual(self.root.grid_rowconfigure(0), - {'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0}) - with self.assertRaisesRegex(TclError, 'bad option "-foo"'): - self.root.grid_rowconfigure(0, 'foo') - self.root.grid_rowconfigure((0, 3), weight=2) - with self.assertRaisesRegex(TclError, - 'must specify a single element on retrieval'): - self.root.grid_rowconfigure((0, 3)) - b = tkinter.Button(self.root) - b.grid_configure(column=0, row=0) - if tcl_version >= (8, 5): - self.root.grid_rowconfigure('all', weight=3) - with self.assertRaisesRegex(TclError, 'expected integer but got "all"'): - self.root.grid_rowconfigure('all') - self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3) - self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2) - self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0) - if tcl_version >= (8, 5): - self.root.grid_rowconfigure(b, weight=4) - self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4) - - def test_grid_rowconfigure_minsize(self): - with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'): - self.root.grid_rowconfigure(0, minsize='foo') - self.root.grid_rowconfigure(0, minsize=10) - self.assertEqual(self.root.grid_rowconfigure(0, 'minsize'), 10) - self.assertEqual(self.root.grid_rowconfigure(0)['minsize'], 10) - - def test_grid_rowconfigure_weight(self): - with self.assertRaisesRegex(TclError, 'expected integer but got "bad"'): - self.root.grid_rowconfigure(0, weight='bad') - with self.assertRaisesRegex(TclError, 'invalid arg "-weight": ' - 'should be non-negative'): - self.root.grid_rowconfigure(0, weight=-3) - self.root.grid_rowconfigure(0, weight=3) - self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3) - self.assertEqual(self.root.grid_rowconfigure(0)['weight'], 3) - - def test_grid_rowconfigure_pad(self): - with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'): - self.root.grid_rowconfigure(0, pad='foo') - with self.assertRaisesRegex(TclError, 'invalid arg "-pad": ' - 'should be non-negative'): - self.root.grid_rowconfigure(0, pad=-3) - self.root.grid_rowconfigure(0, pad=3) - self.assertEqual(self.root.grid_rowconfigure(0, 'pad'), 3) - self.assertEqual(self.root.grid_rowconfigure(0)['pad'], 3) - - def test_grid_rowconfigure_uniform(self): - self.root.grid_rowconfigure(0, uniform='foo') - self.assertEqual(self.root.grid_rowconfigure(0, 'uniform'), 'foo') - self.assertEqual(self.root.grid_rowconfigure(0)['uniform'], 'foo') - - def test_grid_forget(self): - b = tkinter.Button(self.root) - c = tkinter.Button(self.root) - b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, - padx=3, pady=4, sticky='ns') - self.assertEqual(self.root.grid_slaves(), [b]) - b.grid_forget() - c.grid_forget() - self.assertEqual(self.root.grid_slaves(), []) - self.assertEqual(b.grid_info(), {}) - b.grid_configure(row=0, column=0) - info = b.grid_info() - self.assertEqual(info['row'], self._str(0)) - self.assertEqual(info['column'], self._str(0)) - self.assertEqual(info['rowspan'], self._str(1)) - self.assertEqual(info['columnspan'], self._str(1)) - self.assertEqual(info['padx'], self._str(0)) - self.assertEqual(info['pady'], self._str(0)) - self.assertEqual(info['sticky'], '') - - def test_grid_remove(self): - b = tkinter.Button(self.root) - c = tkinter.Button(self.root) - b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, - padx=3, pady=4, sticky='ns') - self.assertEqual(self.root.grid_slaves(), [b]) - b.grid_remove() - c.grid_remove() - self.assertEqual(self.root.grid_slaves(), []) - self.assertEqual(b.grid_info(), {}) - b.grid_configure(row=0, column=0) - info = b.grid_info() - self.assertEqual(info['row'], self._str(0)) - self.assertEqual(info['column'], self._str(0)) - self.assertEqual(info['rowspan'], self._str(2)) - self.assertEqual(info['columnspan'], self._str(2)) - self.assertEqual(info['padx'], self._str(3)) - self.assertEqual(info['pady'], self._str(4)) - self.assertEqual(info['sticky'], 'ns') - - def test_grid_info(self): - b = tkinter.Button(self.root) - self.assertEqual(b.grid_info(), {}) - b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, - padx=3, pady=4, sticky='ns') - info = b.grid_info() - self.assertIsInstance(info, dict) - self.assertEqual(info['in'], self.root) - self.assertEqual(info['row'], self._str(2)) - self.assertEqual(info['column'], self._str(2)) - self.assertEqual(info['rowspan'], self._str(2)) - self.assertEqual(info['columnspan'], self._str(2)) - self.assertEqual(info['padx'], self._str(3)) - self.assertEqual(info['pady'], self._str(4)) - self.assertEqual(info['sticky'], 'ns') - - @requires_tcl(8, 5) - def test_grid_anchor(self): - with self.assertRaisesRegex(TclError, 'bad anchor "x"'): - self.root.grid_anchor('x') - with self.assertRaisesRegex(TclError, 'ambiguous anchor ""'): - self.root.grid_anchor('') - with self.assertRaises(TypeError): - self.root.grid_anchor('se', 'nw') - self.root.grid_anchor('se') - self.assertEqual(self.root.tk.call('grid', 'anchor', self.root), 'se') - - def test_grid_bbox(self): - self.assertEqual(self.root.grid_bbox(), (0, 0, 0, 0)) - self.assertEqual(self.root.grid_bbox(0, 0), (0, 0, 0, 0)) - self.assertEqual(self.root.grid_bbox(0, 0, 1, 1), (0, 0, 0, 0)) - with self.assertRaisesRegex(TclError, 'expected integer but got "x"'): - self.root.grid_bbox('x', 0) - with self.assertRaisesRegex(TclError, 'expected integer but got "x"'): - self.root.grid_bbox(0, 'x') - with self.assertRaisesRegex(TclError, 'expected integer but got "x"'): - self.root.grid_bbox(0, 0, 'x', 0) - with self.assertRaisesRegex(TclError, 'expected integer but got "x"'): - self.root.grid_bbox(0, 0, 0, 'x') - with self.assertRaises(TypeError): - self.root.grid_bbox(0, 0, 0, 0, 0) - t = tkinter.Toplevel(self.root) - # de-maximize - t.wm_geometry('1x1+0+0') - t.wm_geometry('') - f1 = tkinter.Frame(t, width=75, height=75, bg='red') - f2 = tkinter.Frame(t, width=90, height=90, bg='blue') - f1.grid_configure(row=0, column=0) - f2.grid_configure(row=1, column=1) - self.root.update() - self.assertEqual(t.grid_bbox(), (0, 0, 165, 165)) - self.assertEqual(t.grid_bbox(0, 0), (0, 0, 75, 75)) - self.assertEqual(t.grid_bbox(0, 0, 1, 1), (0, 0, 165, 165)) - self.assertEqual(t.grid_bbox(1, 1), (75, 75, 90, 90)) - self.assertEqual(t.grid_bbox(10, 10, 0, 0), (0, 0, 165, 165)) - self.assertEqual(t.grid_bbox(-2, -2, -1, -1), (0, 0, 0, 0)) - self.assertEqual(t.grid_bbox(10, 10, 12, 12), (165, 165, 0, 0)) - - def test_grid_location(self): - with self.assertRaises(TypeError): - self.root.grid_location() - with self.assertRaises(TypeError): - self.root.grid_location(0) - with self.assertRaises(TypeError): - self.root.grid_location(0, 0, 0) - with self.assertRaisesRegex(TclError, 'bad screen distance "x"'): - self.root.grid_location('x', 'y') - with self.assertRaisesRegex(TclError, 'bad screen distance "y"'): - self.root.grid_location('1c', 'y') - t = tkinter.Toplevel(self.root) - # de-maximize - t.wm_geometry('1x1+0+0') - t.wm_geometry('') - f = tkinter.Frame(t, width=200, height=100, - highlightthickness=0, bg='red') - self.assertEqual(f.grid_location(10, 10), (-1, -1)) - f.grid_configure() - self.root.update() - self.assertEqual(t.grid_location(-10, -10), (-1, -1)) - self.assertEqual(t.grid_location(-10, 0), (-1, 0)) - self.assertEqual(t.grid_location(-1, 0), (-1, 0)) - self.assertEqual(t.grid_location(0, -10), (0, -1)) - self.assertEqual(t.grid_location(0, -1), (0, -1)) - self.assertEqual(t.grid_location(0, 0), (0, 0)) - self.assertEqual(t.grid_location(200, 0), (0, 0)) - self.assertEqual(t.grid_location(201, 0), (1, 0)) - self.assertEqual(t.grid_location(0, 100), (0, 0)) - self.assertEqual(t.grid_location(0, 101), (0, 1)) - self.assertEqual(t.grid_location(201, 101), (1, 1)) - - def test_grid_propagate(self): - self.assertEqual(self.root.grid_propagate(), True) - with self.assertRaises(TypeError): - self.root.grid_propagate(False, False) - self.root.grid_propagate(False) - self.assertFalse(self.root.grid_propagate()) - f = tkinter.Frame(self.root, width=100, height=100, bg='red') - f.grid_configure(row=0, column=0) - self.root.update() - self.assertEqual(f.winfo_width(), 100) - self.assertEqual(f.winfo_height(), 100) - f.grid_propagate(False) - g = tkinter.Frame(self.root, width=75, height=85, bg='green') - g.grid_configure(in_=f, row=0, column=0) - self.root.update() - self.assertEqual(f.winfo_width(), 100) - self.assertEqual(f.winfo_height(), 100) - f.grid_propagate(True) - self.root.update() - self.assertEqual(f.winfo_width(), 75) - self.assertEqual(f.winfo_height(), 85) - - def test_grid_size(self): - with self.assertRaises(TypeError): - self.root.grid_size(0) - self.assertEqual(self.root.grid_size(), (0, 0)) - f = tkinter.Scale(self.root) - f.grid_configure(row=0, column=0) - self.assertEqual(self.root.grid_size(), (1, 1)) - f.grid_configure(row=4, column=5) - self.assertEqual(self.root.grid_size(), (6, 5)) - - def test_grid_slaves(self): - self.assertEqual(self.root.grid_slaves(), []) - a = tkinter.Label(self.root) - a.grid_configure(row=0, column=1) - b = tkinter.Label(self.root) - b.grid_configure(row=1, column=0) - c = tkinter.Label(self.root) - c.grid_configure(row=1, column=1) - d = tkinter.Label(self.root) - d.grid_configure(row=1, column=1) - self.assertEqual(self.root.grid_slaves(), [d, c, b, a]) - self.assertEqual(self.root.grid_slaves(row=0), [a]) - self.assertEqual(self.root.grid_slaves(row=1), [d, c, b]) - self.assertEqual(self.root.grid_slaves(column=0), [b]) - self.assertEqual(self.root.grid_slaves(column=1), [d, c, a]) - self.assertEqual(self.root.grid_slaves(row=1, column=1), [d, c]) - - -tests_gui = ( - PackTest, PlaceTest, GridTest, -) - -if __name__ == '__main__': - unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/tkinter/test/test_tkinter/test_misc.py --- a/Lib/tkinter/test/test_tkinter/test_misc.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/tkinter/test/test_tkinter/test_misc.py Sun Mar 23 09:44:28 2014 +0100 @@ -10,11 +10,6 @@ def setUp(self): self.root = ttk.setup_master() - def test_repr(self): - t = tkinter.Toplevel(self.root, name='top') - f = tkinter.Frame(t, name='child') - self.assertEqual(repr(f), '') - def test_tk_setPalette(self): root = self.root root.tk_setPalette('black') diff -r ce070040e1a6 -r d7f128afe9db Lib/tkinter/test/widget_tests.py --- a/Lib/tkinter/test/widget_tests.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/tkinter/test/widget_tests.py Sun Mar 23 09:44:28 2014 +0100 @@ -33,17 +33,6 @@ if not self.root.wantobjects(): self.wantobjects = False - def tearDown(self): - for w in self.root.winfo_children(): - w.destroy() - - def _str(self, value): - if self.wantobjects and tcl_version >= (8, 6): - return value - if isinstance(value, tuple): - return ' '.join(map(self._str, value)) - return str(value) - def create(self, **kwargs): widget = self._create(**kwargs) self.addCleanup(widget.destroy) diff -r ce070040e1a6 -r d7f128afe9db Lib/token.py --- a/Lib/token.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/token.py Sun Mar 23 09:44:28 2014 +0100 @@ -60,12 +60,11 @@ DOUBLESLASH = 47 DOUBLESLASHEQUAL = 48 AT = 49 -ATEQUAL = 50 -RARROW = 51 -ELLIPSIS = 52 -OP = 53 -ERRORTOKEN = 54 -N_TOKENS = 55 +RARROW = 50 +ELLIPSIS = 51 +OP = 52 +ERRORTOKEN = 53 +N_TOKENS = 54 NT_OFFSET = 256 #--end constants-- diff -r ce070040e1a6 -r d7f128afe9db Lib/tokenize.py --- a/Lib/tokenize.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/tokenize.py Sun Mar 23 09:44:28 2014 +0100 @@ -91,8 +91,7 @@ '**=': DOUBLESTAREQUAL, '//': DOUBLESLASH, '//=': DOUBLESLASHEQUAL, - '@': AT, - '@=': ATEQUAL, + '@': AT } class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')): @@ -151,7 +150,7 @@ # recognized as two instances of =). Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=", r"//=?", r"->", - r"[+\-*/%&@|^=<>]=?", + r"[+\-*/%&|^=<>]=?", r"~") Bracket = '[][(){}]' diff -r ce070040e1a6 -r d7f128afe9db Lib/turtle.py --- a/Lib/turtle.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/turtle.py Sun Mar 23 09:44:28 2014 +0100 @@ -109,7 +109,6 @@ import math import time import inspect -import sys from os.path import isfile, split, join from copy import deepcopy @@ -993,12 +992,6 @@ self._colormode = _CFG["colormode"] self._keys = [] self.clear() - if sys.platform == 'darwin': - # Force Turtle window to the front on OS X. This is needed because - # the Turtle window will show behind the Terminal window when you - # start the demo from the command line. - cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '1') - cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '0') def clear(self): """Delete all drawings and all turtles from the TurtleScreen. diff -r ce070040e1a6 -r d7f128afe9db Lib/turtledemo/__init__.py --- a/Lib/turtledemo/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/turtledemo/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,14 +0,0 @@ -""" - -------------------------------------- - About this viewer - -------------------------------------- - - Tiny demo viewer to view turtle graphics example scripts. - - Quickly and dirtyly assembled by Gregor Lingl. - June, 2006 - - For more information see: turtledemo - Help - - Have fun! -""" diff -r ce070040e1a6 -r d7f128afe9db Lib/turtledemo/__main__.py --- a/Lib/turtledemo/__main__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/turtledemo/__main__.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,81 +1,12 @@ #!/usr/bin/env python3 - -""" - ---------------------------------------------- - - turtledemo - Help - - ---------------------------------------------- - - This document has two sections: - - (1) How to use the demo viewer - (2) How to add your own demos to the demo repository - - - (1) How to use the demo viewer. - - Select a demoscript from the example menu. - The (syntax coloured) source code appears in the left - source code window. IT CANNOT BE EDITED, but ONLY VIEWED! - - - Press START button to start the demo. - - Stop execution by pressing the STOP button. - - Clear screen by pressing the CLEAR button. - - Restart by pressing the START button again. - - SPECIAL demos are those which run EVENTDRIVEN. - (For example clock.py - or oldTurtleDemo.py which - in the end expects a mouse click.): - - Press START button to start the demo. - - - Until the EVENTLOOP is entered everything works - as in an ordinary demo script. - - - When the EVENTLOOP is entered, you control the - application by using the mouse and/or keys (or it's - controlled by some timer events) - To stop it you can and must press the STOP button. - - While the EVENTLOOP is running, the examples menu is disabled. - - - Only after having pressed the STOP button, you may - restart it or choose another example script. - - * * * * * * * * - In some rare situations there may occur interferences/conflicts - between events concerning the demo script and those concerning the - demo-viewer. (They run in the same process.) Strange behaviour may be - the consequence and in the worst case you must close and restart the - viewer. - * * * * * * * * - - - (2) How to add your own demos to the demo repository - - - place: same directory as turtledemo/__main__.py - - - requirements on source code: - code must contain a main() function which will - be executed by the viewer (see provided example scripts) - main() may return a string which will be displayed - in the Label below the source code window (when execution - has finished.) - - !! For programs, which are EVENT DRIVEN, main must return - !! the string "EVENTLOOP". This informs the viewer, that the - !! script is still running and must be stopped by the user! -""" import sys import os from tkinter import * from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator -from idlelib.textView import view_text # TextViewer +from idlelib.textView import view_file # TextViewer from importlib import reload -from turtledemo import __doc__ as about_turtledemo import turtle import time @@ -97,13 +28,16 @@ entry.endswith(".py") and entry[0] != '_'] def showDemoHelp(): - view_text(demo.root, "Help on turtledemo", __doc__) + view_file(demo.root, "Help on turtleDemo", + os.path.join(demo_dir, "demohelp.txt")) def showAboutDemo(): - view_text(demo.root, "About turtledemo", about_turtledemo) + view_file(demo.root, "About turtleDemo", + os.path.join(demo_dir, "about_turtledemo.txt")) def showAboutTurtle(): - view_text(demo.root, "About the turtle module.", turtle.__doc__) + view_file(demo.root, "About the new turtle module.", + os.path.join(demo_dir, "about_turtle.txt")) class DemoWindow(object): diff -r ce070040e1a6 -r d7f128afe9db Lib/turtledemo/about_turtle.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/turtledemo/about_turtle.txt Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,76 @@ + +======================================================== + A new turtle module for Python +======================================================== + +Turtle graphics is a popular way for introducing programming to +kids. It was part of the original Logo programming language developed +by Wally Feurzig and Seymour Papert in 1966. + +Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it +the command turtle.forward(15), and it moves (on-screen!) 15 pixels in +the direction it is facing, drawing a line as it moves. Give it the +command turtle.right(25), and it rotates in-place 25 degrees clockwise. + +By combining together these and similar commands, intricate shapes and +pictures can easily be drawn. + +----- turtle.py + +This module is an extended reimplementation of turtle.py from the +Python standard distribution up to Python 2.5. (See: http:\\www.python.org) + +It tries to keep the merits of turtle.py and to be (nearly) 100% +compatible with it. This means in the first place to enable the +learning programmer to use all the commands, classes and methods +interactively when using the module from within IDLE run with +the -n switch. + +Roughly it has the following features added: + +- Better animation of the turtle movements, especially of turning the + turtle. So the turtles can more easily be used as a visual feedback + instrument by the (beginning) programmer. + +- Different turtle shapes, gif-images as turtle shapes, user defined + and user controllable turtle shapes, among them compound + (multicolored) shapes. Turtle shapes can be stgretched and tilted, which + makes turtles zu very versatile geometrical objects. + +- Fine control over turtle movement and screen updates via delay(), + and enhanced tracer() and speed() methods. + +- Aliases for the most commonly used commands, like fd for forward etc., + following the early Logo traditions. This reduces the boring work of + typing long sequences of commands, which often occur in a natural way + when kids try to program fancy pictures on their first encounter with + turtle graphcis. + +- Turtles now have an undo()-method with configurable undo-buffer. + +- Some simple commands/methods for creating event driven programs + (mouse-, key-, timer-events). Especially useful for programming games. + +- A scrollable Canvas class. The default scrollable Canvas can be + extended interactively as needed while playing around with the turtle(s). + +- A TurtleScreen class with methods controlling background color or + background image, window and canvas size and other properties of the + TurtleScreen. + +- There is a method, setworldcoordinates(), to install a user defined + coordinate-system for the TurtleScreen. + +- The implementation uses a 2-vector class named Vec2D, derived from tuple. + This class is public, so it can be imported by the application programmer, + which makes certain types of computations very natural and compact. + +- Appearance of the TurtleScreen and the Turtles at startup/import can be + configured by means of a turtle.cfg configuration file. + The default configuration mimics the appearance of the old turtle module. + +- If configured appropriately the module reads in docstrings from a docstring + dictionary in some different language, supplied separately and replaces + the english ones by those read in. There is a utility function + write_docstringdict() to write a dictionary with the original (english) + docstrings to disc, so it can serve as a template for translations. diff -r ce070040e1a6 -r d7f128afe9db Lib/turtledemo/about_turtledemo.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/turtledemo/about_turtledemo.txt Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,13 @@ + + -------------------------------------- + About this viewer + -------------------------------------- + + Tiny demo viewer to view turtle graphics example scripts. + + Quickly and dirtyly assembled by Gregor Lingl. + June, 2006 + + For more information see: turtleDemo - Help + + Have fun! diff -r ce070040e1a6 -r d7f128afe9db Lib/turtledemo/demohelp.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/turtledemo/demohelp.txt Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,70 @@ + + + ---------------------------------------------- + + turtleDemo - Help + + ---------------------------------------------- + + This document has two sections: + + (1) How to use the demo viewer + (2) How to add your own demos to the demo repository + + + (1) How to use the demo viewer. + + Select a demoscript from the example menu. + The (syntax coloured) source code appears in the left + source code window. IT CANNOT BE EDITED, but ONLY VIEWED! + + - Press START button to start the demo. + - Stop execution by pressing the STOP button. + - Clear screen by pressing the CLEAR button. + - Restart by pressing the START button again. + + SPECIAL demos are those which run EVENTDRIVEN. + (For example clock.py - or oldTurtleDemo.py which + in the end expects a mouse click.): + + Press START button to start the demo. + + - Until the EVENTLOOP is entered everything works + as in an ordinary demo script. + + - When the EVENTLOOP is entered, you control the + application by using the mouse and/or keys (or it's + controlled by some timer events) + To stop it you can and must press the STOP button. + + While the EVENTLOOP is running, the examples menu is disabled. + + - Only after having pressed the STOP button, you may + restart it or choose another example script. + + * * * * * * * * + In some rare situations there may occur interferences/conflicts + between events concerning the demo script and those concerning the + demo-viewer. (They run in the same process.) Strange behaviour may be + the consequence and in the worst case you must close and restart the + viewer. + * * * * * * * * + + + (2) How to add your own demos to the demo repository + + - place: same directory as turtledemo/__main__.py + + - requirements on source code: + code must contain a main() function which will + be executed by the viewer (see provided example scripts) + main() may return a string which will be displayed + in the Label below the source code window (when execution + has finished.) + + !! For programs, which are EVENT DRIVEN, main must return + !! the string "EVENTLOOP". This informs the viewer, that the + !! script is still running and must be stopped by the user! + + + diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/case.py --- a/Lib/unittest/case.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/case.py Sun Mar 23 09:44:28 2014 +0100 @@ -9,7 +9,6 @@ import warnings import collections import contextlib -import traceback from . import result from .util import (strclass, safe_repr, _count_diff_all_purpose, @@ -179,8 +178,6 @@ self.obj_name)) else: self._raiseFailure("{} not raised".format(exc_name)) - else: - traceback.clear_frames(tb) if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/mock.py --- a/Lib/unittest/mock.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/mock.py Sun Mar 23 09:44:28 2014 +0100 @@ -27,13 +27,9 @@ import inspect import pprint import sys -import builtins -from types import ModuleType from functools import wraps, partial -_builtins = {name for name in dir(builtins) if not name.startswith('_')} - BaseExceptions = (BaseException,) if 'java' in sys.platform: # jython @@ -347,14 +343,7 @@ value._mock_name = name return True -# Internal class to identify if we wrapped an iterator object or not. -class _MockIter(object): - def __init__(self, obj): - self.obj = iter(obj) - def __iter__(self): - return self - def __next__(self): - return next(self.obj) + class Base(object): _mock_return_value = DEFAULT @@ -379,7 +368,7 @@ def __init__( self, spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, - _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs + _spec_as_instance=False, _eat_self=None, **kwargs ): if _new_parent is None: _new_parent = parent @@ -409,7 +398,6 @@ __dict__['_mock_mock_calls'] = _CallList() __dict__['method_calls'] = _CallList() - __dict__['_mock_unsafe'] = unsafe if kwargs: self.configure_mock(**kwargs) @@ -507,11 +495,7 @@ delegated = self._mock_delegate if delegated is None: return self._mock_side_effect - sf = delegated.side_effect - if sf is not None and not callable(sf) and not isinstance(sf, _MockIter): - sf = _MockIter(sf) - delegated.side_effect = sf - return sf + return delegated.side_effect def __set_side_effect(self, value): value = _try_iter(value) @@ -566,16 +550,13 @@ def __getattr__(self, name): - if name in {'_mock_methods', '_mock_unsafe'}: + if name == '_mock_methods': raise AttributeError(name) elif self._mock_methods is not None: if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name): raise AttributeError(name) - if not self._mock_unsafe: - if name.startswith(('assert', 'assret')): - raise AttributeError(name) result = self._mock_children.get(name) if result is _deleted: @@ -758,14 +739,6 @@ else: return _call - def assert_not_called(_mock_self): - """assert that the mock was never called. - """ - self = _mock_self - if self.call_count != 0: - msg = ("Expected '%s' to not have been called. Called %s times." % - (self._mock_name or 'mock', self.call_count)) - raise AssertionError(msg) def assert_called_with(_mock_self, *args, **kwargs): """assert that the mock was called with the specified arguments. @@ -1066,7 +1039,7 @@ class _patch(object): attribute_name = None - _active_patches = [] + _active_patches = set() def __init__( self, getter, attribute, new, spec, create, @@ -1182,9 +1155,6 @@ else: local = True - if name in _builtins and isinstance(target, ModuleType): - self.create = True - if not self.create and original is DEFAULT: raise AttributeError( "%s does not have the attribute %r" % (target, name) @@ -1342,18 +1312,13 @@ def start(self): """Activate a patch, returning any created mock.""" result = self.__enter__() - self._active_patches.append(self) + self._active_patches.add(self) return result def stop(self): """Stop an active patch.""" - try: - self._active_patches.remove(self) - except ValueError: - # If the patch hasn't been started this will fail - pass - + self._active_patches.discard(self) return self.__exit__() @@ -1646,8 +1611,8 @@ def _patch_stopall(): - """Stop all active patches. LIFO to unroll nested patches.""" - for patch in reversed(_patch._active_patches): + """Stop all active patches.""" + for patch in list(_patch._active_patches): patch.stop() @@ -1669,9 +1634,7 @@ "bool next " ) -numerics = ( - "add sub mul div floordiv mod lshift rshift and xor or pow truediv" -) +numerics = "add sub mul div floordiv mod lshift rshift and xor or pow " inplace = ' '.join('i%s' % n for n in numerics.split()) right = ' '.join('r%s' % n for n in numerics.split()) @@ -2120,8 +2083,6 @@ elif is_type and instance and not _instance_callable(spec): Klass = NonCallableMagicMock - _name = _kwargs.pop('name', _name) - _new_name = _name if _parent is None: # for a top level object no _new_name should be set diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/test_assertions.py --- a/Lib/unittest/test/test_assertions.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/test_assertions.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,5 @@ import datetime import warnings -import weakref import unittest from itertools import product @@ -98,36 +97,6 @@ else: self.fail("assertRaises() didn't let exception pass through") - def test_assertRaises_frames_survival(self): - # Issue #9815: assertRaises should avoid keeping local variables - # in a traceback alive. - class A: - pass - wr = None - - class Foo(unittest.TestCase): - - def foo(self): - nonlocal wr - a = A() - wr = weakref.ref(a) - try: - raise IOError - except IOError: - raise ValueError - - def test_functional(self): - self.assertRaises(ValueError, self.foo) - - def test_with(self): - with self.assertRaises(ValueError): - self.foo() - - Foo("test_functional").run() - self.assertIsNone(wr()) - Foo("test_with").run() - self.assertIsNone(wr()) - def testAssertNotRegex(self): self.assertNotRegex('Ala ma kota', r'r+') try: diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/test_case.py --- a/Lib/unittest/test/test_case.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/test_case.py Sun Mar 23 09:44:28 2014 +0100 @@ -1080,7 +1080,7 @@ # so can't use assertEqual either. Just use assertTrue. self.assertTrue(sample_text_error == error) - def testAssertEqualSingleLine(self): + def testAsertEqualSingleLine(self): sample_text = "laden swallows fly slowly" revised_sample_text = "unladen swallows fly quickly" sample_text_error = """\ diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/test_loader.py --- a/Lib/unittest/test/test_loader.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/test_loader.py Sun Mar 23 09:44:28 2014 +0100 @@ -255,7 +255,7 @@ try: loader.loadTestsFromName('unittest.sdasfasfasdf') except AttributeError as e: - self.assertEqual(str(e), "module 'unittest' has no attribute 'sdasfasfasdf'") + self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") @@ -272,7 +272,7 @@ try: loader.loadTestsFromName('sdasfasfasdf', unittest) except AttributeError as e: - self.assertEqual(str(e), "module 'unittest' has no attribute 'sdasfasfasdf'") + self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") @@ -635,7 +635,7 @@ try: loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest']) except AttributeError as e: - self.assertEqual(str(e), "module 'unittest' has no attribute 'sdasfasfasdf'") + self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError") @@ -654,7 +654,7 @@ try: loader.loadTestsFromNames(['sdasfasfasdf'], unittest) except AttributeError as e: - self.assertEqual(str(e), "module 'unittest' has no attribute 'sdasfasfasdf'") + self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") @@ -673,7 +673,7 @@ try: loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest) except AttributeError as e: - self.assertEqual(str(e), "module 'unittest' has no attribute 'sdasfasfasdf'") + self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/testmock/testmagicmethods.py --- a/Lib/unittest/test/testmock/testmagicmethods.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/testmock/testmagicmethods.py Sun Mar 23 09:44:28 2014 +0100 @@ -126,31 +126,6 @@ self.assertEqual(7 + mock, mock) self.assertEqual(mock.value, 16) - def test_division(self): - original = mock = Mock() - mock.value = 32 - self.assertRaises(TypeError, lambda: mock / 2) - - def truediv(self, other): - mock.value /= other - return self - mock.__truediv__ = truediv - self.assertEqual(mock / 2, mock) - self.assertEqual(mock.value, 16) - - del mock.__truediv__ - def itruediv(mock): - mock /= 4 - self.assertRaises(TypeError, itruediv, mock) - mock.__itruediv__ = truediv - mock /= 8 - self.assertEqual(mock, original) - self.assertEqual(mock.value, 2) - - self.assertRaises(TypeError, lambda: 8 / mock) - mock.__rtruediv__ = truediv - self.assertEqual(0.5 / mock, mock) - self.assertEqual(mock.value, 4) def test_hash(self): mock = Mock() diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/testmock/testmock.py Sun Mar 23 09:44:28 2014 +0100 @@ -154,24 +154,6 @@ mock = Mock(side_effect=side_effect, return_value=sentinel.RETURN) self.assertEqual(mock(), sentinel.RETURN) - def test_autospec_side_effect(self): - # Test for issue17826 - results = [1, 2, 3] - def effect(): - return results.pop() - def f(): - pass - - mock = create_autospec(f) - mock.side_effect = [1, 2, 3] - self.assertEqual([mock(), mock(), mock()], [1, 2, 3], - "side effect not used correctly in create_autospec") - # Test where side effect is a callable - results = [1, 2, 3] - mock = create_autospec(f) - mock.side_effect = effect - self.assertEqual([mock(), mock(), mock()], [3, 2, 1], - "callable side effect not used correctly") @unittest.skipUnless('java' in sys.platform, 'This test only applies to Jython') @@ -1182,30 +1164,6 @@ func.mock_calls, [call(1, 2), call(3, 4)] ) - #Issue21222 - def test_create_autospec_with_name(self): - m = mock.create_autospec(object(), name='sweet_func') - self.assertIn('sweet_func', repr(m)) - - #Issue21238 - def test_mock_unsafe(self): - m = Mock() - with self.assertRaises(AttributeError): - m.assert_foo_call() - with self.assertRaises(AttributeError): - m.assret_foo_call() - m = Mock(unsafe=True) - m.assert_foo_call() - m.assret_foo_call() - - #Issue21262 - def test_assert_not_called(self): - m = Mock() - m.hello.assert_not_called() - m.hello() - with self.assertRaises(AssertionError): - m.hello.assert_not_called() - def test_mock_add_spec(self): class _One(object): diff -r ce070040e1a6 -r d7f128afe9db Lib/unittest/test/testmock/testpatch.py --- a/Lib/unittest/test/testmock/testpatch.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/unittest/test/testmock/testpatch.py Sun Mar 23 09:44:28 2014 +0100 @@ -12,7 +12,7 @@ from unittest.mock import ( NonCallableMock, CallableMixin, patch, sentinel, MagicMock, Mock, NonCallableMagicMock, patch, _patch, - DEFAULT, call, _get_target, _patch + DEFAULT, call, _get_target ) @@ -377,7 +377,7 @@ def test_patchobject_wont_create_by_default(self): try: - @patch.object(SomeClass, 'ord', sentinel.Frooble) + @patch.object(SomeClass, 'frooble', sentinel.Frooble) def test(): self.fail('Patching non existent attributes should fail') @@ -386,27 +386,7 @@ pass else: self.fail('Patching non existent attributes should fail') - self.assertFalse(hasattr(SomeClass, 'ord')) - - - def test_patch_builtins_without_create(self): - @patch(__name__+'.ord') - def test_ord(mock_ord): - mock_ord.return_value = 101 - return ord('c') - - @patch(__name__+'.open') - def test_open(mock_open): - m = mock_open.return_value - m.read.return_value = 'abcd' - - fobj = open('doesnotexists.txt') - data = fobj.read() - fobj.close() - return data - - self.assertEqual(test_ord(), 101) - self.assertEqual(test_open(), 'abcd') + self.assertFalse(hasattr(SomeClass, 'frooble')) def test_patch_with_static_methods(self): @@ -1799,23 +1779,6 @@ patched() self.assertIs(os.path, path) - def test_stopall_lifo(self): - stopped = [] - class thing(object): - one = two = three = None - - def get_patch(attribute): - class mypatch(_patch): - def stop(self): - stopped.append(attribute) - return super(mypatch, self).stop() - return mypatch(lambda: thing, attribute, None, None, - False, None, None, None, {}) - [get_patch(val).start() for val in ("one", "two", "three")] - patch.stopall() - - self.assertEqual(stopped, ["three", "two", "one"]) - if __name__ == '__main__': unittest.main() diff -r ce070040e1a6 -r d7f128afe9db Lib/urllib/request.py --- a/Lib/urllib/request.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/urllib/request.py Sun Mar 23 09:44:28 2014 +0100 @@ -511,6 +511,9 @@ If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ + def isclass(obj): + return isinstance(obj, type) or hasattr(obj, "__bases__") + opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, @@ -521,7 +524,7 @@ skip = set() for klass in default_classes: for check in handlers: - if isinstance(check, type): + if isclass(check): if issubclass(check, klass): skip.add(klass) elif isinstance(check, klass): @@ -533,7 +536,7 @@ opener.add_handler(klass()) for h in handlers: - if isinstance(h, type): + if isclass(h): h = h() opener.add_handler(h) return opener @@ -687,7 +690,50 @@ If a URL is supplied, it must have an authority (host:port) component. According to RFC 3986, having an authority component means the URL must - have two slashes after the scheme. + have two slashes after the scheme: + + >>> _parse_proxy('file:/ftp.example.com/') + Traceback (most recent call last): + ValueError: proxy URL with no authority: 'file:/ftp.example.com/' + + The first three items of the returned tuple may be None. + + Examples of authority parsing: + + >>> _parse_proxy('proxy.example.com') + (None, None, None, 'proxy.example.com') + >>> _parse_proxy('proxy.example.com:3128') + (None, None, None, 'proxy.example.com:3128') + + The authority component may optionally include userinfo (assumed to be + username:password): + + >>> _parse_proxy('joe:password@proxy.example.com') + (None, 'joe', 'password', 'proxy.example.com') + >>> _parse_proxy('joe:password@proxy.example.com:3128') + (None, 'joe', 'password', 'proxy.example.com:3128') + + Same examples, but with URLs instead: + + >>> _parse_proxy('http://proxy.example.com/') + ('http', None, None, 'proxy.example.com') + >>> _parse_proxy('http://proxy.example.com:3128/') + ('http', None, None, 'proxy.example.com:3128') + >>> _parse_proxy('http://joe:password@proxy.example.com/') + ('http', 'joe', 'password', 'proxy.example.com') + >>> _parse_proxy('http://joe:password@proxy.example.com:3128') + ('http', 'joe', 'password', 'proxy.example.com:3128') + + Everything after the authority is ignored: + + >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128') + ('ftp', 'joe', 'password', 'proxy.example.com') + + Test for no trailing '/' case: + + >>> _parse_proxy('http://joe:password@proxy.example.com') + ('http', 'joe', 'password', 'proxy.example.com') + """ scheme, r_scheme = splittype(proxy) if not r_scheme.startswith("/"): diff -r ce070040e1a6 -r d7f128afe9db Lib/urllib/response.py --- a/Lib/urllib/response.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/urllib/response.py Sun Mar 23 09:44:28 2014 +0100 @@ -6,39 +6,60 @@ headers and a geturl() method that returns the url. """ -import tempfile - -__all__ = ['addbase', 'addclosehook', 'addinfo', 'addinfourl'] - - -class addbase(tempfile._TemporaryFileWrapper): - """Base class for addinfo and addclosehook. Is a good idea for garbage collection.""" +class addbase(object): + """Base class for addinfo and addclosehook.""" # XXX Add a method to expose the timeout on the underlying socket? def __init__(self, fp): - super(addbase, self).__init__(fp, '', delete=False) - # Keep reference around as this was part of the original API. + # TODO(jhylton): Is there a better way to delegate using io? self.fp = fp + self.read = self.fp.read + self.readline = self.fp.readline + # TODO(jhylton): Make sure an object with readlines() is also iterable + if hasattr(self.fp, "readlines"): + self.readlines = self.fp.readlines + if hasattr(self.fp, "fileno"): + self.fileno = self.fp.fileno + else: + self.fileno = lambda: None + + def __iter__(self): + # Assigning `__iter__` to the instance doesn't work as intended + # because the iter builtin does something like `cls.__iter__(obj)` + # and thus fails to find the _bound_ method `obj.__iter__`. + # Returning just `self.fp` works for built-in file objects but + # might not work for general file-like objects. + return iter(self.fp) def __repr__(self): return '<%s at %r whose fp = %r>' % (self.__class__.__name__, - id(self), self.file) + id(self), self.fp) + + def close(self): + if self.fp: + self.fp.close() + self.fp = None + self.read = None + self.readline = None + self.readlines = None + self.fileno = None + self.__iter__ = None + self.__next__ = None def __enter__(self): - if self.fp.closed: + if self.fp is None: raise ValueError("I/O operation on closed file") return self def __exit__(self, type, value, traceback): self.close() - class addclosehook(addbase): """Class to add a close hook to an open file.""" def __init__(self, fp, closehook, *hookargs): - super(addclosehook, self).__init__(fp) + addbase.__init__(self, fp) self.closehook = closehook self.hookargs = hookargs @@ -47,28 +68,30 @@ self.closehook(*self.hookargs) self.closehook = None self.hookargs = None - super(addclosehook, self).close() - + addbase.close(self) class addinfo(addbase): """class to add an info() method to an open file.""" def __init__(self, fp, headers): - super(addinfo, self).__init__(fp) + addbase.__init__(self, fp) self.headers = headers def info(self): return self.headers - -class addinfourl(addinfo): +class addinfourl(addbase): """class to add info() and geturl() methods to an open file.""" def __init__(self, fp, headers, url, code=None): - super(addinfourl, self).__init__(fp, headers) + addbase.__init__(self, fp) + self.headers = headers self.url = url self.code = code + def info(self): + return self.headers + def getcode(self): return self.code diff -r ce070040e1a6 -r d7f128afe9db Lib/venv/__init__.py --- a/Lib/venv/__init__.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/venv/__init__.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,7 +1,7 @@ """ Virtual environment (venv) package for Python. Based on PEP 405. -Copyright (C) 2011-2014 Vinay Sajip. +Copyright (C) 2011-2012 Vinay Sajip. Licensed to the PSF under a contributor agreement. usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear] @@ -30,7 +30,6 @@ import logging import os import shutil -import struct import subprocess import sys import types @@ -133,18 +132,10 @@ else: binname = 'bin' incpath = 'include' - libpath = os.path.join(env_dir, 'lib', - 'python%d.%d' % sys.version_info[:2], - 'site-packages') + libpath = os.path.join(env_dir, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages') context.inc_path = path = os.path.join(env_dir, incpath) create_if_needed(path) create_if_needed(libpath) - # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX - if ((struct.calcsize('P') == 8) and (os.name == 'posix') and - (sys.platform != 'darwin')): - p = os.path.join(env_dir, 'lib') - link_path = os.path.join(env_dir, 'lib64') - os.symlink(p, link_path) context.bin_path = binpath = os.path.join(env_dir, binname) context.bin_name = binname context.env_exe = os.path.join(binpath, exename) diff -r ce070040e1a6 -r d7f128afe9db Lib/xml/dom/expatbuilder.py --- a/Lib/xml/dom/expatbuilder.py Sat May 10 13:24:58 2014 -0400 +++ b/Lib/xml/dom/expatbuilder.py Sun Mar 23 09:44:28 2014 +0100 @@ -121,12 +121,10 @@ qname = "%s:%s" % (prefix, localname) qname = intern(qname, qname) localname = intern(localname, localname) - elif len(parts) == 2: + else: uri, localname = parts prefix = EMPTY_PREFIX qname = localname = intern(localname, localname) - else: - raise ValueError("Unsupported syntax: spaces in URIs not supported: %r" % name) return intern(uri, uri), localname, prefix, qname diff -r ce070040e1a6 -r d7f128afe9db Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt Sat May 10 13:24:58 2014 -0400 +++ b/Mac/BuildScript/README.txt Sun Mar 23 09:44:28 2014 +0100 @@ -12,9 +12,9 @@ for each release. 1. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.5 through (at least) 10.9:: + supported by Mac OS X 10.5 through (at least) 10.8:: - /path/to/bootstrap/python2.7 build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \ --universal-archs=32-bit \ --dep-target=10.5 @@ -22,14 +22,14 @@ - builds the following third-party libraries * NCurses 5.9 (http://bugs.python.org/issue15037) - * SQLite 3.8.3.1 + * SQLite 3.8.1 * XZ 5.0.5 - uses system-supplied versions of third-party libraries * readline module links with Apple BSD editline (libedit) - - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building + - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - recommended build environment: @@ -38,8 +38,7 @@ * ``MacOSX10.5`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.5`` * Apple ``gcc-4.2`` - * bootstrap non-framework Python 2.7 for documentation build with - Sphinx (as of 3.4.1) + * system Python 2.5 for documentation build with Sphinx - alternate build environments: @@ -49,7 +48,7 @@ 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - /path/to/bootstrap/python2.7 build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 @@ -57,14 +56,14 @@ - builds the following third-party libraries * NCurses 5.9 (http://bugs.python.org/issue15037) - * SQLite 3.8.3.1 + * SQLite 3.8.1 * XZ 5.0.5 - uses system-supplied versions of third-party libraries * readline module links with Apple BSD editline (libedit) - - requires ActiveState Tcl/Tk 8.5.15.1 (or later) to be installed for building + - requires ActiveState Tcl/Tk 8.5.15 (or later) to be installed for building - recommended build environment: @@ -73,8 +72,7 @@ * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * bootstrap non-framework Python 2.7 for documentation build with - Sphinx (as of 3.4.1) + * system Python 2.6 for documentation build with Sphinx - alternate build environments: @@ -84,10 +82,10 @@ considered a migration aid by Apple and is not likely to be fixed, its use should be avoided. The other compiler, ``clang``, has been undergoing rapid development. While it appears to have become - production-ready in the most recent Xcode 5 releases, the versions - available on the deprecated Xcode 4.x for 10.6 were early releases - and did not receive the level of exposure in production environments - that the Xcode 3 gcc-4.2 compiler has had. + production-ready in the most recent Xcode 4 releases (Xcode 4.6.3 + as of this writing), there are still some open issues when + building Python and there has not yet been the level of exposure in + production environments that the Xcode 3 gcc-4.2 compiler has had. * For Python 2.7.x and 3.2.x, the 32-bit-only installer was configured to @@ -113,7 +111,7 @@ * Zlib 1.2.3 * Oracle Sleepycat DB 4.8 (Python 2.x only) - - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building + - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - recommended build environment: @@ -139,13 +137,7 @@ interfere with the build. * The documentation for the release is built using Sphinx - because it is included in the installer. For 2.7.x and 3.x.x up to and - including 3.4.0, the ``Doc/Makefile`` uses ``svn`` to download repos of - ``Sphinx`` and its dependencies. Beginning with 3.4.1, the ``Doc/Makefile`` - assumes there is an externally-provided ``sphinx-build`` and requires at - least Python 2.6 to run. Because of this, it is no longer possible to - build a 3.4.1 or later installer on OS X 10.5 using the Apple-supplied - Python 2.5. + because it is included in the installer. * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. @@ -203,8 +195,8 @@ on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on a PPC G4 system with OS X 10.5 and at least one Intel system running OS X -10.9, 10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.9, 10.8, -10.7, and 10.6 systems in both 32-bit and 64-bit modes.:: +10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 +systems in both 32-bit and 64-bit modes.:: /usr/local/bin/pythonn.n -m test -w -u all,-largefile /usr/local/bin/pythonn.n-32 -m test -w -u all @@ -215,7 +207,7 @@ during testing and can be ignored. It is also recommend to launch IDLE and verify that it is at least -functional. Double-click on the IDLE app icon in ``/Applications/Python n.n``. +functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. It should also be tested from the command line:: /usr/local/bin/idlen.n diff -r ce070040e1a6 -r d7f128afe9db Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py Sat May 10 13:24:58 2014 -0400 +++ b/Mac/BuildScript/build-installer.py Sun Mar 23 09:44:28 2014 +0100 @@ -8,9 +8,7 @@ Please ensure that this script keeps working with Python 2.5, to avoid bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5). Sphinx, which is used to build the documentation, currently requires at least -Python 2.4. However, as of Python 3.4.1, Doc builds require an external -sphinx-build and the current versions of Sphinx now require at least -Python 2.6. +Python 2.4. In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script requires an installed version of hg and a third-party version of @@ -23,8 +21,8 @@ 32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 and the installation of additional components, such as a newer Python -(2.5 is needed for Python parser updates), hg, and for the documentation -build either svn (pre-3.4.1) or sphinx-build (3.4.1 and later). +(2.5 is needed for Python parser updates), hg, and svn (for the documentation +build). Usage: see USAGE variable in the script. """ @@ -196,7 +194,7 @@ LT_10_5 = bool(DEPTARGET < '10.5') # Disable for now - if False: # if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 5)): + if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 5)): result.extend([ dict( name="Tcl 8.5.15", @@ -367,8 +365,7 @@ # Instructions for building packages inside the .mpkg. def pkg_recipes(): unselected_for_python3 = ('selected', 'unselected')[PYTHON_3] - # unselected if 3.0 through 3.3, selected otherwise (2.x or >= 3.4) - unselected_for_lt_python34 = ('selected', 'unselected')[(3, 0) <= getVersionTuple() < (3, 4)] + unselected_for_lt_python34 = ('selected', 'unselected')[getVersionTuple() < (3, 4)] result = [ dict( name="PythonFramework", @@ -610,11 +607,7 @@ base_path = base_path + ':' + OLD_DEVELOPER_TOOLS os.environ['PATH'] = base_path print("Setting default PATH: %s"%(os.environ['PATH'])) - # Ensure ws have access to hg and to sphinx-build. - # You may have to create links in /usr/bin for them. - runCommand('hg --version') - if getVersionTuple() >= (3, 4): - runCommand('sphinx-build --version') + def parseOptions(args=None): """ @@ -867,7 +860,7 @@ ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-mmacosx-version-min=%s -isysroot %s -L%s/usr/local/lib -arch %s"%( + "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%( DEPTARGET, shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], @@ -927,15 +920,8 @@ docdir = os.path.join(rootDir, 'pydocs') curDir = os.getcwd() os.chdir(buildDir) - # The Doc build changed for 3.4 (technically, for 3.4.1) - if getVersionTuple() < (3, 4): - # This step does an svn checkout of sphinx and its dependencies - runCommand('make update') - runCommand("make html PYTHON='%s'" % os.path.abspath(sys.executable)) - else: - runCommand('make clean') - # Assume sphinx-build is on our PATH, checked in checkEnvironment - runCommand('make html') + runCommand('make update') + runCommand("make html PYTHON='%s'" % os.path.abspath(sys.executable)) os.chdir(curDir) if not os.path.exists(docdir): os.mkdir(docdir) diff -r ce070040e1a6 -r d7f128afe9db Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in Sat May 10 13:24:58 2014 -0400 +++ b/Mac/PythonLauncher/Info.plist.in Sun Mar 23 09:44:28 2014 +0100 @@ -1,5 +1,5 @@ - + CFBundleDevelopmentRegion @@ -38,7 +38,7 @@ CFBundleExecutable - Python Launcher + PythonLauncher CFBundleGetInfoString %VERSION%, © 2001-2014 Python Software Foundation CFBundleIconFile diff -r ce070040e1a6 -r d7f128afe9db Mac/PythonLauncher/Makefile.in --- a/Mac/PythonLauncher/Makefile.in Sat May 10 13:24:58 2014 -0400 +++ b/Mac/PythonLauncher/Makefile.in Sun Mar 23 09:44:28 2014 +0100 @@ -15,10 +15,12 @@ PYTHONFRAMEWORK=@PYTHONFRAMEWORK@ # Deployment target selected during configure, to be checked -# by distutils +# by distutils MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ @EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET +BUNDLEBULDER=$(srcdir)/../Tools/bundlebuilder.py + PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION) OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o @@ -28,10 +30,10 @@ /bin/cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)" touch "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" + clean: rm -f *.o "Python Launcher" rm -rf "Python Launcher.app" - rm -f Info.plist Python\ Launcher.app: Info.plist \ Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \ @@ -39,18 +41,20 @@ $(srcdir)/../Icons/PythonCompiled.icns \ $(srcdir)/factorySettings.plist rm -fr "Python Launcher.app" - mkdir "Python Launcher.app" - mkdir "Python Launcher.app/Contents" - mkdir "Python Launcher.app/Contents/MacOS" - mkdir "Python Launcher.app/Contents/Resources" - cp "Python Launcher" "Python Launcher.app/Contents/MacOS" - cp Info.plist "Python Launcher.app/Contents" - cp $(srcdir)/../Icons/PythonLauncher.icns "Python Launcher.app/Contents/Resources" - cp $(srcdir)/../Icons/PythonSource.icns "Python Launcher.app/Contents/Resources" - cp $(srcdir)/../Icons/PythonCompiled.icns "Python Launcher.app/Contents/Resources" - cp $(srcdir)/factorySettings.plist "Python Launcher.app/Contents/Resources" - cp -R $(srcdir)/English.lproj "Python Launcher.app/Contents/Resources" + $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \ + --builddir=. \ + --name="Python Launcher" \ + --executable="Python Launcher" \ + --iconfile=$(srcdir)/../Icons/PythonLauncher.icns \ + --bundle-id=org.python.PythonLauncher \ + --resource=$(srcdir)/../Icons/PythonSource.icns \ + --resource=$(srcdir)/../Icons/PythonCompiled.icns \ + --resource=$(srcdir)/English.lproj \ + --resource=$(srcdir)/factorySettings.plist \ + --plist Info.plist \ + build find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r + FileSettings.o: $(srcdir)/FileSettings.m $(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m diff -r ce070040e1a6 -r d7f128afe9db Mac/Tools/bundlebuilder.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mac/Tools/bundlebuilder.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,934 @@ +#! /usr/bin/env python + +"""\ +bundlebuilder.py -- Tools to assemble MacOS X (application) bundles. + +This module contains two classes to build so called "bundles" for +MacOS X. BundleBuilder is a general tool, AppBuilder is a subclass +specialized in building application bundles. + +[Bundle|App]Builder objects are instantiated with a bunch of keyword +arguments, and have a build() method that will do all the work. See +the class doc strings for a description of the constructor arguments. + +The module contains a main program that can be used in two ways: + + % python bundlebuilder.py [options] build + % python buildapp.py [options] build + +Where "buildapp.py" is a user-supplied setup.py-like script following +this model: + + from bundlebuilder import buildapp + buildapp() + +""" + + +__all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"] + + +import sys +import os, errno, shutil +import imp, marshal +import re +from copy import deepcopy +import getopt +from plistlib import Plist +from types import FunctionType as function + +class BundleBuilderError(Exception): pass + + +class Defaults: + + """Class attributes that don't start with an underscore and are + not functions or classmethods are (deep)copied to self.__dict__. + This allows for mutable default values. + """ + + def __init__(self, **kwargs): + defaults = self._getDefaults() + defaults.update(kwargs) + self.__dict__.update(defaults) + + def _getDefaults(cls): + defaults = {} + for base in cls.__bases__: + if hasattr(base, "_getDefaults"): + defaults.update(base._getDefaults()) + for name, value in list(cls.__dict__.items()): + if name[0] != "_" and not isinstance(value, + (function, classmethod)): + defaults[name] = deepcopy(value) + return defaults + _getDefaults = classmethod(_getDefaults) + + +class BundleBuilder(Defaults): + + """BundleBuilder is a barebones class for assembling bundles. It + knows nothing about executables or icons, it only copies files + and creates the PkgInfo and Info.plist files. + """ + + # (Note that Defaults.__init__ (deep)copies these values to + # instance variables. Mutable defaults are therefore safe.) + + # Name of the bundle, with or without extension. + name = None + + # The property list ("plist") + plist = Plist(CFBundleDevelopmentRegion = "English", + CFBundleInfoDictionaryVersion = "6.0") + + # The type of the bundle. + type = "BNDL" + # The creator code of the bundle. + creator = None + + # the CFBundleIdentifier (this is used for the preferences file name) + bundle_id = None + + # List of files that have to be copied to /Contents/Resources. + resources = [] + + # List of (src, dest) tuples; dest should be a path relative to the bundle + # (eg. "Contents/Resources/MyStuff/SomeFile.ext). + files = [] + + # List of shared libraries (dylibs, Frameworks) to bundle with the app + # will be placed in Contents/Frameworks + libs = [] + + # Directory where the bundle will be assembled. + builddir = "build" + + # Make symlinks instead copying files. This is handy during debugging, but + # makes the bundle non-distributable. + symlink = 0 + + # Verbosity level. + verbosity = 1 + + # Destination root directory + destroot = "" + + def setup(self): + # XXX rethink self.name munging, this is brittle. + self.name, ext = os.path.splitext(self.name) + if not ext: + ext = ".bundle" + bundleextension = ext + # misc (derived) attributes + self.bundlepath = pathjoin(self.builddir, self.name + bundleextension) + + plist = self.plist + plist.CFBundleName = self.name + plist.CFBundlePackageType = self.type + if self.creator is None: + if hasattr(plist, "CFBundleSignature"): + self.creator = plist.CFBundleSignature + else: + self.creator = "????" + plist.CFBundleSignature = self.creator + if self.bundle_id: + plist.CFBundleIdentifier = self.bundle_id + elif not hasattr(plist, "CFBundleIdentifier"): + plist.CFBundleIdentifier = self.name + + def build(self): + """Build the bundle.""" + builddir = self.builddir + if builddir and not os.path.exists(builddir): + os.mkdir(builddir) + self.message("Building %s" % repr(self.bundlepath), 1) + if os.path.exists(self.bundlepath): + shutil.rmtree(self.bundlepath) + if os.path.exists(self.bundlepath + '~'): + shutil.rmtree(self.bundlepath + '~') + bp = self.bundlepath + + # Create the app bundle in a temporary location and then + # rename the completed bundle. This way the Finder will + # never see an incomplete bundle (where it might pick up + # and cache the wrong meta data) + self.bundlepath = bp + '~' + try: + os.mkdir(self.bundlepath) + self.preProcess() + self._copyFiles() + self._addMetaFiles() + self.postProcess() + os.rename(self.bundlepath, bp) + finally: + self.bundlepath = bp + self.message("Done.", 1) + + def preProcess(self): + """Hook for subclasses.""" + pass + def postProcess(self): + """Hook for subclasses.""" + pass + + def _addMetaFiles(self): + contents = pathjoin(self.bundlepath, "Contents") + makedirs(contents) + # + # Write Contents/PkgInfo + assert len(self.type) == len(self.creator) == 4, \ + "type and creator must be 4-byte strings." + pkginfo = pathjoin(contents, "PkgInfo") + f = open(pkginfo, "wb") + f.write((self.type + self.creator).encode('latin1')) + f.close() + # + # Write Contents/Info.plist + infoplist = pathjoin(contents, "Info.plist") + self.plist.write(infoplist) + + def _copyFiles(self): + files = self.files[:] + for path in self.resources: + files.append((path, pathjoin("Contents", "Resources", + os.path.basename(path)))) + for path in self.libs: + files.append((path, pathjoin("Contents", "Frameworks", + os.path.basename(path)))) + if self.symlink: + self.message("Making symbolic links", 1) + msg = "Making symlink from" + else: + self.message("Copying files", 1) + msg = "Copying" + files.sort() + for src, dst in files: + if os.path.isdir(src): + self.message("%s %s/ to %s/" % (msg, src, dst), 2) + else: + self.message("%s %s to %s" % (msg, src, dst), 2) + dst = pathjoin(self.bundlepath, dst) + if self.symlink: + symlink(src, dst, mkdirs=1) + else: + copy(src, dst, mkdirs=1) + + def message(self, msg, level=0): + if level <= self.verbosity: + indent = "" + if level > 1: + indent = (level - 1) * " " + sys.stderr.write(indent + msg + "\n") + + def report(self): + # XXX something decent + pass + + +if __debug__: + PYC_EXT = ".pyc" +else: + PYC_EXT = ".pyo" + +MAGIC = imp.get_magic() +USE_ZIPIMPORT = "zipimport" in sys.builtin_module_names + +# For standalone apps, we have our own minimal site.py. We don't need +# all the cruft of the real site.py. +SITE_PY = """\ +import sys +if not %(semi_standalone)s: + del sys.path[1:] # sys.path[0] is Contents/Resources/ +""" + +if USE_ZIPIMPORT: + ZIP_ARCHIVE = "Modules.zip" + SITE_PY += "sys.path.append(sys.path[0] + '/%s')\n" % ZIP_ARCHIVE + def getPycData(fullname, code, ispkg): + if ispkg: + fullname += ".__init__" + path = fullname.replace(".", os.sep) + PYC_EXT + return path, MAGIC + '\0\0\0\0' + marshal.dumps(code) + +# +# Extension modules can't be in the modules zip archive, so a placeholder +# is added instead, that loads the extension from a specified location. +# +EXT_LOADER = """\ +def __load(): + import imp, sys, os + for p in sys.path: + path = os.path.join(p, "%(filename)s") + if os.path.exists(path): + break + else: + assert 0, "file not found: %(filename)s" + mod = imp.load_dynamic("%(name)s", path) + +__load() +del __load +""" + +MAYMISS_MODULES = ['mac', 'nt', 'ntpath', 'dos', 'dospath', + 'win32api', 'ce', '_winreg', 'nturl2path', 'sitecustomize', + 'org.python.core', 'riscos', 'riscosenviron', 'riscospath' +] + +STRIP_EXEC = "/usr/bin/strip" + +# +# We're using a stock interpreter to run the app, yet we need +# a way to pass the Python main program to the interpreter. The +# bootstrapping script fires up the interpreter with the right +# arguments. os.execve() is used as OSX doesn't like us to +# start a real new process. Also, the executable name must match +# the CFBundleExecutable value in the Info.plist, so we lie +# deliberately with argv[0]. The actual Python executable is +# passed in an environment variable so we can "repair" +# sys.executable later. +# +BOOTSTRAP_SCRIPT = """\ +#!%(hashbang)s + +import sys, os +execdir = os.path.dirname(sys.argv[0]) +executable = os.path.join(execdir, "%(executable)s") +resdir = os.path.join(os.path.dirname(execdir), "Resources") +libdir = os.path.join(os.path.dirname(execdir), "Frameworks") +mainprogram = os.path.join(resdir, "%(mainprogram)s") + +sys.argv.insert(1, mainprogram) +if %(standalone)s or %(semi_standalone)s: + os.environ["PYTHONPATH"] = resdir + if %(standalone)s: + os.environ["PYTHONHOME"] = resdir +else: + pypath = os.getenv("PYTHONPATH", "") + if pypath: + pypath = ":" + pypath + os.environ["PYTHONPATH"] = resdir + pypath +os.environ["PYTHONEXECUTABLE"] = executable +os.environ["DYLD_LIBRARY_PATH"] = libdir +os.environ["DYLD_FRAMEWORK_PATH"] = libdir +os.execve(executable, sys.argv, os.environ) +""" + + +# +# Optional wrapper that converts "dropped files" into sys.argv values. +# +ARGV_EMULATOR = """\ +import argvemulator, os + +argvemulator.ArgvCollector().mainloop() +execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s")) +""" + +# +# When building a standalone app with Python.framework, we need to copy +# a subset from Python.framework to the bundle. The following list +# specifies exactly what items we'll copy. +# +PYTHONFRAMEWORKGOODIES = [ + "Python", # the Python core library + "Resources/English.lproj", + "Resources/Info.plist", + "Resources/version.plist", +] + +def isFramework(): + return sys.exec_prefix.find("Python.framework") > 0 + + +LIB = os.path.join(sys.prefix, "lib", "python" + sys.version[:3]) +SITE_PACKAGES = os.path.join(LIB, "site-packages") + + +class AppBuilder(BundleBuilder): + + # Override type of the bundle. + type = "APPL" + + # platform, name of the subfolder of Contents that contains the executable. + platform = "MacOS" + + # A Python main program. If this argument is given, the main + # executable in the bundle will be a small wrapper that invokes + # the main program. (XXX Discuss why.) + mainprogram = None + + # The main executable. If a Python main program is specified + # the executable will be copied to Resources and be invoked + # by the wrapper program mentioned above. Otherwise it will + # simply be used as the main executable. + executable = None + + # The name of the main nib, for Cocoa apps. *Must* be specified + # when building a Cocoa app. + nibname = None + + # The name of the icon file to be copied to Resources and used for + # the Finder icon. + iconfile = None + + # Symlink the executable instead of copying it. + symlink_exec = 0 + + # If True, build standalone app. + standalone = 0 + + # If True, build semi-standalone app (only includes third-party modules). + semi_standalone = 0 + + # If set, use this for #! lines in stead of sys.executable + python = None + + # If True, add a real main program that emulates sys.argv before calling + # mainprogram + argv_emulation = 0 + + # The following attributes are only used when building a standalone app. + + # Exclude these modules. + excludeModules = [] + + # Include these modules. + includeModules = [] + + # Include these packages. + includePackages = [] + + # Strip binaries from debug info. + strip = 0 + + # Found Python modules: [(name, codeobject, ispkg), ...] + pymodules = [] + + # Modules that modulefinder couldn't find: + missingModules = [] + maybeMissingModules = [] + + def setup(self): + if ((self.standalone or self.semi_standalone) + and self.mainprogram is None): + raise BundleBuilderError("must specify 'mainprogram' when " + "building a standalone application.") + if self.mainprogram is None and self.executable is None: + raise BundleBuilderError("must specify either or both of " + "'executable' and 'mainprogram'") + + self.execdir = pathjoin("Contents", self.platform) + + if self.name is not None: + pass + elif self.mainprogram is not None: + self.name = os.path.splitext(os.path.basename(self.mainprogram))[0] + elif executable is not None: + self.name = os.path.splitext(os.path.basename(self.executable))[0] + if self.name[-4:] != ".app": + self.name += ".app" + + if self.executable is None: + if not self.standalone and not isFramework(): + self.symlink_exec = 1 + if self.python: + self.executable = self.python + else: + self.executable = sys.executable + + if self.nibname: + self.plist.NSMainNibFile = self.nibname + if not hasattr(self.plist, "NSPrincipalClass"): + self.plist.NSPrincipalClass = "NSApplication" + + if self.standalone and isFramework(): + self.addPythonFramework() + + BundleBuilder.setup(self) + + self.plist.CFBundleExecutable = self.name + + if self.standalone or self.semi_standalone: + self.findDependencies() + + def preProcess(self): + resdir = "Contents/Resources" + if self.executable is not None: + if self.mainprogram is None: + execname = self.name + else: + execname = os.path.basename(self.executable) + execpath = pathjoin(self.execdir, execname) + if not self.symlink_exec: + self.files.append((self.destroot + self.executable, execpath)) + self.execpath = execpath + + if self.mainprogram is not None: + mainprogram = os.path.basename(self.mainprogram) + self.files.append((self.mainprogram, pathjoin(resdir, mainprogram))) + if self.argv_emulation: + # Change the main program, and create the helper main program (which + # does argv collection and then calls the real main). + # Also update the included modules (if we're creating a standalone + # program) and the plist + realmainprogram = mainprogram + mainprogram = '__argvemulator_' + mainprogram + resdirpath = pathjoin(self.bundlepath, resdir) + mainprogrampath = pathjoin(resdirpath, mainprogram) + makedirs(resdirpath) + open(mainprogrampath, "w").write(ARGV_EMULATOR % locals()) + if self.standalone or self.semi_standalone: + self.includeModules.append("argvemulator") + self.includeModules.append("os") + if "CFBundleDocumentTypes" not in self.plist: + self.plist["CFBundleDocumentTypes"] = [ + { "CFBundleTypeOSTypes" : [ + "****", + "fold", + "disk"], + "CFBundleTypeRole": "Viewer"}] + # Write bootstrap script + executable = os.path.basename(self.executable) + execdir = pathjoin(self.bundlepath, self.execdir) + bootstrappath = pathjoin(execdir, self.name) + makedirs(execdir) + if self.standalone or self.semi_standalone: + # XXX we're screwed when the end user has deleted + # /usr/bin/python + hashbang = "/usr/bin/python" + elif self.python: + hashbang = self.python + else: + hashbang = os.path.realpath(sys.executable) + standalone = self.standalone + semi_standalone = self.semi_standalone + open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals()) + os.chmod(bootstrappath, 0o775) + + if self.iconfile is not None: + iconbase = os.path.basename(self.iconfile) + self.plist.CFBundleIconFile = iconbase + self.files.append((self.iconfile, pathjoin(resdir, iconbase))) + + def postProcess(self): + if self.standalone or self.semi_standalone: + self.addPythonModules() + if self.strip and not self.symlink: + self.stripBinaries() + + if self.symlink_exec and self.executable: + self.message("Symlinking executable %s to %s" % (self.executable, + self.execpath), 2) + dst = pathjoin(self.bundlepath, self.execpath) + makedirs(os.path.dirname(dst)) + os.symlink(os.path.abspath(self.executable), dst) + + if self.missingModules or self.maybeMissingModules: + self.reportMissing() + + def addPythonFramework(self): + # If we're building a standalone app with Python.framework, + # include a minimal subset of Python.framework, *unless* + # Python.framework was specified manually in self.libs. + for lib in self.libs: + if os.path.basename(lib) == "Python.framework": + # a Python.framework was specified as a library + return + + frameworkpath = sys.exec_prefix[:sys.exec_prefix.find( + "Python.framework") + len("Python.framework")] + + version = sys.version[:3] + frameworkpath = pathjoin(frameworkpath, "Versions", version) + destbase = pathjoin("Contents", "Frameworks", "Python.framework", + "Versions", version) + for item in PYTHONFRAMEWORKGOODIES: + src = pathjoin(frameworkpath, item) + dst = pathjoin(destbase, item) + self.files.append((src, dst)) + + def _getSiteCode(self): + return compile(SITE_PY % {"semi_standalone": self.semi_standalone}, + "<-bundlebuilder.py->", "exec") + + def addPythonModules(self): + self.message("Adding Python modules", 1) + + if USE_ZIPIMPORT: + # Create a zip file containing all modules as pyc. + import zipfile + relpath = pathjoin("Contents", "Resources", ZIP_ARCHIVE) + abspath = pathjoin(self.bundlepath, relpath) + zf = zipfile.ZipFile(abspath, "w", zipfile.ZIP_DEFLATED) + for name, code, ispkg in self.pymodules: + self.message("Adding Python module %s" % name, 2) + path, pyc = getPycData(name, code, ispkg) + zf.writestr(path, pyc) + zf.close() + # add site.pyc + sitepath = pathjoin(self.bundlepath, "Contents", "Resources", + "site" + PYC_EXT) + writePyc(self._getSiteCode(), sitepath) + else: + # Create individual .pyc files. + for name, code, ispkg in self.pymodules: + if ispkg: + name += ".__init__" + path = name.split(".") + path = pathjoin("Contents", "Resources", *path) + PYC_EXT + + if ispkg: + self.message("Adding Python package %s" % path, 2) + else: + self.message("Adding Python module %s" % path, 2) + + abspath = pathjoin(self.bundlepath, path) + makedirs(os.path.dirname(abspath)) + writePyc(code, abspath) + + def stripBinaries(self): + if not os.path.exists(STRIP_EXEC): + self.message("Error: can't strip binaries: no strip program at " + "%s" % STRIP_EXEC, 0) + else: + import stat + self.message("Stripping binaries", 1) + def walk(top): + for name in os.listdir(top): + path = pathjoin(top, name) + if os.path.islink(path): + continue + if os.path.isdir(path): + walk(path) + else: + mod = os.stat(path)[stat.ST_MODE] + if not (mod & 0o100): + continue + relpath = path[len(self.bundlepath):] + self.message("Stripping %s" % relpath, 2) + inf, outf = os.popen4("%s -S \"%s\"" % + (STRIP_EXEC, path)) + output = outf.read().strip() + if output: + # usually not a real problem, like when we're + # trying to strip a script + self.message("Problem stripping %s:" % relpath, 3) + self.message(output, 3) + walk(self.bundlepath) + + def findDependencies(self): + self.message("Finding module dependencies", 1) + import modulefinder + mf = modulefinder.ModuleFinder(excludes=self.excludeModules) + if USE_ZIPIMPORT: + # zipimport imports zlib, must add it manually + mf.import_hook("zlib") + # manually add our own site.py + site = mf.add_module("site") + site.__code__ = self._getSiteCode() + mf.scan_code(site.__code__, site) + + # warnings.py gets imported implicitly from C + mf.import_hook("warnings") + + includeModules = self.includeModules[:] + for name in self.includePackages: + includeModules.extend(list(findPackageContents(name).keys())) + for name in includeModules: + try: + mf.import_hook(name) + except ImportError: + self.missingModules.append(name) + + mf.run_script(self.mainprogram) + modules = list(mf.modules.items()) + modules.sort() + for name, mod in modules: + path = mod.__file__ + if path and self.semi_standalone: + # skip the standard library + if path.startswith(LIB) and not path.startswith(SITE_PACKAGES): + continue + if path and mod.__code__ is None: + # C extension + filename = os.path.basename(path) + pathitems = name.split(".")[:-1] + [filename] + dstpath = pathjoin(*pathitems) + if USE_ZIPIMPORT: + if name != "zlib": + # neatly pack all extension modules in a subdirectory, + # except zlib, since it's necessary for bootstrapping. + dstpath = pathjoin("ExtensionModules", dstpath) + # Python modules are stored in a Zip archive, but put + # extensions in Contents/Resources/. Add a tiny "loader" + # program in the Zip archive. Due to Thomas Heller. + source = EXT_LOADER % {"name": name, "filename": dstpath} + code = compile(source, "" % name, "exec") + mod.__code__ = code + self.files.append((path, pathjoin("Contents", "Resources", dstpath))) + if mod.__code__ is not None: + ispkg = mod.__path__ is not None + if not USE_ZIPIMPORT or name != "site": + # Our site.py is doing the bootstrapping, so we must + # include a real .pyc file if USE_ZIPIMPORT is True. + self.pymodules.append((name, mod.__code__, ispkg)) + + if hasattr(mf, "any_missing_maybe"): + missing, maybe = mf.any_missing_maybe() + else: + missing = mf.any_missing() + maybe = [] + self.missingModules.extend(missing) + self.maybeMissingModules.extend(maybe) + + def reportMissing(self): + missing = [name for name in self.missingModules + if name not in MAYMISS_MODULES] + if self.maybeMissingModules: + maybe = self.maybeMissingModules + else: + maybe = [name for name in missing if "." in name] + missing = [name for name in missing if "." not in name] + missing.sort() + maybe.sort() + if maybe: + self.message("Warning: couldn't find the following submodules:", 1) + self.message(" (Note that these could be false alarms -- " + "it's not always", 1) + self.message(" possible to distinguish between \"from package " + "import submodule\" ", 1) + self.message(" and \"from package import name\")", 1) + for name in maybe: + self.message(" ? " + name, 1) + if missing: + self.message("Warning: couldn't find the following modules:", 1) + for name in missing: + self.message(" ? " + name, 1) + + def report(self): + # XXX something decent + import pprint + pprint.pprint(self.__dict__) + if self.standalone or self.semi_standalone: + self.reportMissing() + +# +# Utilities. +# + +SUFFIXES = [_suf for _suf, _mode, _tp in imp.get_suffixes()] +identifierRE = re.compile(r"[_a-zA-z][_a-zA-Z0-9]*$") + +def findPackageContents(name, searchpath=None): + head = name.split(".")[-1] + if identifierRE.match(head) is None: + return {} + try: + fp, path, (ext, mode, tp) = imp.find_module(head, searchpath) + except ImportError: + return {} + modules = {name: None} + if tp == imp.PKG_DIRECTORY and path: + files = os.listdir(path) + for sub in files: + sub, ext = os.path.splitext(sub) + fullname = name + "." + sub + if sub != "__init__" and fullname not in modules: + modules.update(findPackageContents(fullname, [path])) + return modules + +def writePyc(code, path): + f = open(path, "wb") + f.write(MAGIC) + f.write("\0" * 4) # don't bother about a time stamp + marshal.dump(code, f) + f.close() + +def copy(src, dst, mkdirs=0): + """Copy a file or a directory.""" + if mkdirs: + makedirs(os.path.dirname(dst)) + if os.path.isdir(src): + shutil.copytree(src, dst, symlinks=1) + else: + shutil.copy2(src, dst) + +def copytodir(src, dstdir): + """Copy a file or a directory to an existing directory.""" + dst = pathjoin(dstdir, os.path.basename(src)) + copy(src, dst) + +def makedirs(dir): + """Make all directories leading up to 'dir' including the leaf + directory. Don't moan if any path element already exists.""" + try: + os.makedirs(dir) + except OSError as why: + if why.errno != errno.EEXIST: + raise + +def symlink(src, dst, mkdirs=0): + """Copy a file or a directory.""" + if not os.path.exists(src): + raise IOError("No such file or directory: '%s'" % src) + if mkdirs: + makedirs(os.path.dirname(dst)) + os.symlink(os.path.abspath(src), dst) + +def pathjoin(*args): + """Safe wrapper for os.path.join: asserts that all but the first + argument are relative paths.""" + for seg in args[1:]: + assert seg[0] != "/" + return os.path.join(*args) + + +cmdline_doc = """\ +Usage: + python bundlebuilder.py [options] command + python mybuildscript.py [options] command + +Commands: + build build the application + report print a report + +Options: + -b, --builddir=DIR the build directory; defaults to "build" + -n, --name=NAME application name + -r, --resource=FILE extra file or folder to be copied to Resources + -f, --file=SRC:DST extra file or folder to be copied into the bundle; + DST must be a path relative to the bundle root + -e, --executable=FILE the executable to be used + -m, --mainprogram=FILE the Python main program + -a, --argv add a wrapper main program to create sys.argv + -p, --plist=FILE .plist file (default: generate one) + --nib=NAME main nib name + -c, --creator=CCCC 4-char creator code (default: '????') + --iconfile=FILE filename of the icon (an .icns file) to be used + as the Finder icon + --bundle-id=ID the CFBundleIdentifier, in reverse-dns format + (eg. org.python.BuildApplet; this is used for + the preferences file name) + -l, --link symlink files/folder instead of copying them + --link-exec symlink the executable instead of copying it + --standalone build a standalone application, which is fully + independent of a Python installation + --semi-standalone build a standalone application, which depends on + an installed Python, yet includes all third-party + modules. + --python=FILE Python to use in #! line in stead of current Python + --lib=FILE shared library or framework to be copied into + the bundle + -x, --exclude=MODULE exclude module (with --(semi-)standalone) + -i, --include=MODULE include module (with --(semi-)standalone) + --package=PACKAGE include a whole package (with --(semi-)standalone) + --strip strip binaries (remove debug info) + -v, --verbose increase verbosity level + -q, --quiet decrease verbosity level + -h, --help print this message +""" + +def usage(msg=None): + if msg: + print(msg) + print(cmdline_doc) + sys.exit(1) + +def main(builder=None): + if builder is None: + builder = AppBuilder(verbosity=1) + + shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa" + longopts = ("builddir=", "name=", "resource=", "file=", "executable=", + "mainprogram=", "creator=", "nib=", "plist=", "link", + "link-exec", "help", "verbose", "quiet", "argv", "standalone", + "exclude=", "include=", "package=", "strip", "iconfile=", + "lib=", "python=", "semi-standalone", "bundle-id=", "destroot=") + + try: + options, args = getopt.getopt(sys.argv[1:], shortopts, longopts) + except getopt.error: + usage() + + for opt, arg in options: + if opt in ('-b', '--builddir'): + builder.builddir = arg + elif opt in ('-n', '--name'): + builder.name = arg + elif opt in ('-r', '--resource'): + builder.resources.append(os.path.normpath(arg)) + elif opt in ('-f', '--file'): + srcdst = arg.split(':') + if len(srcdst) != 2: + usage("-f or --file argument must be two paths, " + "separated by a colon") + builder.files.append(srcdst) + elif opt in ('-e', '--executable'): + builder.executable = arg + elif opt in ('-m', '--mainprogram'): + builder.mainprogram = arg + elif opt in ('-a', '--argv'): + builder.argv_emulation = 1 + elif opt in ('-c', '--creator'): + builder.creator = arg + elif opt == '--bundle-id': + builder.bundle_id = arg + elif opt == '--iconfile': + builder.iconfile = arg + elif opt == "--lib": + builder.libs.append(os.path.normpath(arg)) + elif opt == "--nib": + builder.nibname = arg + elif opt in ('-p', '--plist'): + builder.plist = Plist.fromFile(arg) + elif opt in ('-l', '--link'): + builder.symlink = 1 + elif opt == '--link-exec': + builder.symlink_exec = 1 + elif opt in ('-h', '--help'): + usage() + elif opt in ('-v', '--verbose'): + builder.verbosity += 1 + elif opt in ('-q', '--quiet'): + builder.verbosity -= 1 + elif opt == '--standalone': + builder.standalone = 1 + elif opt == '--semi-standalone': + builder.semi_standalone = 1 + elif opt == '--python': + builder.python = arg + elif opt in ('-x', '--exclude'): + builder.excludeModules.append(arg) + elif opt in ('-i', '--include'): + builder.includeModules.append(arg) + elif opt == '--package': + builder.includePackages.append(arg) + elif opt == '--strip': + builder.strip = 1 + elif opt == '--destroot': + builder.destroot = arg + + if len(args) != 1: + usage("Must specify one command ('build', 'report' or 'help')") + command = args[0] + + if command == "build": + builder.setup() + builder.build() + elif command == "report": + builder.setup() + builder.report() + elif command == "help": + usage() + else: + usage("Unknown command '%s'" % command) + + +def buildapp(**kwargs): + builder = AppBuilder(**kwargs) + main(builder) + + +if __name__ == "__main__": + main() diff -r ce070040e1a6 -r d7f128afe9db Makefile.pre.in --- a/Makefile.pre.in Sat May 10 13:24:58 2014 -0400 +++ b/Makefile.pre.in Sun Mar 23 09:44:28 2014 +0100 @@ -323,13 +323,6 @@ PGENOBJS= $(POBJS) $(PGOBJS) ########################################################################## -# opcode.h generation -OPCODE_H_DIR= $(srcdir)/Include -OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py -OPCODE_H= $(OPCODE_H_DIR)/opcode.h -OPCODE_H_GEN= @OPCODEHGEN@ $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H) -# -########################################################################## # AST AST_H_DIR= Include AST_H= $(AST_H_DIR)/Python-ast.h @@ -767,9 +760,6 @@ $(MKDIR_P) $(AST_C_DIR) $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL) -$(OPCODE_H): $(srcdir)/Lib/opcode.py $(OPCODE_H_SCRIPT) - $(OPCODE_H_GEN) - Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H) Python/getplatform.o: $(srcdir)/Python/getplatform.c @@ -881,7 +871,7 @@ $(srcdir)/Include/node.h \ $(srcdir)/Include/object.h \ $(srcdir)/Include/objimpl.h \ - $(OPCODE_H) \ + $(srcdir)/Include/opcode.h \ $(srcdir)/Include/osdefs.h \ $(srcdir)/Include/patchlevel.h \ $(srcdir)/Include/pgen.h \ @@ -1129,26 +1119,26 @@ test/imghdrdata \ test/subprocessdata test/sndhdrdata test/support \ test/tracedmodules test/encoded_modules \ - test/test_importlib/namespace_pkgs \ - test/test_importlib/namespace_pkgs/both_portions \ - test/test_importlib/namespace_pkgs/both_portions/foo \ - test/test_importlib/namespace_pkgs/not_a_namespace_pkg \ - test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo \ - test/test_importlib/namespace_pkgs/portion1 \ - test/test_importlib/namespace_pkgs/portion1/foo \ - test/test_importlib/namespace_pkgs/portion2 \ - test/test_importlib/namespace_pkgs/portion2/foo \ - test/test_importlib/namespace_pkgs/project1 \ - test/test_importlib/namespace_pkgs/project1/parent \ - test/test_importlib/namespace_pkgs/project1/parent/child \ - test/test_importlib/namespace_pkgs/project2 \ - test/test_importlib/namespace_pkgs/project2/parent \ - test/test_importlib/namespace_pkgs/project2/parent/child \ - test/test_importlib/namespace_pkgs/project3 \ - test/test_importlib/namespace_pkgs/project3/parent \ - test/test_importlib/namespace_pkgs/project3/parent/child \ - test/test_importlib/namespace_pkgs/module_and_namespace_package \ - test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \ + test/namespace_pkgs \ + test/namespace_pkgs/both_portions \ + test/namespace_pkgs/both_portions/foo \ + test/namespace_pkgs/not_a_namespace_pkg \ + test/namespace_pkgs/not_a_namespace_pkg/foo \ + test/namespace_pkgs/portion1 \ + test/namespace_pkgs/portion1/foo \ + test/namespace_pkgs/portion2 \ + test/namespace_pkgs/portion2/foo \ + test/namespace_pkgs/project1 \ + test/namespace_pkgs/project1/parent \ + test/namespace_pkgs/project1/parent/child \ + test/namespace_pkgs/project2 \ + test/namespace_pkgs/project2/parent \ + test/namespace_pkgs/project2/parent/child \ + test/namespace_pkgs/project3 \ + test/namespace_pkgs/project3/parent \ + test/namespace_pkgs/project3/parent/child \ + test/namespace_pkgs/module_and_namespace_package \ + test/namespace_pkgs/module_and_namespace_package/a_test \ asyncio \ test/test_asyncio \ collections concurrent concurrent/futures encodings \ diff -r ce070040e1a6 -r d7f128afe9db Misc/ACKS --- a/Misc/ACKS Sat May 10 13:24:58 2014 -0400 +++ b/Misc/ACKS Sun Mar 23 09:44:28 2014 +0100 @@ -17,14 +17,11 @@ David Abrahams Marc Abramowitz Ron Adam -Anton Afanasyev Ali Afshar -Nitika Agarwal Jim Ahlstrom Farhan Ahmad Matthew Ahrens Nir Aides -Akira Yaniv Aknin Jyrki Alakuijala Steve Alexander @@ -99,7 +96,6 @@ Robin Becker Torsten Becker Bill Bedford -Ian Beer Stefan Behnel Reimer Behrends Ben Bell @@ -470,7 +466,6 @@ Shelley Gooch David Goodger Hans de Graaff -Kim Gräsman Nathaniel Gray Eddy De Greef Grant Griffin @@ -615,7 +610,6 @@ Rajagopalasarma Jayakrishnan Zbigniew Jędrzejewski-Szmek Julien Jehannet -Muhammad Jehanzeb Drew Jenkins Flemming Kjær Jensen Philip H. Jensen @@ -635,7 +629,6 @@ Nicolas Joly Brian K. Jones Evan Jones -Glenn Jones Jeremy Jones Richard Jones Irmen de Jong @@ -748,7 +741,6 @@ Chris Lawrence Brian Leair Mathieu Leduc-Hamel -Antony Lee Christopher Lee Inyeol Lee James Lee @@ -850,7 +842,6 @@ Lucas Maystre Arnaud Mazin Matt McClure -Jack McCracken Rebecca McCreary Kirk McDonald Chris McDonough @@ -1119,7 +1110,6 @@ Case Roole Timothy Roscoe Erik Rose -Josh Rosenberg Jim Roskind Brian Rosner Guido van Rossum @@ -1160,7 +1150,6 @@ Ty Sarna Hugh Sasse Bob Savage -Dave Sawyer Ben Sayer sbt Marco Scataglini @@ -1263,7 +1252,6 @@ Anthony Starks Oliver Steele Greg Stein -Marek Stepniowski Baruch Sterin Chris Stern Alex Stewart @@ -1290,7 +1278,6 @@ Paul Swartz Thenault Sylvain Péter Szabó -John Szakmeister Amir Szekely Arfrever Frehtes Taifersar Arahesis Hideaki Takahashi @@ -1357,7 +1344,6 @@ Daniel Urban Michael Urman Hector Urtubia -Lukas Vacek Ville Vainio Andi Vajda Case Van Horsen @@ -1385,7 +1371,6 @@ Alex Volkov Martijn Vries Sjoerd de Vries -Guido Vranken Niki W. Waibel Wojtek Walczak Charles Waldman @@ -1404,7 +1389,6 @@ David Watson Aaron Watters Henrik Weber -Leon Weber Corran Webster Glyn Webster Phil Webster @@ -1430,7 +1414,6 @@ Jason Williams John Williams Sue Williams -Carol Willing Steven Willis Frank Willison Geoff Wilson diff -r ce070040e1a6 -r d7f128afe9db Misc/NEWS --- a/Misc/NEWS Sat May 10 13:24:58 2014 -0400 +++ b/Misc/NEWS Sun Mar 23 09:44:28 2014 +0100 @@ -10,37 +10,6 @@ Core and Builtins ----------------- -- Issue #21435: In rare cases, when running finalizers on objects in cyclic - trash a bad pointer dereference could occur due to a subtle flaw in - internal iteration logic. - -- Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(), - PyObject_Calloc(), _PyObject_GC_Calloc(). bytes(int) and bytearray(int) - are now using ``calloc()`` instead of ``malloc()`` for large objects which - is faster and use less memory (until the bytearray buffer is filled with - data). - -- Issue #21377: PyBytes_Concat() now tries to concatenate in-place when the - first argument has a reference count of 1. Patch by Nikolaus Rath. - -- Issue #20355: -W command line options now have higher priority than the - PYTHONWARNINGS environment variable. Patch by Arfrever. - -- Issue #21274: Define PATH_MAX for GNU/Hurd in Python/pythonrun.c. - -- Issue #20904: Support setting FPU precision on m68k. - -- Issue #21209: Fix sending tuples to custom generator objects with the yield - from syntax. - -- Issue #21193: pow(a, b, c) now raises ValueError rather than TypeError when b - is negative. Patch by Josh Rosenberg. - -- PEP 465 and Issue #21176: Add the '@' operator for matrix multiplication. - -- Issue #21134: Fix segfault when str is called on an uninitialized - UnicodeEncodeError, UnicodeDecodeError, or UnicodeTranslateError object. - - Issue #19537: Fix PyUnicode_DATA() alignment under m68k. Patch by Andreas Schwab. @@ -52,177 +21,15 @@ - Issue #20637: Key-sharing now also works for instance dictionaries of subclasses. Patch by Peter Ingebretson. -- Issue #8297: Attributes missing from modules now include the module name - in the error text. Original patch by ysj.ray. - - Issue #19995: %c, %o, %x, and %X now raise TypeError on non-integer input. -- Issue #19655: The ASDL parser - used by the build process to generate code for - managing the Python AST in C - was rewritten. The new parser is self contained - and does not require to carry long the spark.py parser-generator library; - spark.py was removed from the source base. - -- Issue #12546: Allow \x00 to be used as a fill character when using str, int, - float, and complex __format__ methods. - -- Issue #20480: Add ipaddress.reverse_pointer. Patch by Leon Weber. - -- Issue #13598: Modify string.Formatter to support auto-numbering of - replacement fields. It now matches the behavior of str.format() in - this regard. Patches by Phil Elson and Ramchandra Apte. - -- Issue #8931: Make alternate formatting ('#') for type 'c' raise an - exception. In versions prior to 3.5, '#' with 'c' had no effect. Now - specifying it is an error. Patch by Torsten Landschoff. - Library ------- -- Issue #21156: importlib.abc.InspectLoader.source_to_code() is now a - staticmethod. - -- Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a - flush() on the underlying binary stream. Patch by akira. - -- Issue #18314: Unlink now removes junctions on Windows. Patch by Kim Gräsman - -- Issue #21088: Bugfix for curses.window.addch() regression in 3.4.0. - In porting to Argument Clinic, the first two arguments were reversed. - -- Issue #10650: Remove the non-standard 'watchexp' parameter from the - Decimal.quantize() method in the Python version. It had never been - present in the C version. - -- Issue #19414: Have the OrderedDict mark deleted links as unusable. - This gives an early failure if the link is deleted during iteration. - -- Issue #21421: Add __slots__ to the MappingViews ABC. - Patch by Josh Rosenberg. - -- Issue #21101: Eliminate double hashing in the C speed-up code for - collections.Counter(). - -- Issue #21321: itertools.islice() now releases the reference to the source - iterator when the slice is exhausted. Patch by Anton Afanasyev. - -- Issue #21057: TextIOWrapper now allows the underlying binary stream's - read() or read1() method to return an arbitrary bytes-like object - (such as a memoryview). Patch by Nikolaus Rath. - -- Issue #20951: SSLSocket.send() now raises either SSLWantReadError or - SSLWantWriteError on a non-blocking socket if the operation would block. - Previously, it would return 0. Patch by Nikolaus Rath. - -- Issue #13248: removed previously deprecated asyncore.dispatcher __getattr__ - cheap inheritance hack. - -- Issue #9815: assertRaises now tries to clear references to local variables - in the exception's traceback. - -- Issue #19940: ssl.cert_time_to_seconds() now interprets the given time - string in the UTC timezone (as specified in RFC 5280), not the local - timezone. - -- Issue #13204: Calling sys.flags.__new__ would crash the interpreter, - now it raises a TypeError. - -- Issue #19385: Make operations on a closed dbm.dumb database always raise the - same exception. - -- Issue #21207: Detect when the os.urandom cached fd has been closed or - replaced, and open it anew. - -- Issue #21291: subprocess's Popen.wait() is now thread safe so that - multiple threads may be calling wait() or poll() on a Popen instance - at the same time without losing the Popen.returncode value. - -- Issue #21127: Path objects can now be instantiated from str subclass - instances (such as ``numpy.str_``). - -- Issue #15002: urllib.response object to use _TemporaryFileWrapper (and - _TemporaryFileCloser) facility. Provides a better way to handle file - descriptor close. Patch contributed by Christian Theune. - -- Issue #12220: mindom now raises a custom ValueError indicating it doesn't - support spaces in URIs instead of letting a 'split' ValueError bubble up. - -- Issue #21068: The ssl.PROTOCOL* constants are now enum members. - -- Issue #21262: New method assert_not_called for Mock. - It raises AssertionError if the mock has been called. - -- Issue #21238: New keyword argument `unsafe` to Mock. It raises - `AttributeError` incase of an attribute startswith assert or assret. - -- Issue #20896: ssl.get_server_certificate() now uses PROTOCOL_SSLv23, not - PROTOCOL_SSLv3, for maximum compatibility. - -- Issue #21239: patch.stopall() didn't work deterministically when the same - name was patched more than once. - -- Issue #21203: Updated fileConfig and dictConfig to remove inconsistencies. - Thanks to Jure Koren for the patch. - -- Issue #21222: Passing name keyword argument to mock.create_autospec now - works. - -- Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX. - -- Issue #17498: Some SMTP servers disconnect after certain errors, violating - strict RFC conformance. Instead of losing the error code when we issue the - subsequent RSET, smtplib now returns the error code and defers raising the - SMTPServerDisconnected error until the next command is issued. - -- Issue #17826: setting an iterable side_effect on a mock function created by - create_autospec now works. Patch by Kushal Das. - -- Issue #7776: Fix ``Host:`` header and reconnection when using - http.client.HTTPConnection.set_tunnel(). Patch by Nikolaus Rath. - -- Issue #20968: unittest.mock.MagicMock now supports division. - Patch by Johannes Baiter. - -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. - -- Issue #21169: getpass now handles non-ascii characters that the - input stream encoding cannot encode by re-encoding using the - replace error handler. - -- Issue #21171: Fixed undocumented filter API of the rot13 codec. - Patch by Berker Peksag. - -- Issue #20539: Improved math.factorial error message for large positive inputs - and changed exception type (OverflowError -> ValueError) for large negative - inputs. - -- Issue #21172: isinstance check relaxed from dict to collections.Mapping. - -- Issue #21155: asyncio.EventLoop.create_unix_server() now raises a ValueError - if path and sock are specified at the same time. - -- Issue #21136: Avoid unnecessary normalization of Fractions resulting from - power and other operations. Patch by Raymond Hettinger. - -- Issue #17621: Introduce importlib.util.LazyLoader. - -- Issue #21076: signal module constants were turned into enums. - Patch by Giampaolo Rodola'. - -- Issue #20636: Improved the repr of Tkinter widgets. - -- Issue #19505: The items, keys, and values views of OrderedDict now support - reverse iteration using reversed(). - -- Issue #21149: Improved thread-safety in logging cleanup during interpreter - shutdown. Thanks to Devin Jeanpierre for the patch. - - Issue #21058: Fix a leak of file descriptor in :func:`tempfile.NamedTemporaryFile`, close the file descriptor if :func:`io.open` fails -- Issue #21200: Return None from pkgutil.get_loader() when __spec__ is missing. - - Issue #21013: Enhance ssl.create_default_context() when used for server side sockets to provide better security by default. @@ -233,9 +40,6 @@ - Issue #20980: Stop wrapping exception when using ThreadPool. -- Issue #21082: In os.makedirs, do not set the process-wide umask. Note this - changes behavior of makedirs when exist_ok=True. - - Issue #20990: Fix issues found by pyflakes for multiprocessing. - Issue #21015: SSL contexts will now automatically select an elliptic @@ -301,115 +105,9 @@ - Issue #19748: On AIX, time.mktime() now raises an OverflowError for year outsize range [1902; 2037]. -- Issue #19573: inspect.signature: Use enum for parameter kind constants. - -- Issue #20726: inspect.signature: Make Signature and Parameter picklable. - -- Issue #17373: Add inspect.Signature.from_callable method. - -- Issue #20378: Improve repr of inspect.Signature and inspect.Parameter. - -- Issue #20816: Fix inspect.getcallargs() to raise correct TypeError for - missing keyword-only arguments. Patch by Jeremiah Lowin. - -- Issue #20817: Fix inspect.getcallargs() to fail correctly if more - than 3 arguments are missing. Patch by Jeremiah Lowin. - -- Issue #6676: Ensure a meaningful exception is raised when attempting - to parse more than one XML document per pyexpat xmlparser instance. - (Original patches by Hirokazu Yamamoto and Amaury Forgeot d'Arc, with - suggested wording by David Gutteridge) - -- Issue #21117: Fix inspect.signature to better support functools.partial. - Due to the specifics of functools.partial implementation, - positional-or-keyword arguments passed as keyword arguments become - keyword-only. - -- Issue #20334: inspect.Signature and inspect.Parameter are now hashable. - -- Issue #15916: doctest.DocTestSuite returns an empty unittest.TestSuite instead - of raising ValueError if it finds no tests - -- Issue #21209: Fix asyncio.tasks.CoroWrapper to workaround a bug - in yield-from implementation in CPythons prior to 3.4.1. - -- asyncio: Add gi_{frame,running,code} properties to CoroWrapper - (upstream issue #163). - -- Issue #21311: Avoid exception in _osx_support with non-standard compiler - configurations. Patch by John Szakmeister. - -- Issue #11571: Ensure that the turtle window becomes the topmost window - when launched on OS X. - -Extension Modules ------------------ - -- Issue #21407: _decimal: The module now supports function signatures. - -- Issue #21276: posixmodule: Don't define USE_XATTRS on KFreeBSD and the Hurd. - -IDLE ----- - -- Issue #21139: Change default paragraph width to 72, the PEP 8 recommendation. - -- Issue #21284: Paragraph reformat test passes after user changes reformat width. - -- Issue #17654: Ensure IDLE menus are customized properly on OS X for - non-framework builds and for all variants of Tk. - -Build ------ - -- Issue #21141: The Windows build process no longer attempts to find Perl, - instead relying on OpenSSL source being configured and ready to build. The - ``PCbuild\build_ssl.py`` script has been re-written and re-named to - ``PCbuild\prepare_ssl.py``, and takes care of configuring OpenSSL source - for both 32 and 64 bit platforms. OpenSSL sources obtained from - svn.python.org will always be pre-configured and ready to build. - -- Issue #21037: Add a build option to enable AddressSanitizer support. - -- The Windows build now includes OpenSSL 1.0.1g - -- Issue #19962: The Windows build process now creates "python.bat" in the - root of the source tree, which passes all arguments through to the most - recently built interpreter. - -- Issue #21285: Refactor and fix curses configure check to always search - in a ncursesw directory. - -- Issue #15234: For BerkelyDB and Sqlite, only add the found library and - include directories if they aren't already being searched. This avoids - an explicit runtime library dependency. - -- Issue #17861: Tools/scripts/generate_opcode_h.py automatically regenerates - Include/opcode.h from Lib/opcode.py if the later gets any change. - -- Issue #20644: OS X installer build support for documentation build changes - in 3.4.1: assume externally supplied sphinx-build is available in /usr/bin. - -- Issue #20022: Eliminate use of deprecated bundlebuilder in OS X builds. - -- Issue #15968: Incorporated Tcl, Tk, and Tix builds into the Windows build - solution. - -C API ------ -- Issue #20942: PyImport_ImportFrozenModuleObject() no longer sets __file__ to - match what importlib does; this affects _frozen_importlib as well as any - module loaded using imp.init_frozen(). - Documentation ------------- -- Issue #17386: Expanded functionality of the ``Doc/make.bat`` script to make - it much more comparable to ``Doc/Makefile``. - -- Issue #21312: Update the thread_foobar.h template file to include newer - threading APIs. Patch by Jack McCracken. - - Issue #21043: Remove the recommendation for specific CA organizations and to mention the ability to load the OS certificates. @@ -422,55 +120,23 @@ required reference material for tool developers that isn't recorded anywhere else. -- Issue #19697: Document cases where __main__.__spec__ is None. - Tests ----- -- Issue #17752: Fix distutils tests when run from the installed location. - -- Issue #18604: Consolidated checks for GUI availability. All platforms now - at least check whether Tk can be instantiated when the GUI resource is - requested. - -- Issue #21275: Fix a socket test on KFreeBSD. - -- Issue #21223: Pass test_site/test_startup_imports when some of the extensions - are built as builtins. - -- Issue #20635: Added tests for Tk geometry managers. - -- Add test case for freeze. - - Issue #20743: Fix a reference leak in test_tcl. -- Issue #21097: Move test_namespace_pkgs into test_importlib. - -- Issue #20939: Avoid various network test failures due to new - redirect of http://www.python.org/ to https://www.python.org: - use http://www.example.com instead. - -- Issue #20668: asyncio tests no longer rely on tests.txt file. - (Patch by Vajrasky Kok) - -- Issue #21093: Prevent failures of ctypes test_macholib on OS X if a - copy of libz exists in $HOME/lib or /usr/local/lib. - Tools/Demos ----------- -- Add support for ``yield from`` to 2to3. - -- Add support for the PEP 465 matrix multiplication operator to 2to3. - -- Issue #16047: Fix module exception list and __file__ handling in freeze. - Patch by Meador Inge. - -- Issue #11824: Consider ABI tags in freeze. Patch by Meador Inge. - - Issue #20535: PYTHONWARNING no longer affects the run_tests.py script. Patch by Arfrever Frehtes Taifersar Arahesis. +Build +----- + +- Issue #15968: Incorporated Tcl, Tk, and Tix builds into the Windows build + solution. + What's New in Python 3.4.0? =========================== diff -r ce070040e1a6 -r d7f128afe9db Misc/SpecialBuilds.txt --- a/Misc/SpecialBuilds.txt Sat May 10 13:24:58 2014 -0400 +++ b/Misc/SpecialBuilds.txt Sun Mar 23 09:44:28 2014 +0100 @@ -13,14 +13,12 @@ ------------ Turn on aggregate reference counting. This arranges that extern _Py_RefTotal -hold a count of all references, the sum of ob_refcnt across all objects. -Passing ``-X showrefcount`` on the command line causes the interactive -interpreter to print the reference count total as well the number of memory -blocks allocated after each statement: +hold a count of all references, the sum of ob_refcnt across all objects. In a +debug-mode build, this is where the "8288" comes from in >>> 23 23 - [8288 refs, 14332 blocks] + [8288 refs] >>> Note that if this count increases when you're not storing away new objects, diff -r ce070040e1a6 -r d7f128afe9db Modules/Setup.config.in --- a/Modules/Setup.config.in Sat May 10 13:24:58 2014 -0400 +++ b/Modules/Setup.config.in Sun Mar 23 09:44:28 2014 +0100 @@ -7,7 +7,7 @@ @USE_THREAD_MODULE@_thread _threadmodule.c # The signal module -@USE_SIGNAL_MODULE@_signal signalmodule.c +@USE_SIGNAL_MODULE@signal signalmodule.c # The rest of the modules previously listed in this file are built # by the setup.py script in Python 2.1 and later. diff -r ce070040e1a6 -r d7f128afe9db Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_collectionsmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -3,7 +3,7 @@ /* collections module implementation of a deque() datatype Written and maintained by Raymond D. Hettinger - Copyright (c) 2004-2014 Python Software Foundation. + Copyright (c) 2004-2013 Python Software Foundation. All rights reserved. */ @@ -145,12 +145,6 @@ static PyTypeObject deque_type; -/* XXX Todo: - If aligned memory allocations become available, make the - deque object 64 byte aligned so that all of the fields - can be retrieved or updated in a single cache line. -*/ - static PyObject * deque_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -460,31 +454,6 @@ return (PyObject *)deque; } -/* The rotate() method is part of the public API and is used internally -as a primitive for other methods. - -Rotation by 1 or -1 is a common case, so any optimizations for high -volume rotations should take care not to penalize the common case. - -Conceptually, a rotate by one is equivalent to a pop on one side and an -append on the other. However, a pop/append pair is unnecessarily slow -because it requires a incref/decref pair for an object located randomly -in memory. It is better to just move the object pointer from one block -to the next without changing the reference count. - -When moving batches of pointers, it is tempting to use memcpy() but that -proved to be slower than a simple loop for a variety of reasons. -Memcpy() cannot know in advance that we're copying pointers instead of -bytes, that the source and destination are pointer aligned and -non-overlapping, that moving just one pointer is a common case, that we -never need to move more than BLOCKLEN pointers, and that at least one -pointer is always moved. - -For high volume rotations, newblock() and freeblock() are never called -more than once. Previously emptied blocks are immediately reused as a -destination block. If a block is left-over at the end, it is freed. -*/ - static int _deque_rotate(dequeobject *deque, Py_ssize_t n) { @@ -1831,29 +1800,18 @@ if (mapping_get != NULL && mapping_get == dict_get && mapping_setitem != NULL && mapping_setitem == dict_setitem) { while (1) { - Py_hash_t hash; - key = PyIter_Next(it); if (key == NULL) break; - - if (!PyUnicode_CheckExact(key) || - (hash = ((PyASCIIObject *) key)->hash) == -1) - { - hash = PyObject_Hash(key); - if (hash == -1) - goto done; - } - - oldval = _PyDict_GetItem_KnownHash(mapping, key, hash); + oldval = PyDict_GetItem(mapping, key); if (oldval == NULL) { - if (_PyDict_SetItem_KnownHash(mapping, key, one, hash) == -1) + if (PyDict_SetItem(mapping, key, one) == -1) break; } else { newval = PyNumber_Add(oldval, one); if (newval == NULL) break; - if (_PyDict_SetItem_KnownHash(mapping, key, newval, hash) == -1) + if (PyDict_SetItem(mapping, key, newval) == -1) break; Py_CLEAR(newval); } diff -r ce070040e1a6 -r d7f128afe9db Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_cursesmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -560,10 +560,10 @@ curses.window.addch [ + x: int + X-coordinate. y: int Y-coordinate. - x: int - X-coordinate. ] ch: object @@ -584,13 +584,13 @@ [clinic start generated code]*/ PyDoc_STRVAR(curses_window_addch__doc__, -"addch([y, x,] ch, [attr])\n" +"addch([x, y,] ch, [attr])\n" "Paint character ch at (y, x) with attributes attr.\n" "\n" +" x\n" +" X-coordinate.\n" " y\n" " Y-coordinate.\n" -" x\n" -" X-coordinate.\n" " ch\n" " Character to add.\n" " attr\n" @@ -605,15 +605,15 @@ {"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__}, static PyObject * -curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr); +curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int x, int y, PyObject *ch, int group_right_1, long attr); static PyObject * curses_window_addch(PyCursesWindowObject *self, PyObject *args) { PyObject *return_value = NULL; int group_left_1 = 0; + int x = 0; int y = 0; - int x = 0; PyObject *ch; int group_right_1 = 0; long attr = 0; @@ -629,12 +629,12 @@ group_right_1 = 1; break; case 3: - if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) + if (!PyArg_ParseTuple(args, "iiO:addch", &x, &y, &ch)) goto exit; group_left_1 = 1; break; case 4: - if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) + if (!PyArg_ParseTuple(args, "iiOl:addch", &x, &y, &ch, &attr)) goto exit; group_right_1 = 1; group_left_1 = 1; @@ -643,15 +643,15 @@ PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments"); goto exit; } - return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); + return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr); exit: return return_value; } static PyObject * -curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr) -/*[clinic end generated code: output=d4b97cc287010c54 input=5a41efb34a2de338]*/ +curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int x, int y, PyObject *ch, int group_right_1, long attr) +/*[clinic end generated code: output=43acb91a5c98f615 input=fe7e3711d5bbf1f6]*/ { PyCursesWindowObject *cwself = (PyCursesWindowObject *)self; int coordinates_group = group_left_1; diff -r ce070040e1a6 -r d7f128afe9db Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_decimal/_decimal.c Sun Mar 23 09:44:28 2014 +0100 @@ -3542,7 +3542,7 @@ } } -static PyTypeObject *DecimalTuple = NULL; +static PyObject *DecimalTuple = NULL; /* Return the DecimalTuple representation of a PyDecObject. */ static PyObject * PyDec_AsTuple(PyObject *dec, PyObject *dummy UNUSED) @@ -3625,7 +3625,7 @@ } } - result = PyObject_CallFunctionObjArgs((PyObject *)DecimalTuple, + result = PyObject_CallFunctionObjArgs(DecimalTuple, sign, coeff, expt, NULL); out: @@ -5562,14 +5562,9 @@ /* DecimalTuple */ ASSIGN_PTR(collections, PyImport_ImportModule("collections")); - ASSIGN_PTR(DecimalTuple, (PyTypeObject *)PyObject_CallMethod(collections, + ASSIGN_PTR(DecimalTuple, PyObject_CallMethod(collections, "namedtuple", "(ss)", "DecimalTuple", "sign digits exponent")); - - ASSIGN_PTR(obj, PyUnicode_FromString("decimal")); - CHECK_INT(PyDict_SetItemString(DecimalTuple->tp_dict, "__module__", obj)); - Py_CLEAR(obj); - /* MutableMapping */ ASSIGN_PTR(MutableMapping, PyObject_GetAttrString(collections, "MutableMapping")); @@ -5596,7 +5591,7 @@ CHECK_INT(PyModule_AddObject(m, "Context", (PyObject *)&PyDecContext_Type)); Py_INCREF(DecimalTuple); - CHECK_INT(PyModule_AddObject(m, "DecimalTuple", (PyObject *)DecimalTuple)); + CHECK_INT(PyModule_AddObject(m, "DecimalTuple", DecimalTuple)); /* Create top level exception */ diff -r ce070040e1a6 -r d7f128afe9db Modules/_decimal/docstrings.h --- a/Modules/_decimal/docstrings.h Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_decimal/docstrings.h Sun Mar 23 09:44:28 2014 +0100 @@ -19,30 +19,26 @@ PyDoc_STRVAR(doc__decimal, "C decimal arithmetic module"); -PyDoc_STRVAR(doc_getcontext, -"getcontext($module, /)\n--\n\n\ -Get the current default context.\n\ +PyDoc_STRVAR(doc_getcontext,"\n\ +getcontext() - Get the current default context.\n\ \n"); -PyDoc_STRVAR(doc_setcontext, -"setcontext($module, context, /)\n--\n\n\ -Set a new default context.\n\ +PyDoc_STRVAR(doc_setcontext,"\n\ +setcontext(c) - Set a new default context.\n\ \n"); -PyDoc_STRVAR(doc_localcontext, -"localcontext($module, /, ctx=None)\n--\n\n\ -Return a context manager that will set the default context to a copy of ctx\n\ -on entry to the with-statement and restore the previous default context when\n\ -exiting the with-statement. If no context is specified, a copy of the current\n\ -default context is used.\n\ +PyDoc_STRVAR(doc_localcontext,"\n\ +localcontext(ctx=None) - Return a context manager that will set the default\n\ +context to a copy of ctx on entry to the with-statement and restore the\n\ +previous default context when exiting the with-statement. If no context is\n\ +specified, a copy of the current default context is used.\n\ \n"); #ifdef EXTRA_FUNCTIONALITY -PyDoc_STRVAR(doc_ieee_context, -"IEEEContext($module, bits, /)\n--\n\n\ -Return a context object initialized to the proper values for one of the\n\ -IEEE interchange formats. The argument must be a multiple of 32 and less\n\ -than IEEE_CONTEXT_MAX_BITS. For the most common values, the constants\n\ +PyDoc_STRVAR(doc_ieee_context,"\n\ +IEEEContext(bits) - Return a context object initialized to the proper values for\n\ +one of the IEEE interchange formats. The argument must be a multiple of 32 and\n\ +less than IEEE_CONTEXT_MAX_BITS. For the most common values, the constants\n\ DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\ \n"); #endif @@ -52,34 +48,32 @@ /* Decimal Object and Methods */ /******************************************************************************/ -PyDoc_STRVAR(doc_decimal, -"Decimal(value=\"0\", context=None)\n--\n\n\ -Construct a new Decimal object. 'value' can be an integer, string, tuple,\n\ -or another Decimal object. If no value is given, return Decimal('0'). The\n\ -context does not affect the conversion and is only passed to determine if\n\ -the InvalidOperation trap is active.\n\ +PyDoc_STRVAR(doc_decimal,"\n\ +Decimal(value=\"0\", context=None): Construct a new Decimal object.\n\ +value can be an integer, string, tuple, or another Decimal object.\n\ +If no value is given, return Decimal('0'). The context does not affect\n\ +the conversion and is only passed to determine if the InvalidOperation\n\ +trap is active.\n\ \n"); -PyDoc_STRVAR(doc_adjusted, -"adjusted($self, /)\n--\n\n\ -Return the adjusted exponent of the number. Defined as exp + digits - 1.\n\ +PyDoc_STRVAR(doc_adjusted,"\n\ +adjusted() - Return the adjusted exponent of the number.\n\ +\n\ +Defined as exp + digits - 1.\n\ \n"); -PyDoc_STRVAR(doc_as_tuple, -"as_tuple($self, /)\n--\n\n\ -Return a tuple representation of the number.\n\ +PyDoc_STRVAR(doc_as_tuple,"\n\ +as_tuple() - Return a tuple representation of the number.\n\ \n"); -PyDoc_STRVAR(doc_canonical, -"canonical($self, /)\n--\n\n\ -Return the canonical encoding of the argument. Currently, the encoding\n\ -of a Decimal instance is always canonical, so this operation returns its\n\ -argument unchanged.\n\ +PyDoc_STRVAR(doc_canonical,"\n\ +canonical() - Return the canonical encoding of the argument. Currently,\n\ +the encoding of a Decimal instance is always canonical, so this operation\n\ +returns its argument unchanged.\n\ \n"); -PyDoc_STRVAR(doc_compare, -"compare($self, /, other, context=None)\n--\n\n\ -Compare self to other. Return a decimal value:\n\ +PyDoc_STRVAR(doc_compare,"\n\ +compare(other, context=None) - Compare self to other. Return a decimal value:\n\ \n\ a or b is a NaN ==> Decimal('NaN')\n\ a < b ==> Decimal('-1')\n\ @@ -87,18 +81,17 @@ a > b ==> Decimal('1')\n\ \n"); -PyDoc_STRVAR(doc_compare_signal, -"compare_signal($self, /, other, context=None)\n--\n\n\ -Identical to compare, except that all NaNs signal.\n\ +PyDoc_STRVAR(doc_compare_signal,"\n\ +compare_signal(other, context=None) - Identical to compare, except that\n\ +all NaNs signal.\n\ \n"); -PyDoc_STRVAR(doc_compare_total, -"compare_total($self, /, other, context=None)\n--\n\n\ -Compare two operands using their abstract representation rather than\n\ -their numerical value. Similar to the compare() method, but the result\n\ -gives a total ordering on Decimal instances. Two Decimal instances with\n\ -the same numeric value but different representations compare unequal\n\ -in this ordering:\n\ +PyDoc_STRVAR(doc_compare_total,"\n\ +compare_total(other, context=None) - Compare two operands using their\n\ +abstract representation rather than their numerical value. Similar to the\n\ +compare() method, but the result gives a total ordering on Decimal instances.\n\ +Two Decimal instances with the same numeric value but different representations\n\ +compare unequal in this ordering:\n\ \n\ >>> Decimal('12.0').compare_total(Decimal('12'))\n\ Decimal('-1')\n\ @@ -114,39 +107,36 @@ InvalidOperation if the second operand cannot be converted exactly.\n\ \n"); -PyDoc_STRVAR(doc_compare_total_mag, -"compare_total_mag($self, /, other, context=None)\n--\n\n\ -Compare two operands using their abstract representation rather than their\n\ -value as in compare_total(), but ignoring the sign of each operand.\n\ -\n\ -x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()).\n\ +PyDoc_STRVAR(doc_compare_total_mag,"\n\ +compare_total_mag(other, context=None) - Compare two operands using their\n\ +abstract representation rather than their value as in compare_total(), but\n\ +ignoring the sign of each operand. x.compare_total_mag(y) is equivalent to\n\ +x.copy_abs().compare_total(y.copy_abs()).\n\ \n\ This operation is unaffected by context and is quiet: no flags are changed\n\ and no rounding is performed. As an exception, the C version may raise\n\ InvalidOperation if the second operand cannot be converted exactly.\n\ \n"); -PyDoc_STRVAR(doc_conjugate, -"conjugate($self, /)\n--\n\n\ -Return self.\n\ +PyDoc_STRVAR(doc_conjugate,"\n\ +conjugate() - Return self.\n\ \n"); -PyDoc_STRVAR(doc_copy_abs, -"copy_abs($self, /)\n--\n\n\ -Return the absolute value of the argument. This operation is unaffected by\n\ -context and is quiet: no flags are changed and no rounding is performed.\n\ +PyDoc_STRVAR(doc_copy_abs,"\n\ +copy_abs() - Return the absolute value of the argument. This operation\n\ +is unaffected by context and is quiet: no flags are changed and no rounding\n\ +is performed.\n\ \n"); -PyDoc_STRVAR(doc_copy_negate, -"copy_negate($self, /)\n--\n\n\ -Return the negation of the argument. This operation is unaffected by context\n\ -and is quiet: no flags are changed and no rounding is performed.\n\ +PyDoc_STRVAR(doc_copy_negate,"\n\ +copy_negate() - Return the negation of the argument. This operation is\n\ +unaffected by context and is quiet: no flags are changed and no rounding\n\ +is performed.\n\ \n"); -PyDoc_STRVAR(doc_copy_sign, -"copy_sign($self, /, other, context=None)\n--\n\n\ -Return a copy of the first operand with the sign set to be the same as the\n\ -sign of the second operand. For example:\n\ +PyDoc_STRVAR(doc_copy_sign,"\n\ +copy_sign(other, context=None) - Return a copy of the first operand with\n\ +the sign set to be the same as the sign of the second operand. For example:\n\ \n\ >>> Decimal('2.3').copy_sign(Decimal('-1.5'))\n\ Decimal('-2.3')\n\ @@ -156,16 +146,14 @@ InvalidOperation if the second operand cannot be converted exactly.\n\ \n"); -PyDoc_STRVAR(doc_exp, -"exp($self, /, context=None)\n--\n\n\ -Return the value of the (natural) exponential function e**x at the given\n\ -number. The function always uses the ROUND_HALF_EVEN mode and the result\n\ -is correctly rounded.\n\ +PyDoc_STRVAR(doc_exp,"\n\ +exp(context=None) - Return the value of the (natural) exponential function\n\ +e**x at the given number. The function always uses the ROUND_HALF_EVEN mode\n\ +and the result is correctly rounded.\n\ \n"); -PyDoc_STRVAR(doc_from_float, -"from_float($type, f, /)\n--\n\n\ -Class method that converts a float to a decimal number, exactly.\n\ +PyDoc_STRVAR(doc_from_float,"\n\ +from_float(f) - Class method that converts a float to a decimal number, exactly.\n\ Since 0.1 is not exactly representable in binary floating point,\n\ Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\ \n\ @@ -180,176 +168,155 @@ \n\ \n"); -PyDoc_STRVAR(doc_fma, -"fma($self, /, other, third, context=None)\n--\n\n\ -Fused multiply-add. Return self*other+third with no rounding of the\n\ -intermediate product self*other.\n\ +PyDoc_STRVAR(doc_fma,"\n\ +fma(other, third, context=None) - Fused multiply-add. Return self*other+third\n\ +with no rounding of the intermediate product self*other.\n\ \n\ >>> Decimal(2).fma(3, 5)\n\ Decimal('11')\n\ \n\ \n"); -PyDoc_STRVAR(doc_is_canonical, -"is_canonical($self, /)\n--\n\n\ -Return True if the argument is canonical and False otherwise. Currently,\n\ -a Decimal instance is always canonical, so this operation always returns\n\ -True.\n\ +PyDoc_STRVAR(doc_is_canonical,"\n\ +is_canonical() - Return True if the argument is canonical and False otherwise.\n\ +Currently, a Decimal instance is always canonical, so this operation always\n\ +returns True.\n\ \n"); -PyDoc_STRVAR(doc_is_finite, -"is_finite($self, /)\n--\n\n\ -Return True if the argument is a finite number, and False if the argument\n\ -is infinite or a NaN.\n\ +PyDoc_STRVAR(doc_is_finite,"\n\ +is_finite() - Return True if the argument is a finite number, and False if the\n\ +argument is infinite or a NaN.\n\ \n"); -PyDoc_STRVAR(doc_is_infinite, -"is_infinite($self, /)\n--\n\n\ -Return True if the argument is either positive or negative infinity and\n\ +PyDoc_STRVAR(doc_is_infinite,"\n\ +is_infinite() - Return True if the argument is either positive or negative\n\ +infinity and False otherwise.\n\ +\n"); + +PyDoc_STRVAR(doc_is_nan,"\n\ +is_nan() - Return True if the argument is a (quiet or signaling) NaN and\n\ False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_is_nan, -"is_nan($self, /)\n--\n\n\ -Return True if the argument is a (quiet or signaling) NaN and False\n\ -otherwise.\n\ +PyDoc_STRVAR(doc_is_normal,"\n\ +is_normal(context=None) - Return True if the argument is a normal finite\n\ +non-zero number with an adjusted exponent greater than or equal to Emin.\n\ +Return False if the argument is zero, subnormal, infinite or a NaN.\n\ \n"); -PyDoc_STRVAR(doc_is_normal, -"is_normal($self, /, context=None)\n--\n\n\ -Return True if the argument is a normal finite non-zero number with an\n\ -adjusted exponent greater than or equal to Emin. Return False if the\n\ -argument is zero, subnormal, infinite or a NaN.\n\ +PyDoc_STRVAR(doc_is_qnan,"\n\ +is_qnan() - Return True if the argument is a quiet NaN, and False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_is_qnan, -"is_qnan($self, /)\n--\n\n\ -Return True if the argument is a quiet NaN, and False otherwise.\n\ +PyDoc_STRVAR(doc_is_signed,"\n\ +is_signed() - Return True if the argument has a negative sign and\n\ +False otherwise. Note that both zeros and NaNs can carry signs.\n\ \n"); -PyDoc_STRVAR(doc_is_signed, -"is_signed($self, /)\n--\n\n\ -Return True if the argument has a negative sign and False otherwise.\n\ -Note that both zeros and NaNs can carry signs.\n\ +PyDoc_STRVAR(doc_is_snan,"\n\ +is_snan() - Return True if the argument is a signaling NaN and False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_is_snan, -"is_snan($self, /)\n--\n\n\ -Return True if the argument is a signaling NaN and False otherwise.\n\ +PyDoc_STRVAR(doc_is_subnormal,"\n\ +is_subnormal(context=None) - Return True if the argument is subnormal, and\n\ +False otherwise. A number is subnormal if it is non-zero, finite, and has an\n\ +adjusted exponent less than Emin.\n\ \n"); -PyDoc_STRVAR(doc_is_subnormal, -"is_subnormal($self, /, context=None)\n--\n\n\ -Return True if the argument is subnormal, and False otherwise. A number is\n\ -subnormal if it is non-zero, finite, and has an adjusted exponent less\n\ -than Emin.\n\ +PyDoc_STRVAR(doc_is_zero,"\n\ +is_zero() - Return True if the argument is a (positive or negative) zero and\n\ +False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_is_zero, -"is_zero($self, /)\n--\n\n\ -Return True if the argument is a (positive or negative) zero and False\n\ -otherwise.\n\ +PyDoc_STRVAR(doc_ln,"\n\ +ln(context=None) - Return the natural (base e) logarithm of the operand.\n\ +The function always uses the ROUND_HALF_EVEN mode and the result is\n\ +correctly rounded.\n\ \n"); -PyDoc_STRVAR(doc_ln, -"ln($self, /, context=None)\n--\n\n\ -Return the natural (base e) logarithm of the operand. The function always\n\ -uses the ROUND_HALF_EVEN mode and the result is correctly rounded.\n\ +PyDoc_STRVAR(doc_log10,"\n\ +log10(context=None) - Return the base ten logarithm of the operand.\n\ +The function always uses the ROUND_HALF_EVEN mode and the result is\n\ +correctly rounded.\n\ \n"); -PyDoc_STRVAR(doc_log10, -"log10($self, /, context=None)\n--\n\n\ -Return the base ten logarithm of the operand. The function always uses the\n\ -ROUND_HALF_EVEN mode and the result is correctly rounded.\n\ +PyDoc_STRVAR(doc_logb,"\n\ +logb(context=None) - For a non-zero number, return the adjusted exponent\n\ +of the operand as a Decimal instance. If the operand is a zero, then\n\ +Decimal('-Infinity') is returned and the DivisionByZero condition is\n\ +raised. If the operand is an infinity then Decimal('Infinity') is returned.\n\ \n"); -PyDoc_STRVAR(doc_logb, -"logb($self, /, context=None)\n--\n\n\ -For a non-zero number, return the adjusted exponent of the operand as a\n\ -Decimal instance. If the operand is a zero, then Decimal('-Infinity') is\n\ -returned and the DivisionByZero condition is raised. If the operand is\n\ -an infinity then Decimal('Infinity') is returned.\n\ +PyDoc_STRVAR(doc_logical_and,"\n\ +logical_and(other, context=None) - Return the digit-wise and of the two\n\ +(logical) operands.\n\ \n"); -PyDoc_STRVAR(doc_logical_and, -"logical_and($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'and' of the two (logical) operands.\n\ +PyDoc_STRVAR(doc_logical_invert,"\n\ +logical_invert(context=None) - Return the digit-wise inversion of the\n\ +(logical) operand.\n\ \n"); -PyDoc_STRVAR(doc_logical_invert, -"logical_invert($self, /, context=None)\n--\n\n\ -Return the digit-wise inversion of the (logical) operand.\n\ +PyDoc_STRVAR(doc_logical_or,"\n\ +logical_or(other, context=None) - Return the digit-wise or of the two\n\ +(logical) operands.\n\ \n"); -PyDoc_STRVAR(doc_logical_or, -"logical_or($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'or' of the two (logical) operands.\n\ +PyDoc_STRVAR(doc_logical_xor,"\n\ +logical_xor(other, context=None) - Return the digit-wise exclusive or of the\n\ +two (logical) operands.\n\ \n"); -PyDoc_STRVAR(doc_logical_xor, -"logical_xor($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'exclusive or' of the two (logical) operands.\n\ +PyDoc_STRVAR(doc_max,"\n\ +max(other, context=None) - Maximum of self and other. If one operand is a\n\ +quiet NaN and the other is numeric, the numeric operand is returned.\n\ \n"); -PyDoc_STRVAR(doc_max, -"max($self, /, other, context=None)\n--\n\n\ -Maximum of self and other. If one operand is a quiet NaN and the other is\n\ -numeric, the numeric operand is returned.\n\ +PyDoc_STRVAR(doc_max_mag,"\n\ +max_mag(other, context=None) - Similar to the max() method, but the\n\ +comparison is done using the absolute values of the operands.\n\ \n"); -PyDoc_STRVAR(doc_max_mag, -"max_mag($self, /, other, context=None)\n--\n\n\ -Similar to the max() method, but the comparison is done using the absolute\n\ -values of the operands.\n\ +PyDoc_STRVAR(doc_min,"\n\ +min(other, context=None) - Minimum of self and other. If one operand is a\n\ +quiet NaN and the other is numeric, the numeric operand is returned.\n\ \n"); -PyDoc_STRVAR(doc_min, -"min($self, /, other, context=None)\n--\n\n\ -Minimum of self and other. If one operand is a quiet NaN and the other is\n\ -numeric, the numeric operand is returned.\n\ +PyDoc_STRVAR(doc_min_mag,"\n\ +min_mag(other, context=None) - Similar to the min() method, but the\n\ +comparison is done using the absolute values of the operands.\n\ \n"); -PyDoc_STRVAR(doc_min_mag, -"min_mag($self, /, other, context=None)\n--\n\n\ -Similar to the min() method, but the comparison is done using the absolute\n\ -values of the operands.\n\ +PyDoc_STRVAR(doc_next_minus,"\n\ +next_minus(context=None) - Return the largest number representable in the\n\ +given context (or in the current default context if no context is given) that\n\ +is smaller than the given operand.\n\ \n"); -PyDoc_STRVAR(doc_next_minus, -"next_minus($self, /, context=None)\n--\n\n\ -Return the largest number representable in the given context (or in the\n\ -current default context if no context is given) that is smaller than the\n\ -given operand.\n\ +PyDoc_STRVAR(doc_next_plus,"\n\ +next_plus(context=None) - Return the smallest number representable in the\n\ +given context (or in the current default context if no context is given) that\n\ +is larger than the given operand.\n\ \n"); -PyDoc_STRVAR(doc_next_plus, -"next_plus($self, /, context=None)\n--\n\n\ -Return the smallest number representable in the given context (or in the\n\ -current default context if no context is given) that is larger than the\n\ -given operand.\n\ +PyDoc_STRVAR(doc_next_toward,"\n\ +next_toward(other, context=None) - If the two operands are unequal, return\n\ +the number closest to the first operand in the direction of the second operand.\n\ +If both operands are numerically equal, return a copy of the first operand\n\ +with the sign set to be the same as the sign of the second operand.\n\ \n"); -PyDoc_STRVAR(doc_next_toward, -"next_toward($self, /, other, context=None)\n--\n\n\ -If the two operands are unequal, return the number closest to the first\n\ -operand in the direction of the second operand. If both operands are\n\ -numerically equal, return a copy of the first operand with the sign set\n\ -to be the same as the sign of the second operand.\n\ +PyDoc_STRVAR(doc_normalize,"\n\ +normalize(context=None) - Normalize the number by stripping the rightmost\n\ +trailing zeros and converting any result equal to Decimal('0') to Decimal('0e0').\n\ +Used for producing canonical values for members of an equivalence class. For\n\ +example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the\n\ +equivalent value Decimal('32.1').\n\ \n"); -PyDoc_STRVAR(doc_normalize, -"normalize($self, /, context=None)\n--\n\n\ -Normalize the number by stripping the rightmost trailing zeros and\n\ -converting any result equal to Decimal('0') to Decimal('0e0'). Used\n\ -for producing canonical values for members of an equivalence class.\n\ -For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize\n\ -to the equivalent value Decimal('32.1').\n\ -\n"); - -PyDoc_STRVAR(doc_number_class, -"number_class($self, /, context=None)\n--\n\n\ -Return a string describing the class of the operand. The returned value\n\ -is one of the following ten strings:\n\ +PyDoc_STRVAR(doc_number_class,"\n\ +number_class(context=None) - Return a string describing the class of the\n\ +operand. The returned value is one of the following ten strings:\n\ \n\ * '-Infinity', indicating that the operand is negative infinity.\n\ * '-Normal', indicating that the operand is a negative normal number.\n\ @@ -364,10 +331,9 @@ \n\ \n"); -PyDoc_STRVAR(doc_quantize, -"quantize($self, /, exp, rounding=None, context=None)\n--\n\n\ -Return a value equal to the first operand after rounding and having the\n\ -exponent of the second operand.\n\ +PyDoc_STRVAR(doc_quantize,"\n\ +quantize(exp, rounding=None, context=None) - Return a value equal to the\n\ +first operand after rounding and having the exponent of the second operand.\n\ \n\ >>> Decimal('1.41421356').quantize(Decimal('1.000'))\n\ Decimal('1.414')\n\ @@ -386,98 +352,93 @@ argument is given, the rounding mode of the current thread's context is used.\n\ \n"); -PyDoc_STRVAR(doc_radix, -"radix($self, /)\n--\n\n\ -Return Decimal(10), the radix (base) in which the Decimal class does\n\ +PyDoc_STRVAR(doc_radix,"\n\ +radix() - Return Decimal(10), the radix (base) in which the Decimal class does\n\ all its arithmetic. Included for compatibility with the specification.\n\ \n"); -PyDoc_STRVAR(doc_remainder_near, -"remainder_near($self, /, other, context=None)\n--\n\n\ -Return the remainder from dividing self by other. This differs from\n\ -self % other in that the sign of the remainder is chosen so as to minimize\n\ -its absolute value. More precisely, the return value is self - n * other\n\ -where n is the integer nearest to the exact value of self / other, and\n\ -if two integers are equally near then the even one is chosen.\n\ +PyDoc_STRVAR(doc_remainder_near,"\n\ +remainder_near(other, context=None) - Return the remainder from dividing\n\ +self by other. This differs from self % other in that the sign of the\n\ +remainder is chosen so as to minimize its absolute value. More precisely, the\n\ +return value is self - n * other where n is the integer nearest to the exact\n\ +value of self / other, and if two integers are equally near then the even one\n\ +is chosen.\n\ \n\ If the result is zero then its sign will be the sign of self.\n\ \n"); -PyDoc_STRVAR(doc_rotate, -"rotate($self, /, other, context=None)\n--\n\n\ -Return the result of rotating the digits of the first operand by an amount\n\ -specified by the second operand. The second operand must be an integer in\n\ -the range -precision through precision. The absolute value of the second\n\ -operand gives the number of places to rotate. If the second operand is\n\ -positive then rotation is to the left; otherwise rotation is to the right.\n\ -The coefficient of the first operand is padded on the left with zeros to\n\ +PyDoc_STRVAR(doc_rotate,"\n\ +rotate(other, context=None) - Return the result of rotating the digits of the\n\ +first operand by an amount specified by the second operand. The second operand\n\ +must be an integer in the range -precision through precision. The absolute\n\ +value of the second operand gives the number of places to rotate. If the second\n\ +operand is positive then rotation is to the left; otherwise rotation is to the\n\ +right. The coefficient of the first operand is padded on the left with zeros to\n\ length precision if necessary. The sign and exponent of the first operand are\n\ unchanged.\n\ \n"); -PyDoc_STRVAR(doc_same_quantum, -"same_quantum($self, /, other, context=None)\n--\n\n\ -Test whether self and other have the same exponent or whether both are NaN.\n\ +PyDoc_STRVAR(doc_same_quantum,"\n\ +same_quantum(other, context=None) - Test whether self and other have the\n\ +same exponent or whether both are NaN.\n\ \n\ This operation is unaffected by context and is quiet: no flags are changed\n\ and no rounding is performed. As an exception, the C version may raise\n\ InvalidOperation if the second operand cannot be converted exactly.\n\ \n"); -PyDoc_STRVAR(doc_scaleb, -"scaleb($self, /, other, context=None)\n--\n\n\ -Return the first operand with the exponent adjusted the second. Equivalently,\n\ -return the first operand multiplied by 10**other. The second operand must be\n\ -an integer.\n\ +PyDoc_STRVAR(doc_scaleb,"\n\ +scaleb(other, context=None) - Return the first operand with the exponent\n\ +adjusted the second. Equivalently, return the first operand multiplied by\n\ +10**other. The second operand must be an integer.\n\ \n"); -PyDoc_STRVAR(doc_shift, -"shift($self, /, other, context=None)\n--\n\n\ -Return the result of shifting the digits of the first operand by an amount\n\ -specified by the second operand. The second operand must be an integer in\n\ -the range -precision through precision. The absolute value of the second\n\ -operand gives the number of places to shift. If the second operand is\n\ -positive, then the shift is to the left; otherwise the shift is to the\n\ -right. Digits shifted into the coefficient are zeros. The sign and exponent\n\ -of the first operand are unchanged.\n\ +PyDoc_STRVAR(doc_shift,"\n\ +shift(other, context=None) - Return the result of shifting the digits of\n\ +the first operand by an amount specified by the second operand. The second\n\ +operand must be an integer in the range -precision through precision. The\n\ +absolute value of the second operand gives the number of places to shift.\n\ +If the second operand is positive, then the shift is to the left; otherwise\n\ +the shift is to the right. Digits shifted into the coefficient are zeros.\n\ +The sign and exponent of the first operand are unchanged.\n\ \n"); -PyDoc_STRVAR(doc_sqrt, -"sqrt($self, /, context=None)\n--\n\n\ -Return the square root of the argument to full precision. The result is\n\ -correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\ +PyDoc_STRVAR(doc_sqrt,"\n\ +sqrt(context=None) - Return the square root of the argument to full precision.\n\ +The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\ \n"); -PyDoc_STRVAR(doc_to_eng_string, -"to_eng_string($self, /, context=None)\n--\n\n\ -Convert to an engineering-type string. Engineering notation has an exponent\n\ -which is a multiple of 3, so there are up to 3 digits left of the decimal\n\ -place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').\n\ +PyDoc_STRVAR(doc_to_eng_string,"\n\ +to_eng_string(context=None) - Convert to an engineering-type string.\n\ +Engineering notation has an exponent which is a multiple of 3, so there\n\ +are up to 3 digits left of the decimal place. For example, Decimal('123E+1')\n\ +is converted to Decimal('1.23E+3').\n\ \n\ The value of context.capitals determines whether the exponent sign is lower\n\ or upper case. Otherwise, the context does not affect the operation.\n\ \n"); -PyDoc_STRVAR(doc_to_integral, -"to_integral($self, /, rounding=None, context=None)\n--\n\n\ -Identical to the to_integral_value() method. The to_integral() name has been\n\ -kept for compatibility with older versions.\n\ +PyDoc_STRVAR(doc_to_integral,"\n\ +to_integral(rounding=None, context=None) - Identical to the\n\ +to_integral_value() method. The to_integral() name has been kept\n\ +for compatibility with older versions.\n\ \n"); -PyDoc_STRVAR(doc_to_integral_exact, -"to_integral_exact($self, /, rounding=None, context=None)\n--\n\n\ -Round to the nearest integer, signaling Inexact or Rounded as appropriate if\n\ -rounding occurs. The rounding mode is determined by the rounding parameter\n\ -if given, else by the given context. If neither parameter is given, then the\n\ -rounding mode of the current default context is used.\n\ +PyDoc_STRVAR(doc_to_integral_exact,"\n\ +to_integral_exact(rounding=None, context=None) - Round to the nearest\n\ +integer, signaling Inexact or Rounded as appropriate if rounding occurs.\n\ +The rounding mode is determined by the rounding parameter if given, else\n\ +by the given context. If neither parameter is given, then the rounding mode\n\ +of the current default context is used.\n\ \n"); -PyDoc_STRVAR(doc_to_integral_value, -"to_integral_value($self, /, rounding=None, context=None)\n--\n\n\ -Round to the nearest integer without signaling Inexact or Rounded. The\n\ -rounding mode is determined by the rounding parameter if given, else by\n\ -the given context. If neither parameter is given, then the rounding mode\n\ -of the current default context is used.\n\ +PyDoc_STRVAR(doc_to_integral_value,"\n\ +to_integral_value(rounding=None, context=None) - Round to the nearest\n\ +integer without signaling Inexact or Rounded. The rounding mode is determined\n\ +by the rounding parameter if given, else by the given context. If neither\n\ +parameter is given, then the rounding mode of the current default context is\n\ +used.\n\ \n"); @@ -485,10 +446,9 @@ /* Context Object and Methods */ /******************************************************************************/ -PyDoc_STRVAR(doc_context, -"Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None)\n--\n\n\ +PyDoc_STRVAR(doc_context,"\n\ The context affects almost all operations and controls rounding,\n\ -Over/Underflow, raising of exceptions and much more. A new context\n\ +Over/Underflow, raising of exceptions and much more. A new context\n\ can be constructed as follows:\n\ \n\ >>> c = Context(prec=28, Emin=-425000000, Emax=425000000,\n\ @@ -500,372 +460,308 @@ \n"); #ifdef EXTRA_FUNCTIONALITY -PyDoc_STRVAR(doc_ctx_apply, -"apply($self, x, /)\n--\n\n\ -Apply self to Decimal x.\n\ +PyDoc_STRVAR(doc_ctx_apply,"\n\ +apply(x) - Apply self to Decimal x.\n\ \n"); #endif -PyDoc_STRVAR(doc_ctx_clear_flags, -"clear_flags($self, /)\n--\n\n\ -Reset all flags to False.\n\ +PyDoc_STRVAR(doc_ctx_clear_flags,"\n\ +clear_flags() - Reset all flags to False.\n\ \n"); -PyDoc_STRVAR(doc_ctx_clear_traps, -"clear_traps($self, /)\n--\n\n\ -Set all traps to False.\n\ +PyDoc_STRVAR(doc_ctx_clear_traps,"\n\ +clear_traps() - Set all traps to False.\n\ \n"); -PyDoc_STRVAR(doc_ctx_copy, -"copy($self, /)\n--\n\n\ -Return a duplicate of the context with all flags cleared.\n\ +PyDoc_STRVAR(doc_ctx_copy,"\n\ +copy() - Return a duplicate of the context with all flags cleared.\n\ \n"); -PyDoc_STRVAR(doc_ctx_copy_decimal, -"copy_decimal($self, x, /)\n--\n\n\ -Return a copy of Decimal x.\n\ +PyDoc_STRVAR(doc_ctx_copy_decimal,"\n\ +copy_decimal(x) - Return a copy of Decimal x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_create_decimal, -"create_decimal($self, num=\"0\", /)\n--\n\n\ -Create a new Decimal instance from num, using self as the context. Unlike the\n\ -Decimal constructor, this function observes the context limits.\n\ +PyDoc_STRVAR(doc_ctx_create_decimal,"\n\ +create_decimal(x) - Create a new Decimal instance from x, using self as the\n\ +context. Unlike the Decimal constructor, this function observes the context\n\ +limits.\n\ \n"); -PyDoc_STRVAR(doc_ctx_create_decimal_from_float, -"create_decimal_from_float($self, f, /)\n--\n\n\ -Create a new Decimal instance from float f. Unlike the Decimal.from_float()\n\ -class method, this function observes the context limits.\n\ +PyDoc_STRVAR(doc_ctx_create_decimal_from_float,"\n\ +create_decimal_from_float(f) - Create a new Decimal instance from float f.\n\ +Unlike the Decimal.from_float() class method, this function observes the\n\ +context limits.\n\ \n"); -PyDoc_STRVAR(doc_ctx_Etiny, -"Etiny($self, /)\n--\n\n\ -Return a value equal to Emin - prec + 1, which is the minimum exponent value\n\ -for subnormal results. When underflow occurs, the exponent is set to Etiny.\n\ +PyDoc_STRVAR(doc_ctx_Etiny,"\n\ +Etiny() - Return a value equal to Emin - prec + 1, which is the minimum\n\ +exponent value for subnormal results. When underflow occurs, the exponent\n\ +is set to Etiny.\n\ \n"); -PyDoc_STRVAR(doc_ctx_Etop, -"Etop($self, /)\n--\n\n\ -Return a value equal to Emax - prec + 1. This is the maximum exponent\n\ -if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop()\n\ -must not be negative.\n\ +PyDoc_STRVAR(doc_ctx_Etop,"\n\ +Etop() - Return a value equal to Emax - prec + 1. This is the maximum exponent\n\ +if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop() must\n\ +not be negative.\n\ \n"); -PyDoc_STRVAR(doc_ctx_abs, -"abs($self, x, /)\n--\n\n\ -Return the absolute value of x.\n\ +PyDoc_STRVAR(doc_ctx_abs,"\n\ +abs(x) - Return the absolute value of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_add, -"add($self, x, y, /)\n--\n\n\ -Return the sum of x and y.\n\ +PyDoc_STRVAR(doc_ctx_add,"\n\ +add(x, y) - Return the sum of x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_canonical, -"canonical($self, x, /)\n--\n\n\ -Return a new instance of x.\n\ +PyDoc_STRVAR(doc_ctx_canonical,"\n\ +canonical(x) - Return a new instance of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_compare, -"compare($self, x, y, /)\n--\n\n\ -Compare x and y numerically.\n\ +PyDoc_STRVAR(doc_ctx_compare,"\n\ +compare(x, y) - Compare x and y numerically.\n\ \n"); -PyDoc_STRVAR(doc_ctx_compare_signal, -"compare_signal($self, x, y, /)\n--\n\n\ -Compare x and y numerically. All NaNs signal.\n\ +PyDoc_STRVAR(doc_ctx_compare_signal,"\n\ +compare_signal(x, y) - Compare x and y numerically. All NaNs signal.\n\ \n"); -PyDoc_STRVAR(doc_ctx_compare_total, -"compare_total($self, x, y, /)\n--\n\n\ -Compare x and y using their abstract representation.\n\ +PyDoc_STRVAR(doc_ctx_compare_total,"\n\ +compare_total(x, y) - Compare x and y using their abstract representation.\n\ \n"); -PyDoc_STRVAR(doc_ctx_compare_total_mag, -"compare_total_mag($self, x, y, /)\n--\n\n\ -Compare x and y using their abstract representation, ignoring sign.\n\ +PyDoc_STRVAR(doc_ctx_compare_total_mag,"\n\ +compare_total_mag(x, y) - Compare x and y using their abstract representation,\n\ +ignoring sign.\n\ \n"); -PyDoc_STRVAR(doc_ctx_copy_abs, -"copy_abs($self, x, /)\n--\n\n\ -Return a copy of x with the sign set to 0.\n\ +PyDoc_STRVAR(doc_ctx_copy_abs,"\n\ +copy_abs(x) - Return a copy of x with the sign set to 0.\n\ \n"); -PyDoc_STRVAR(doc_ctx_copy_negate, -"copy_negate($self, x, /)\n--\n\n\ -Return a copy of x with the sign inverted.\n\ +PyDoc_STRVAR(doc_ctx_copy_negate,"\n\ +copy_negate(x) - Return a copy of x with the sign inverted.\n\ \n"); -PyDoc_STRVAR(doc_ctx_copy_sign, -"copy_sign($self, x, y, /)\n--\n\n\ -Copy the sign from y to x.\n\ +PyDoc_STRVAR(doc_ctx_copy_sign,"\n\ +copy_sign(x, y) - Copy the sign from y to x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_divide, -"divide($self, x, y, /)\n--\n\n\ -Return x divided by y.\n\ +PyDoc_STRVAR(doc_ctx_divide,"\n\ +divide(x, y) - Return x divided by y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_divide_int, -"divide_int($self, x, y, /)\n--\n\n\ -Return x divided by y, truncated to an integer.\n\ +PyDoc_STRVAR(doc_ctx_divide_int,"\n\ +divide_int(x, y) - Return x divided by y, truncated to an integer.\n\ \n"); -PyDoc_STRVAR(doc_ctx_divmod, -"divmod($self, x, y, /)\n--\n\n\ -Return quotient and remainder of the division x / y.\n\ +PyDoc_STRVAR(doc_ctx_divmod,"\n\ +divmod(x, y) - Return quotient and remainder of the division x / y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_exp, -"exp($self, x, /)\n--\n\n\ -Return e ** x.\n\ +PyDoc_STRVAR(doc_ctx_exp,"\n\ +exp(x) - Return e ** x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_fma, -"fma($self, x, y, z, /)\n--\n\n\ -Return x multiplied by y, plus z.\n\ +PyDoc_STRVAR(doc_ctx_fma,"\n\ +fma(x, y, z) - Return x multiplied by y, plus z.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_canonical, -"is_canonical($self, x, /)\n--\n\n\ -Return True if x is canonical, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_canonical,"\n\ +is_canonical(x) - Return True if x is canonical, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_finite, -"is_finite($self, x, /)\n--\n\n\ -Return True if x is finite, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_finite,"\n\ +is_finite(x) - Return True if x is finite, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_infinite, -"is_infinite($self, x, /)\n--\n\n\ -Return True if x is infinite, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_infinite,"\n\ +is_infinite(x) - Return True if x is infinite, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_nan, -"is_nan($self, x, /)\n--\n\n\ -Return True if x is a qNaN or sNaN, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_nan,"\n\ +is_nan(x) - Return True if x is a qNaN or sNaN, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_normal, -"is_normal($self, x, /)\n--\n\n\ -Return True if x is a normal number, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_normal,"\n\ +is_normal(x) - Return True if x is a normal number, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_qnan, -"is_qnan($self, x, /)\n--\n\n\ -Return True if x is a quiet NaN, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_qnan,"\n\ +is_qnan(x) - Return True if x is a quiet NaN, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_signed, -"is_signed($self, x, /)\n--\n\n\ -Return True if x is negative, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_signed,"\n\ +is_signed(x) - Return True if x is negative, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_snan, -"is_snan($self, x, /)\n--\n\n\ -Return True if x is a signaling NaN, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_snan,"\n\ +is_snan() - Return True if x is a signaling NaN, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_subnormal, -"is_subnormal($self, x, /)\n--\n\n\ -Return True if x is subnormal, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_subnormal,"\n\ +is_subnormal(x) - Return True if x is subnormal, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_is_zero, -"is_zero($self, x, /)\n--\n\n\ -Return True if x is a zero, False otherwise.\n\ +PyDoc_STRVAR(doc_ctx_is_zero,"\n\ +is_zero(x) - Return True if x is a zero, False otherwise.\n\ \n"); -PyDoc_STRVAR(doc_ctx_ln, -"ln($self, x, /)\n--\n\n\ -Return the natural (base e) logarithm of x.\n\ +PyDoc_STRVAR(doc_ctx_ln,"\n\ +ln(x) - Return the natural (base e) logarithm of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_log10, -"log10($self, x, /)\n--\n\n\ -Return the base 10 logarithm of x.\n\ +PyDoc_STRVAR(doc_ctx_log10,"\n\ +log10(x) - Return the base 10 logarithm of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_logb, -"logb($self, x, /)\n--\n\n\ -Return the exponent of the magnitude of the operand's MSD.\n\ +PyDoc_STRVAR(doc_ctx_logb,"\n\ +logb(x) - Return the exponent of the magnitude of the operand's MSD.\n\ \n"); -PyDoc_STRVAR(doc_ctx_logical_and, -"logical_and($self, x, y, /)\n--\n\n\ -Digit-wise and of x and y.\n\ +PyDoc_STRVAR(doc_ctx_logical_and,"\n\ +logical_and(x, y) - Digit-wise and of x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_logical_invert, -"logical_invert($self, x, /)\n--\n\n\ -Invert all digits of x.\n\ +PyDoc_STRVAR(doc_ctx_logical_invert,"\n\ +logical_invert(x) - Invert all digits of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_logical_or, -"logical_or($self, x, y, /)\n--\n\n\ -Digit-wise or of x and y.\n\ +PyDoc_STRVAR(doc_ctx_logical_or,"\n\ +logical_or(x, y) - Digit-wise or of x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_logical_xor, -"logical_xor($self, x, y, /)\n--\n\n\ -Digit-wise xor of x and y.\n\ +PyDoc_STRVAR(doc_ctx_logical_xor,"\n\ +logical_xor(x, y) - Digit-wise xor of x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_max, -"max($self, x, y, /)\n--\n\n\ -Compare the values numerically and return the maximum.\n\ +PyDoc_STRVAR(doc_ctx_max,"\n\ +max(x, y) - Compare the values numerically and return the maximum.\n\ \n"); -PyDoc_STRVAR(doc_ctx_max_mag, -"max_mag($self, x, y, /)\n--\n\n\ -Compare the values numerically with their sign ignored.\n\ +PyDoc_STRVAR(doc_ctx_max_mag,"\n\ +max_mag(x, y) - Compare the values numerically with their sign ignored.\n\ \n"); -PyDoc_STRVAR(doc_ctx_min, -"min($self, x, y, /)\n--\n\n\ -Compare the values numerically and return the minimum.\n\ +PyDoc_STRVAR(doc_ctx_min,"\n\ +min(x, y) - Compare the values numerically and return the minimum.\n\ \n"); -PyDoc_STRVAR(doc_ctx_min_mag, -"min_mag($self, x, y, /)\n--\n\n\ -Compare the values numerically with their sign ignored.\n\ +PyDoc_STRVAR(doc_ctx_min_mag,"\n\ +min_mag(x, y) - Compare the values numerically with their sign ignored.\n\ \n"); -PyDoc_STRVAR(doc_ctx_minus, -"minus($self, x, /)\n--\n\n\ -Minus corresponds to the unary prefix minus operator in Python, but applies\n\ -the context to the result.\n\ +PyDoc_STRVAR(doc_ctx_minus,"\n\ +minus(x) - Minus corresponds to the unary prefix minus operator in Python,\n\ +but applies the context to the result.\n\ \n"); -PyDoc_STRVAR(doc_ctx_multiply, -"multiply($self, x, y, /)\n--\n\n\ -Return the product of x and y.\n\ +PyDoc_STRVAR(doc_ctx_multiply,"\n\ +multiply(x, y) - Return the product of x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_next_minus, -"next_minus($self, x, /)\n--\n\n\ -Return the largest representable number smaller than x.\n\ +PyDoc_STRVAR(doc_ctx_next_minus,"\n\ +next_minus(x) - Return the largest representable number smaller than x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_next_plus, -"next_plus($self, x, /)\n--\n\n\ -Return the smallest representable number larger than x.\n\ +PyDoc_STRVAR(doc_ctx_next_plus,"\n\ +next_plus(x) - Return the smallest representable number larger than x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_next_toward, -"next_toward($self, x, y, /)\n--\n\n\ -Return the number closest to x, in the direction towards y.\n\ +PyDoc_STRVAR(doc_ctx_next_toward,"\n\ +next_toward(x) - Return the number closest to x, in the direction towards y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_normalize, -"normalize($self, x, /)\n--\n\n\ -Reduce x to its simplest form. Alias for reduce(x).\n\ +PyDoc_STRVAR(doc_ctx_normalize,"\n\ +normalize(x) - Reduce x to its simplest form. Alias for reduce(x).\n\ \n"); -PyDoc_STRVAR(doc_ctx_number_class, -"number_class($self, x, /)\n--\n\n\ -Return an indication of the class of x.\n\ +PyDoc_STRVAR(doc_ctx_number_class,"\n\ +number_class(x) - Return an indication of the class of x.\n\ \n"); -PyDoc_STRVAR(doc_ctx_plus, -"plus($self, x, /)\n--\n\n\ -Plus corresponds to the unary prefix plus operator in Python, but applies\n\ -the context to the result.\n\ +PyDoc_STRVAR(doc_ctx_plus,"\n\ +plus(x) - Plus corresponds to the unary prefix plus operator in Python,\n\ +but applies the context to the result.\n\ \n"); -PyDoc_STRVAR(doc_ctx_power, -"power($self, /, a, b, modulo=None)\n--\n\n\ -Compute a**b. If 'a' is negative, then 'b' must be integral. The result\n\ -will be inexact unless 'a' is integral and the result is finite and can\n\ -be expressed exactly in 'precision' digits. In the Python version the\n\ -result is always correctly rounded, in the C version the result is almost\n\ -always correctly rounded.\n\ +PyDoc_STRVAR(doc_ctx_power,"\n\ +power(x, y) - Compute x**y. If x is negative, then y must be integral.\n\ +The result will be inexact unless y is integral and the result is finite\n\ +and can be expressed exactly in 'precision' digits. In the Python version\n\ +the result is always correctly rounded, in the C version the result is\n\ +almost always correctly rounded.\n\ \n\ -If modulo is given, compute (a**b) % modulo. The following restrictions\n\ -hold:\n\ +power(x, y, m) - Compute (x**y) % m. The following restrictions hold:\n\ \n\ * all three arguments must be integral\n\ - * 'b' must be nonnegative\n\ - * at least one of 'a' or 'b' must be nonzero\n\ - * modulo must be nonzero and less than 10**prec in absolute value\n\ + * y must be nonnegative\n\ + * at least one of x or y must be nonzero\n\ + * m must be nonzero and less than 10**prec in absolute value\n\ \n\ \n"); -PyDoc_STRVAR(doc_ctx_quantize, -"quantize($self, x, y, /)\n--\n\n\ -Return a value equal to x (rounded), having the exponent of y.\n\ +PyDoc_STRVAR(doc_ctx_quantize,"\n\ +quantize(x, y) - Return a value equal to x (rounded), having the exponent of y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_radix, -"radix($self, /)\n--\n\n\ -Return 10.\n\ +PyDoc_STRVAR(doc_ctx_radix,"\n\ +radix() - Return 10.\n\ \n"); -PyDoc_STRVAR(doc_ctx_remainder, -"remainder($self, x, y, /)\n--\n\n\ -Return the remainder from integer division. The sign of the result,\n\ -if non-zero, is the same as that of the original dividend.\n\ +PyDoc_STRVAR(doc_ctx_remainder,"\n\ +remainder(x, y) - Return the remainder from integer division. The sign of\n\ +the result, if non-zero, is the same as that of the original dividend.\n\ \n"); -PyDoc_STRVAR(doc_ctx_remainder_near, -"remainder_near($self, x, y, /)\n--\n\n\ -Return x - y * n, where n is the integer nearest the exact value of x / y\n\ -(if the result is 0 then its sign will be the sign of x).\n\ +PyDoc_STRVAR(doc_ctx_remainder_near,"\n\ +remainder_near(x, y) - Return x - y * n, where n is the integer nearest the\n\ +exact value of x / y (if the result is 0 then its sign will be the sign of x).\n\ \n"); -PyDoc_STRVAR(doc_ctx_rotate, -"rotate($self, x, y, /)\n--\n\n\ -Return a copy of x, rotated by y places.\n\ +PyDoc_STRVAR(doc_ctx_rotate,"\n\ +rotate(x, y) - Return a copy of x, rotated by y places.\n\ \n"); -PyDoc_STRVAR(doc_ctx_same_quantum, -"same_quantum($self, x, y, /)\n--\n\n\ -Return True if the two operands have the same exponent.\n\ +PyDoc_STRVAR(doc_ctx_same_quantum,"\n\ +same_quantum(x, y) - Return True if the two operands have the same exponent.\n\ \n"); -PyDoc_STRVAR(doc_ctx_scaleb, -"scaleb($self, x, y, /)\n--\n\n\ -Return the first operand after adding the second value to its exp.\n\ +PyDoc_STRVAR(doc_ctx_scaleb,"\n\ +scaleb(x, y) - Return the first operand after adding the second value\n\ +to its exp.\n\ \n"); -PyDoc_STRVAR(doc_ctx_shift, -"shift($self, x, y, /)\n--\n\n\ -Return a copy of x, shifted by y places.\n\ +PyDoc_STRVAR(doc_ctx_shift,"\n\ +shift(x, y) - Return a copy of x, shifted by y places.\n\ \n"); -PyDoc_STRVAR(doc_ctx_sqrt, -"sqrt($self, x, /)\n--\n\n\ -Square root of a non-negative number to context precision.\n\ +PyDoc_STRVAR(doc_ctx_sqrt,"\n\ +sqrt(x) - Square root of a non-negative number to context precision.\n\ \n"); -PyDoc_STRVAR(doc_ctx_subtract, -"subtract($self, x, y, /)\n--\n\n\ -Return the difference between x and y.\n\ +PyDoc_STRVAR(doc_ctx_subtract,"\n\ +subtract(x, y) - Return the difference between x and y.\n\ \n"); -PyDoc_STRVAR(doc_ctx_to_eng_string, -"to_eng_string($self, x, /)\n--\n\n\ -Convert a number to a string, using engineering notation.\n\ +PyDoc_STRVAR(doc_ctx_to_eng_string,"\n\ +to_eng_string(x) - Convert a number to a string, using engineering notation.\n\ \n"); -PyDoc_STRVAR(doc_ctx_to_integral, -"to_integral($self, x, /)\n--\n\n\ -Identical to to_integral_value(x).\n\ +PyDoc_STRVAR(doc_ctx_to_integral,"\n\ +to_integral(x) - Identical to to_integral_value(x).\n\ \n"); -PyDoc_STRVAR(doc_ctx_to_integral_exact, -"to_integral_exact($self, x, /)\n--\n\n\ -Round to an integer. Signal if the result is rounded or inexact.\n\ +PyDoc_STRVAR(doc_ctx_to_integral_exact,"\n\ +to_integral_exact(x) - Round to an integer. Signal if the result is\n\ +rounded or inexact.\n\ \n"); -PyDoc_STRVAR(doc_ctx_to_integral_value, -"to_integral_value($self, x, /)\n--\n\n\ -Round to an integer.\n\ +PyDoc_STRVAR(doc_ctx_to_integral_value,"\n\ +to_integral_value(x) - Round to an integer.\n\ \n"); -PyDoc_STRVAR(doc_ctx_to_sci_string, -"to_sci_string($self, x, /)\n--\n\n\ -Convert a number to a string using scientific notation.\n\ +PyDoc_STRVAR(doc_ctx_to_sci_string,"\n\ +to_sci_string(x) - Convert a number to a string using scientific notation.\n\ \n"); diff -r ce070040e1a6 -r d7f128afe9db Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_heapqmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -11,9 +11,10 @@ static int _siftdown(PyListObject *heap, Py_ssize_t startpos, Py_ssize_t pos) { - PyObject *newitem, *parent; - Py_ssize_t parentpos, size; + PyObject *newitem, *parent, *olditem; int cmp; + Py_ssize_t parentpos; + Py_ssize_t size; assert(PyList_Check(heap)); size = PyList_GET_SIZE(heap); @@ -22,75 +23,103 @@ return -1; } + newitem = PyList_GET_ITEM(heap, pos); + Py_INCREF(newitem); /* Follow the path to the root, moving parents down until finding a place newitem fits. */ - newitem = PyList_GET_ITEM(heap, pos); - while (pos > startpos) { + while (pos > startpos){ parentpos = (pos - 1) >> 1; parent = PyList_GET_ITEM(heap, parentpos); cmp = PyObject_RichCompareBool(newitem, parent, Py_LT); - if (cmp == -1) + if (cmp == -1) { + Py_DECREF(newitem); return -1; + } if (size != PyList_GET_SIZE(heap)) { + Py_DECREF(newitem); PyErr_SetString(PyExc_RuntimeError, "list changed size during iteration"); return -1; } if (cmp == 0) break; - parent = PyList_GET_ITEM(heap, parentpos); - newitem = PyList_GET_ITEM(heap, pos); - PyList_SET_ITEM(heap, parentpos, newitem); + Py_INCREF(parent); + olditem = PyList_GET_ITEM(heap, pos); PyList_SET_ITEM(heap, pos, parent); + Py_DECREF(olditem); pos = parentpos; + if (size != PyList_GET_SIZE(heap)) { + PyErr_SetString(PyExc_RuntimeError, + "list changed size during iteration"); + return -1; + } } + Py_DECREF(PyList_GET_ITEM(heap, pos)); + PyList_SET_ITEM(heap, pos, newitem); return 0; } static int _siftup(PyListObject *heap, Py_ssize_t pos) { - Py_ssize_t startpos, endpos, childpos, rightpos, limit; - PyObject *tmp1, *tmp2; + Py_ssize_t startpos, endpos, childpos, rightpos; int cmp; + PyObject *newitem, *tmp, *olditem; + Py_ssize_t size; assert(PyList_Check(heap)); - endpos = PyList_GET_SIZE(heap); + size = PyList_GET_SIZE(heap); + endpos = size; startpos = pos; if (pos >= endpos) { PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } + newitem = PyList_GET_ITEM(heap, pos); + Py_INCREF(newitem); /* Bubble up the smaller child until hitting a leaf. */ - limit = endpos / 2; /* smallest pos that has no child */ - while (pos < limit) { + childpos = 2*pos + 1; /* leftmost child position */ + while (childpos < endpos) { /* Set childpos to index of smaller child. */ - childpos = 2*pos + 1; /* leftmost child position */ rightpos = childpos + 1; if (rightpos < endpos) { cmp = PyObject_RichCompareBool( PyList_GET_ITEM(heap, childpos), PyList_GET_ITEM(heap, rightpos), Py_LT); - if (cmp == -1) + if (cmp == -1) { + Py_DECREF(newitem); return -1; + } if (cmp == 0) childpos = rightpos; - if (endpos != PyList_GET_SIZE(heap)) { - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } + } + if (size != PyList_GET_SIZE(heap)) { + Py_DECREF(newitem); + PyErr_SetString(PyExc_RuntimeError, + "list changed size during iteration"); + return -1; } /* Move the smaller child up. */ - tmp1 = PyList_GET_ITEM(heap, childpos); - tmp2 = PyList_GET_ITEM(heap, pos); - PyList_SET_ITEM(heap, childpos, tmp2); - PyList_SET_ITEM(heap, pos, tmp1); + tmp = PyList_GET_ITEM(heap, childpos); + Py_INCREF(tmp); + olditem = PyList_GET_ITEM(heap, pos); + PyList_SET_ITEM(heap, pos, tmp); + Py_DECREF(olditem); pos = childpos; + childpos = 2*pos + 1; + if (size != PyList_GET_SIZE(heap)) { + PyErr_SetString(PyExc_RuntimeError, + "list changed size during iteration"); + return -1; + } } - /* Bubble it up to its final resting place (by sifting its parents down). */ + + /* The leaf at pos is empty now. Put newitem there, and bubble + it up to its final resting place (by sifting its parents down). */ + Py_DECREF(PyList_GET_ITEM(heap, pos)); + PyList_SET_ITEM(heap, pos, newitem); return _siftdown(heap, startpos, pos); } @@ -354,47 +383,45 @@ _siftdownmax(PyListObject *heap, Py_ssize_t startpos, Py_ssize_t pos) { PyObject *newitem, *parent; - Py_ssize_t parentpos, size; int cmp; + Py_ssize_t parentpos; assert(PyList_Check(heap)); - size = PyList_GET_SIZE(heap); - if (pos >= size) { + if (pos >= PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } + newitem = PyList_GET_ITEM(heap, pos); + Py_INCREF(newitem); /* Follow the path to the root, moving parents down until finding a place newitem fits. */ - newitem = PyList_GET_ITEM(heap, pos); - while (pos > startpos) { + while (pos > startpos){ parentpos = (pos - 1) >> 1; parent = PyList_GET_ITEM(heap, parentpos); cmp = PyObject_RichCompareBool(parent, newitem, Py_LT); - if (cmp == -1) - return -1; - if (size != PyList_GET_SIZE(heap)) { - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); + if (cmp == -1) { + Py_DECREF(newitem); return -1; } if (cmp == 0) break; - parent = PyList_GET_ITEM(heap, parentpos); - newitem = PyList_GET_ITEM(heap, pos); - PyList_SET_ITEM(heap, parentpos, newitem); + Py_INCREF(parent); + Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, parent); pos = parentpos; } + Py_DECREF(PyList_GET_ITEM(heap, pos)); + PyList_SET_ITEM(heap, pos, newitem); return 0; } static int _siftupmax(PyListObject *heap, Py_ssize_t pos) { - Py_ssize_t startpos, endpos, childpos, rightpos, limit; - PyObject *tmp1, *tmp2; + Py_ssize_t startpos, endpos, childpos, rightpos; int cmp; + PyObject *newitem, *tmp; assert(PyList_Check(heap)); endpos = PyList_GET_SIZE(heap); @@ -403,36 +430,39 @@ PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } + newitem = PyList_GET_ITEM(heap, pos); + Py_INCREF(newitem); /* Bubble up the smaller child until hitting a leaf. */ - limit = endpos / 2; /* smallest pos that has no child */ - while (pos < limit) { + childpos = 2*pos + 1; /* leftmost child position */ + while (childpos < endpos) { /* Set childpos to index of smaller child. */ - childpos = 2*pos + 1; /* leftmost child position */ rightpos = childpos + 1; if (rightpos < endpos) { cmp = PyObject_RichCompareBool( PyList_GET_ITEM(heap, rightpos), PyList_GET_ITEM(heap, childpos), Py_LT); - if (cmp == -1) + if (cmp == -1) { + Py_DECREF(newitem); return -1; + } if (cmp == 0) childpos = rightpos; - if (endpos != PyList_GET_SIZE(heap)) { - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } } /* Move the smaller child up. */ - tmp1 = PyList_GET_ITEM(heap, childpos); - tmp2 = PyList_GET_ITEM(heap, pos); - PyList_SET_ITEM(heap, childpos, tmp2); - PyList_SET_ITEM(heap, pos, tmp1); + tmp = PyList_GET_ITEM(heap, childpos); + Py_INCREF(tmp); + Py_DECREF(PyList_GET_ITEM(heap, pos)); + PyList_SET_ITEM(heap, pos, tmp); pos = childpos; + childpos = 2*pos + 1; } - /* Bubble it up to its final resting place (by sifting its parents down). */ + + /* The leaf at pos is empty now. Put newitem there, and bubble + it up to its final resting place (by sifting its parents down). */ + Py_DECREF(PyList_GET_ITEM(heap, pos)); + PyList_SET_ITEM(heap, pos, newitem); return _siftdownmax(heap, startpos, pos); } diff -r ce070040e1a6 -r d7f128afe9db Modules/_io/iobase.c --- a/Modules/_io/iobase.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_io/iobase.c Sun Mar 23 09:44:28 2014 +0100 @@ -42,8 +42,8 @@ "bytes. bytearrays are accepted too, and in some cases (such as\n" "readinto) needed. Text I/O classes work with str data.\n" "\n" - "Note that calling any method (except additional calls to close(),\n" - "which are ignored) on a closed stream should raise a ValueError.\n" + "Note that calling any method (even inquiries) on a closed stream is\n" + "undefined. Implementations may raise IOError in this case.\n" "\n" "IOBase (and its subclasses) support the iterator protocol, meaning\n" "that an IOBase object can be iterated over yielding the lines in a\n" diff -r ce070040e1a6 -r d7f128afe9db Modules/_io/textio.c --- a/Modules/_io/textio.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_io/textio.c Sun Mar 23 09:44:28 2014 +0100 @@ -1297,7 +1297,7 @@ PyObject *b; Py_ssize_t textlen; int haslf = 0; - int needflush = 0, text_needflush = 0; + int needflush = 0; CHECK_INITIALIZED(self); @@ -1331,8 +1331,8 @@ } if (self->write_through) - text_needflush = 1; - if (self->line_buffering && + needflush = 1; + else if (self->line_buffering && (haslf || PyUnicode_FindChar(text, '\r', 0, PyUnicode_GET_LENGTH(text), 1) != -1)) needflush = 1; @@ -1363,8 +1363,7 @@ } self->pending_bytes_count += PyBytes_GET_SIZE(b); Py_DECREF(b); - if (self->pending_bytes_count > self->chunk_size || needflush || - text_needflush) { + if (self->pending_bytes_count > self->chunk_size || needflush) { if (_textiowrapper_writeflush(self) < 0) return NULL; } @@ -1440,7 +1439,6 @@ PyObject *dec_buffer = NULL; PyObject *dec_flags = NULL; PyObject *input_chunk = NULL; - Py_buffer input_chunk_buf; PyObject *decoded_chars, *chunk_size; Py_ssize_t nbytes, nchars; int eof; @@ -1472,15 +1470,6 @@ Py_DECREF(state); return -1; } - - if (!PyBytes_Check(dec_buffer)) { - PyErr_Format(PyExc_TypeError, - "decoder getstate() should have returned a bytes " - "object, not '%.200s'", - Py_TYPE(dec_buffer)->tp_name); - Py_DECREF(state); - return -1; - } Py_INCREF(dec_buffer); Py_INCREF(dec_flags); Py_DECREF(state); @@ -1493,24 +1482,23 @@ chunk_size = PyLong_FromSsize_t(Py_MAX(self->chunk_size, size_hint)); if (chunk_size == NULL) goto fail; - input_chunk = PyObject_CallMethodObjArgs(self->buffer, (self->has_read1 ? _PyIO_str_read1: _PyIO_str_read), chunk_size, NULL); Py_DECREF(chunk_size); if (input_chunk == NULL) goto fail; - - if (PyObject_GetBuffer(input_chunk, &input_chunk_buf, 0) != 0) { + if (!PyBytes_Check(input_chunk)) { PyErr_Format(PyExc_TypeError, - "underlying %s() should have returned a bytes-like object, " + "underlying %s() should have returned a bytes object, " "not '%.200s'", (self->has_read1 ? "read1": "read"), Py_TYPE(input_chunk)->tp_name); goto fail; } - nbytes = input_chunk_buf.len; + nbytes = PyBytes_Size(input_chunk); eof = (nbytes == 0); + if (Py_TYPE(self->decoder) == &PyIncrementalNewlineDecoder_Type) { decoded_chars = _PyIncrementalNewlineDecoder_decode( self->decoder, input_chunk, eof); @@ -1519,7 +1507,6 @@ decoded_chars = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode, input_chunk, eof ? Py_True : Py_False, NULL); } - PyBuffer_Release(&input_chunk_buf); if (check_decoded(decoded_chars) < 0) goto fail; @@ -1536,12 +1523,18 @@ /* At the snapshot point, len(dec_buffer) bytes before the read, the * next input to be decoded is dec_buffer + input_chunk. */ - PyObject *next_input = dec_buffer; - PyBytes_Concat(&next_input, input_chunk); - if (next_input == NULL) { - dec_buffer = NULL; /* Reference lost to PyBytes_Concat */ + PyObject *next_input = PyNumber_Add(dec_buffer, input_chunk); + if (next_input == NULL) + goto fail; + if (!PyBytes_Check(next_input)) { + PyErr_Format(PyExc_TypeError, + "decoder getstate() should have returned a bytes " + "object, not '%.200s'", + Py_TYPE(next_input)->tp_name); + Py_DECREF(next_input); goto fail; } + Py_DECREF(dec_buffer); Py_CLEAR(self->snapshot); self->snapshot = Py_BuildValue("NN", dec_flags, next_input); } diff -r ce070040e1a6 -r d7f128afe9db Modules/_json.c --- a/Modules/_json.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_json.c Sun Mar 23 09:44:28 2014 +0100 @@ -941,10 +941,6 @@ kind = PyUnicode_KIND(pystr); length = PyUnicode_GET_LENGTH(pystr); - if (idx < 0) { - PyErr_SetString(PyExc_ValueError, "idx cannot be negative"); - return NULL; - } if (idx >= length) { raise_stop_iteration(idx); return NULL; diff -r ce070040e1a6 -r d7f128afe9db Modules/_operator.c --- a/Modules/_operator.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_operator.c Sun Mar 23 09:44:28 2014 +0100 @@ -69,7 +69,6 @@ spam2(op_add , PyNumber_Add) spam2(op_sub , PyNumber_Subtract) spam2(op_mul , PyNumber_Multiply) -spam2(op_matmul , PyNumber_MatrixMultiply) spam2(op_floordiv , PyNumber_FloorDivide) spam2(op_truediv , PyNumber_TrueDivide) spam2(op_mod , PyNumber_Remainder) @@ -87,7 +86,6 @@ spam2(op_iadd , PyNumber_InPlaceAdd) spam2(op_isub , PyNumber_InPlaceSubtract) spam2(op_imul , PyNumber_InPlaceMultiply) -spam2(op_imatmul , PyNumber_InPlaceMatrixMultiply) spam2(op_ifloordiv , PyNumber_InPlaceFloorDivide) spam2(op_itruediv , PyNumber_InPlaceTrueDivide) spam2(op_imod , PyNumber_InPlaceRemainder) @@ -345,7 +343,6 @@ spam2(add, "add(a, b) -- Same as a + b.") spam2(sub, "sub(a, b) -- Same as a - b.") spam2(mul, "mul(a, b) -- Same as a * b.") -spam2(matmul, "matmul(a, b) -- Same as a @ b.") spam2(floordiv, "floordiv(a, b) -- Same as a // b.") spam2(truediv, "truediv(a, b) -- Same as a / b.") spam2(mod, "mod(a, b) -- Same as a % b.") @@ -363,7 +360,6 @@ spam2(iadd, "a = iadd(a, b) -- Same as a += b.") spam2(isub, "a = isub(a, b) -- Same as a -= b.") spam2(imul, "a = imul(a, b) -- Same as a *= b.") -spam2(imatmul, "a = imatmul(a, b) -- Same as a @= b.") spam2(ifloordiv, "a = ifloordiv(a, b) -- Same as a //= b.") spam2(itruediv, "a = itruediv(a, b) -- Same as a /= b") spam2(imod, "a = imod(a, b) -- Same as a %= b.") diff -r ce070040e1a6 -r d7f128afe9db Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_posixsubprocess.c Sun Mar 23 09:44:28 2014 +0100 @@ -18,12 +18,6 @@ #include #endif -#if defined(__ANDROID__) && !defined(SYS_getdents64) -/* Android doesn't expose syscalls, add the definition manually. */ -# include -# define SYS_getdents64 __NR_getdents64 -#endif - #if defined(sun) /* readdir64 is used to work around Solaris 9 bug 6395699. */ # define readdir readdir64 diff -r ce070040e1a6 -r d7f128afe9db Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_testcapimodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -2710,20 +2710,6 @@ { void *ptr; - ptr = PyMem_RawMalloc(0); - if (ptr == NULL) { - PyErr_SetString(PyExc_RuntimeError, "PyMem_RawMalloc(0) returns NULL"); - return NULL; - } - PyMem_RawFree(ptr); - - ptr = PyMem_RawCalloc(0, 0); - if (ptr == NULL) { - PyErr_SetString(PyExc_RuntimeError, "PyMem_RawCalloc(0, 0) returns NULL"); - return NULL; - } - PyMem_RawFree(ptr); - ptr = PyMem_Malloc(0); if (ptr == NULL) { PyErr_SetString(PyExc_RuntimeError, "PyMem_Malloc(0) returns NULL"); @@ -2731,13 +2717,6 @@ } PyMem_Free(ptr); - ptr = PyMem_Calloc(0, 0); - if (ptr == NULL) { - PyErr_SetString(PyExc_RuntimeError, "PyMem_Calloc(0, 0) returns NULL"); - return NULL; - } - PyMem_Free(ptr); - ptr = PyObject_Malloc(0); if (ptr == NULL) { PyErr_SetString(PyExc_RuntimeError, "PyObject_Malloc(0) returns NULL"); @@ -2745,13 +2724,6 @@ } PyObject_Free(ptr); - ptr = PyObject_Calloc(0, 0); - if (ptr == NULL) { - PyErr_SetString(PyExc_RuntimeError, "PyObject_Calloc(0, 0) returns NULL"); - return NULL; - } - PyObject_Free(ptr); - Py_RETURN_NONE; } @@ -2759,8 +2731,6 @@ PyMemAllocator alloc; size_t malloc_size; - size_t calloc_nelem; - size_t calloc_elsize; void *realloc_ptr; size_t realloc_new_size; void *free_ptr; @@ -2773,14 +2743,6 @@ return hook->alloc.malloc(hook->alloc.ctx, size); } -static void* hook_calloc (void* ctx, size_t nelem, size_t elsize) -{ - alloc_hook_t *hook = (alloc_hook_t *)ctx; - hook->calloc_nelem = nelem; - hook->calloc_elsize = elsize; - return hook->alloc.calloc(hook->alloc.ctx, nelem, elsize); -} - static void* hook_realloc (void* ctx, void* ptr, size_t new_size) { alloc_hook_t *hook = (alloc_hook_t *)ctx; @@ -2803,14 +2765,16 @@ const char *error_msg; alloc_hook_t hook; PyMemAllocator alloc; - size_t size, size2, nelem, elsize; + size_t size, size2; void *ptr, *ptr2; - memset(&hook, 0, sizeof(hook)); + hook.malloc_size = 0; + hook.realloc_ptr = NULL; + hook.realloc_new_size = 0; + hook.free_ptr = NULL; alloc.ctx = &hook; alloc.malloc = &hook_malloc; - alloc.calloc = &hook_calloc; alloc.realloc = &hook_realloc; alloc.free = &hook_free; PyMem_GetAllocator(domain, &hook.alloc); @@ -2867,33 +2831,6 @@ goto fail; } - nelem = 2; - elsize = 5; - switch(domain) - { - case PYMEM_DOMAIN_RAW: ptr = PyMem_RawCalloc(nelem, elsize); break; - case PYMEM_DOMAIN_MEM: ptr = PyMem_Calloc(nelem, elsize); break; - case PYMEM_DOMAIN_OBJ: ptr = PyObject_Calloc(nelem, elsize); break; - default: ptr = NULL; break; - } - - if (ptr == NULL) { - error_msg = "calloc failed"; - goto fail; - } - - if (hook.calloc_nelem != nelem || hook.calloc_elsize != elsize) { - error_msg = "calloc invalid nelem or elsize"; - goto fail; - } - - switch(domain) - { - case PYMEM_DOMAIN_RAW: PyMem_RawFree(ptr); break; - case PYMEM_DOMAIN_MEM: PyMem_Free(ptr); break; - case PYMEM_DOMAIN_OBJ: PyObject_Free(ptr); break; - } - Py_INCREF(Py_None); res = Py_None; goto finally; @@ -3361,109 +3298,6 @@ }; -typedef struct { - PyObject_HEAD -} matmulObject; - -static PyObject * -matmulType_matmul(PyObject *self, PyObject *other) -{ - return Py_BuildValue("(sOO)", "matmul", self, other); -} - -static PyObject * -matmulType_imatmul(PyObject *self, PyObject *other) -{ - return Py_BuildValue("(sOO)", "imatmul", self, other); -} - -static void -matmulType_dealloc(PyObject *self) -{ - Py_TYPE(self)->tp_free(self); -} - -static PyNumberMethods matmulType_as_number = { - 0, /* nb_add */ - 0, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_remainde r*/ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* tp_positive */ - 0, /* tp_absolute */ - 0, /* tp_bool */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - 0, /* nb_and */ - 0, /* nb_xor */ - 0, /* nb_or */ - 0, /* nb_int */ - 0, /* nb_reserved */ - 0, /* nb_float */ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - 0, /* nb_floor_divide */ - 0, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ - 0, /* nb_index */ - matmulType_matmul, /* nb_matrix_multiply */ - matmulType_imatmul /* nb_matrix_inplace_multiply */ -}; - -static PyTypeObject matmulType = { - PyVarObject_HEAD_INIT(NULL, 0) - "matmulType", - sizeof(matmulObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - matmulType_dealloc, /* destructor tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - &matmulType_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - "C level type with matrix operations defined", - 0, /* traverseproc tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - PyType_GenericNew, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - static struct PyModuleDef _testcapimodule = { PyModuleDef_HEAD_INIT, @@ -3493,10 +3327,6 @@ /* don't use a name starting with "test", since we don't want test_capi to automatically call this */ PyModule_AddObject(m, "_test_structmembersType", (PyObject *)&test_structmembersType); - if (PyType_Ready(&matmulType) < 0) - return NULL; - Py_INCREF(&matmulType); - PyModule_AddObject(m, "matmulType", (PyObject *)&matmulType); PyModule_AddObject(m, "CHAR_MAX", PyLong_FromLong(CHAR_MAX)); PyModule_AddObject(m, "CHAR_MIN", PyLong_FromLong(CHAR_MIN)); diff -r ce070040e1a6 -r d7f128afe9db Modules/_tracemalloc.c --- a/Modules/_tracemalloc.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_tracemalloc.c Sun Mar 23 09:44:28 2014 +0100 @@ -476,22 +476,17 @@ } static void* -tracemalloc_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) +tracemalloc_malloc(void *ctx, size_t size) { PyMemAllocator *alloc = (PyMemAllocator *)ctx; void *ptr; - assert(nelem <= PY_SIZE_MAX / elsize); - - if (use_calloc) - ptr = alloc->calloc(alloc->ctx, nelem, elsize); - else - ptr = alloc->malloc(alloc->ctx, nelem * elsize); + ptr = alloc->malloc(alloc->ctx, size); if (ptr == NULL) return NULL; TABLES_LOCK(); - if (tracemalloc_add_trace(ptr, nelem * elsize) < 0) { + if (tracemalloc_add_trace(ptr, size) < 0) { /* Failed to allocate a trace for the new memory block */ TABLES_UNLOCK(); alloc->free(alloc->ctx, ptr); @@ -565,16 +560,13 @@ } static void* -tracemalloc_alloc_gil(int use_calloc, void *ctx, size_t nelem, size_t elsize) +tracemalloc_malloc_gil(void *ctx, size_t size) { void *ptr; if (get_reentrant()) { PyMemAllocator *alloc = (PyMemAllocator *)ctx; - if (use_calloc) - return alloc->calloc(alloc->ctx, nelem, elsize); - else - return alloc->malloc(alloc->ctx, nelem * elsize); + return alloc->malloc(alloc->ctx, size); } /* Ignore reentrant call. PyObjet_Malloc() calls PyMem_Malloc() for @@ -582,25 +574,13 @@ allocation twice. */ set_reentrant(1); - ptr = tracemalloc_alloc(use_calloc, ctx, nelem, elsize); + ptr = tracemalloc_malloc(ctx, size); set_reentrant(0); return ptr; } static void* -tracemalloc_malloc_gil(void *ctx, size_t size) -{ - return tracemalloc_alloc_gil(0, ctx, 1, size); -} - -static void* -tracemalloc_calloc_gil(void *ctx, size_t nelem, size_t elsize) -{ - return tracemalloc_alloc_gil(1, ctx, nelem, elsize); -} - -static void* tracemalloc_realloc_gil(void *ctx, void *ptr, size_t new_size) { void *ptr2; @@ -634,7 +614,7 @@ #ifdef TRACE_RAW_MALLOC static void* -tracemalloc_raw_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) +tracemalloc_raw_malloc(void *ctx, size_t size) { #ifdef WITH_THREAD PyGILState_STATE gil_state; @@ -643,10 +623,7 @@ if (get_reentrant()) { PyMemAllocator *alloc = (PyMemAllocator *)ctx; - if (use_calloc) - return alloc->calloc(alloc->ctx, nelem, elsize); - else - return alloc->malloc(alloc->ctx, nelem * elsize); + return alloc->malloc(alloc->ctx, size); } /* Ignore reentrant call. PyGILState_Ensure() may call PyMem_RawMalloc() @@ -656,10 +633,10 @@ #ifdef WITH_THREAD gil_state = PyGILState_Ensure(); - ptr = tracemalloc_alloc(use_calloc, ctx, nelem, elsize); + ptr = tracemalloc_malloc(ctx, size); PyGILState_Release(gil_state); #else - ptr = tracemalloc_alloc(use_calloc, ctx, nelem, elsize); + ptr = tracemalloc_malloc(ctx, size); #endif set_reentrant(0); @@ -667,18 +644,6 @@ } static void* -tracemalloc_raw_malloc(void *ctx, size_t size) -{ - return tracemalloc_raw_alloc(0, ctx, 1, size); -} - -static void* -tracemalloc_raw_calloc(void *ctx, size_t nelem, size_t elsize) -{ - return tracemalloc_raw_alloc(1, ctx, nelem, elsize); -} - -static void* tracemalloc_raw_realloc(void *ctx, void *ptr, size_t new_size) { #ifdef WITH_THREAD @@ -891,7 +856,6 @@ #ifdef TRACE_RAW_MALLOC alloc.malloc = tracemalloc_raw_malloc; - alloc.calloc = tracemalloc_raw_calloc; alloc.realloc = tracemalloc_raw_realloc; alloc.free = tracemalloc_free; @@ -901,7 +865,6 @@ #endif alloc.malloc = tracemalloc_malloc_gil; - alloc.calloc = tracemalloc_calloc_gil; alloc.realloc = tracemalloc_realloc_gil; alloc.free = tracemalloc_free; diff -r ce070040e1a6 -r d7f128afe9db Modules/_winapi.c --- a/Modules/_winapi.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/_winapi.c Sun Mar 23 09:44:28 2014 +0100 @@ -40,7 +40,6 @@ #define WINDOWS_LEAN_AND_MEAN #include "windows.h" #include -#include "winreparse.h" #if defined(MS_WIN32) && !defined(MS_WIN64) #define HANDLE_TO_PYNUM(handle) \ @@ -402,140 +401,6 @@ } static PyObject * -winapi_CreateJunction(PyObject *self, PyObject *args) -{ - /* Input arguments */ - LPWSTR src_path = NULL; - LPWSTR dst_path = NULL; - - /* Privilege adjustment */ - HANDLE token = NULL; - TOKEN_PRIVILEGES tp; - - /* Reparse data buffer */ - const USHORT prefix_len = 4; - USHORT print_len = 0; - USHORT rdb_size = 0; - PREPARSE_DATA_BUFFER rdb = NULL; - - /* Junction point creation */ - HANDLE junction = NULL; - DWORD ret = 0; - - if (!PyArg_ParseTuple(args, "uu", &src_path, &dst_path)) - return NULL; - - if (src_path == NULL || dst_path == NULL) - return PyErr_SetFromWindowsErr(ERROR_INVALID_PARAMETER); - - if (wcsncmp(src_path, L"\\??\\", prefix_len) == 0) - return PyErr_SetFromWindowsErr(ERROR_INVALID_PARAMETER); - - /* Adjust privileges to allow rewriting directory entry as a - junction point. */ - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) - goto cleanup; - - if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid)) - goto cleanup; - - tp.PrivilegeCount = 1; - tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - if (!AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), - NULL, NULL)) - goto cleanup; - - if (GetFileAttributesW(src_path) == INVALID_FILE_ATTRIBUTES) - goto cleanup; - - /* Store the absolute link target path length in print_len. */ - print_len = (USHORT)GetFullPathNameW(src_path, 0, NULL, NULL); - if (print_len == 0) - goto cleanup; - - /* NUL terminator should not be part of print_len. */ - --print_len; - - /* REPARSE_DATA_BUFFER usage is heavily under-documented, especially for - junction points. Here's what I've learned along the way: - - A junction point has two components: a print name and a substitute - name. They both describe the link target, but the substitute name is - the physical target and the print name is shown in directory listings. - - The print name must be a native name, prefixed with "\??\". - - Both names are stored after each other in the same buffer (the - PathBuffer) and both must be NUL-terminated. - - There are four members defining their respective offset and length - inside PathBuffer: SubstituteNameOffset, SubstituteNameLength, - PrintNameOffset and PrintNameLength. - - The total size we need to allocate for the REPARSE_DATA_BUFFER, thus, - is the sum of: - - the fixed header size (REPARSE_DATA_BUFFER_HEADER_SIZE) - - the size of the MountPointReparseBuffer member without the PathBuffer - - the size of the prefix ("\??\") in bytes - - the size of the print name in bytes - - the size of the substitute name in bytes - - the size of two NUL terminators in bytes */ - rdb_size = REPARSE_DATA_BUFFER_HEADER_SIZE + - sizeof(rdb->MountPointReparseBuffer) - - sizeof(rdb->MountPointReparseBuffer.PathBuffer) + - /* Two +1's for NUL terminators. */ - (prefix_len + print_len + 1 + print_len + 1) * sizeof(WCHAR); - rdb = (PREPARSE_DATA_BUFFER)PyMem_RawMalloc(rdb_size); - if (rdb == NULL) - goto cleanup; - - memset(rdb, 0, rdb_size); - rdb->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; - rdb->ReparseDataLength = rdb_size - REPARSE_DATA_BUFFER_HEADER_SIZE; - rdb->MountPointReparseBuffer.SubstituteNameOffset = 0; - rdb->MountPointReparseBuffer.SubstituteNameLength = - (prefix_len + print_len) * sizeof(WCHAR); - rdb->MountPointReparseBuffer.PrintNameOffset = - rdb->MountPointReparseBuffer.SubstituteNameLength + sizeof(WCHAR); - rdb->MountPointReparseBuffer.PrintNameLength = print_len * sizeof(WCHAR); - - /* Store the full native path of link target at the substitute name - offset (0). */ - wcscpy(rdb->MountPointReparseBuffer.PathBuffer, L"\\??\\"); - if (GetFullPathNameW(src_path, print_len + 1, - rdb->MountPointReparseBuffer.PathBuffer + prefix_len, - NULL) == 0) - goto cleanup; - - /* Copy everything but the native prefix to the print name offset. */ - wcscpy(rdb->MountPointReparseBuffer.PathBuffer + - prefix_len + print_len + 1, - rdb->MountPointReparseBuffer.PathBuffer + prefix_len); - - /* Create a directory for the junction point. */ - if (!CreateDirectoryW(dst_path, NULL)) - goto cleanup; - - junction = CreateFileW(dst_path, GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); - if (junction == INVALID_HANDLE_VALUE) - goto cleanup; - - /* Make the directory entry a junction point. */ - if (!DeviceIoControl(junction, FSCTL_SET_REPARSE_POINT, rdb, rdb_size, - NULL, 0, &ret, NULL)) - goto cleanup; - -cleanup: - ret = GetLastError(); - - CloseHandle(token); - CloseHandle(junction); - PyMem_RawFree(rdb); - - if (ret != 0) - return PyErr_SetFromWindowsErr(ret); - - Py_RETURN_NONE; -} - -static PyObject * winapi_CreateNamedPipe(PyObject *self, PyObject *args) { LPCTSTR lpName; @@ -1360,8 +1225,6 @@ METH_VARARGS | METH_KEYWORDS, ""}, {"CreateFile", winapi_CreateFile, METH_VARARGS, ""}, - {"CreateJunction", winapi_CreateJunction, METH_VARARGS, - ""}, {"CreateNamedPipe", winapi_CreateNamedPipe, METH_VARARGS, ""}, {"CreatePipe", winapi_CreatePipe, METH_VARARGS, diff -r ce070040e1a6 -r d7f128afe9db Modules/gcmodule.c --- a/Modules/gcmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/gcmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -776,40 +776,28 @@ return 0; } -/* Run first-time finalizers (if any) on all the objects in collectable. - * Note that this may remove some (or even all) of the objects from the - * list, due to refcounts falling to 0. - */ static void -finalize_garbage(PyGC_Head *collectable) +finalize_garbage(PyGC_Head *collectable, PyGC_Head *old) { destructor finalize; - PyGC_Head seen; + PyGC_Head *gc = collectable->gc.gc_next; - /* While we're going through the loop, `finalize(op)` may cause op, or - * other objects, to be reclaimed via refcounts falling to zero. So - * there's little we can rely on about the structure of the input - * `collectable` list across iterations. For safety, we always take the - * first object in that list and move it to a temporary `seen` list. - * If objects vanish from the `collectable` and `seen` lists we don't - * care. - */ - gc_list_init(&seen); + for (; gc != collectable; gc = gc->gc.gc_next) { + PyObject *op = FROM_GC(gc); - while (!gc_list_is_empty(collectable)) { - PyGC_Head *gc = collectable->gc.gc_next; - PyObject *op = FROM_GC(gc); - gc_list_move(gc, &seen); if (!_PyGCHead_FINALIZED(gc) && - PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_HAVE_FINALIZE) && - (finalize = Py_TYPE(op)->tp_finalize) != NULL) { + PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_HAVE_FINALIZE) && + (finalize = Py_TYPE(op)->tp_finalize) != NULL) { _PyGCHead_SET_FINALIZED(gc, 1); Py_INCREF(op); finalize(op); + if (Py_REFCNT(op) == 1) { + /* op will be destroyed */ + gc = gc->gc.gc_prev; + } Py_DECREF(op); } } - gc_list_merge(&seen, collectable); } /* Walk the collectable list and check that they are really unreachable @@ -1018,7 +1006,7 @@ m += handle_weakrefs(&unreachable, old); /* Call tp_finalize on objects which have one. */ - finalize_garbage(&unreachable); + finalize_garbage(&unreachable, old); if (check_garbage(&unreachable)) { revive_garbage(&unreachable); @@ -1715,19 +1703,15 @@ _PyObject_GC_UNTRACK(op); } -static PyObject * -_PyObject_GC_Alloc(int use_calloc, size_t basicsize) +PyObject * +_PyObject_GC_Malloc(size_t basicsize) { PyObject *op; PyGC_Head *g; - size_t size; if (basicsize > PY_SSIZE_T_MAX - sizeof(PyGC_Head)) return PyErr_NoMemory(); - size = sizeof(PyGC_Head) + basicsize; - if (use_calloc) - g = (PyGC_Head *)PyObject_Calloc(1, size); - else - g = (PyGC_Head *)PyObject_Malloc(size); + g = (PyGC_Head *)PyObject_MALLOC( + sizeof(PyGC_Head) + basicsize); if (g == NULL) return PyErr_NoMemory(); g->gc.gc_refs = 0; @@ -1747,18 +1731,6 @@ } PyObject * -_PyObject_GC_Malloc(size_t basicsize) -{ - return _PyObject_GC_Alloc(0, basicsize); -} - -PyObject * -_PyObject_GC_Calloc(size_t basicsize) -{ - return _PyObject_GC_Alloc(1, basicsize); -} - -PyObject * _PyObject_GC_New(PyTypeObject *tp) { PyObject *op = _PyObject_GC_Malloc(_PyObject_SIZE(tp)); diff -r ce070040e1a6 -r d7f128afe9db Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/itertoolsmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -1492,22 +1492,19 @@ Py_ssize_t oldnext; PyObject *(*iternext)(PyObject *); - if (it == NULL) - return NULL; - iternext = *Py_TYPE(it)->tp_iternext; while (lz->cnt < lz->next) { item = iternext(it); if (item == NULL) - goto empty; + return NULL; Py_DECREF(item); lz->cnt++; } if (stop != -1 && lz->cnt >= stop) - goto empty; + return NULL; item = iternext(it); if (item == NULL) - goto empty; + return NULL; lz->cnt++; oldnext = lz->next; /* The (size_t) cast below avoids the danger of undefined @@ -1516,10 +1513,6 @@ if (lz->next < oldnext || (stop != -1 && lz->next > stop)) lz->next = stop; return item; - -empty: - Py_CLEAR(lz->it); - return NULL; } static PyObject * @@ -1529,18 +1522,6 @@ * then 'setstate' with the next and count */ PyObject *stop; - if (lz->it == NULL) { - PyObject *empty_list; - PyObject *empty_it; - empty_list = PyList_New(0); - if (empty_list == NULL) - return NULL; - empty_it = PyObject_GetIter(empty_list); - Py_DECREF(empty_list); - if (empty_it == NULL) - return NULL; - return Py_BuildValue("O(Nn)n", Py_TYPE(lz), empty_it, 0, 0); - } if (lz->stop == -1) { stop = Py_None; Py_INCREF(stop); diff -r ce070040e1a6 -r d7f128afe9db Modules/main.c --- a/Modules/main.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/main.c Sun Mar 23 09:44:28 2014 +0100 @@ -343,8 +343,6 @@ int version = 0; int saw_unbuffered_flag = 0; PyCompilerFlags cf; - PyObject *warning_option = NULL; - PyObject *warning_options = NULL; cf.cf_flags = 0; @@ -467,15 +465,7 @@ break; case 'W': - if (warning_options == NULL) - warning_options = PyList_New(0); - if (warning_options == NULL) - Py_FatalError("failure in handling of -W argument"); - warning_option = PyUnicode_FromWideChar(_PyOS_optarg, -1); - if (warning_option == NULL) - Py_FatalError("failure in handling of -W argument"); - PyList_Append(warning_options, warning_option); - Py_DECREF(warning_option); + PySys_AddWarnOption(_PyOS_optarg); break; case 'X': @@ -569,12 +559,6 @@ PyMem_RawFree(buf); } #endif - if (warning_options != NULL) { - Py_ssize_t i; - for (i = 0; i < PyList_GET_SIZE(warning_options); i++) { - PySys_AddWarnOptionUnicode(PyList_GET_ITEM(warning_options, i)); - } - } if (command == NULL && module == NULL && _PyOS_optind < argc && wcscmp(argv[_PyOS_optind], L"-") != 0) @@ -668,7 +652,6 @@ Py_SetProgramName(argv[0]); #endif Py_Initialize(); - Py_XDECREF(warning_options); if (!Py_QuietFlag && (Py_VerboseFlag || (command == NULL && filename == NULL && diff -r ce070040e1a6 -r d7f128afe9db Modules/mathmodule.c --- a/Modules/mathmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/mathmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -1408,7 +1408,6 @@ math_factorial(PyObject *self, PyObject *arg) { long x; - int overflow; PyObject *result, *odd_part, *two_valuation; if (PyFloat_Check(arg)) { @@ -1422,22 +1421,15 @@ lx = PyLong_FromDouble(dx); if (lx == NULL) return NULL; - x = PyLong_AsLongAndOverflow(lx, &overflow); + x = PyLong_AsLong(lx); Py_DECREF(lx); } else - x = PyLong_AsLongAndOverflow(arg, &overflow); + x = PyLong_AsLong(arg); - if (x == -1 && PyErr_Occurred()) { + if (x == -1 && PyErr_Occurred()) return NULL; - } - else if (overflow == 1) { - PyErr_Format(PyExc_OverflowError, - "factorial() argument should not exceed %ld", - LONG_MAX); - return NULL; - } - else if (overflow == -1 || x < 0) { + if (x < 0) { PyErr_SetString(PyExc_ValueError, "factorial() not defined for negative values"); return NULL; diff -r ce070040e1a6 -r d7f128afe9db Modules/posixmodule.c --- a/Modules/posixmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/posixmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -27,8 +27,6 @@ #include "Python.h" #ifndef MS_WINDOWS #include "posixmodule.h" -#else -#include "winreparse.h" #endif #ifdef __cplusplus @@ -94,7 +92,7 @@ #undef HAVE_SCHED_SETAFFINITY #endif -#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) +#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) #define USE_XATTRS #endif @@ -303,9 +301,6 @@ #ifndef IO_REPARSE_TAG_SYMLINK #define IO_REPARSE_TAG_SYMLINK (0xA000000CL) #endif -#ifndef IO_REPARSE_TAG_MOUNT_POINT -#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) -#endif #include "osdefs.h" #include #include @@ -1114,6 +1109,41 @@ #endif #ifdef MS_WINDOWS +/* The following structure was copied from + http://msdn.microsoft.com/en-us/library/ms791514.aspx as the required + include doesn't seem to be present in the Windows SDK (at least as included + with Visual Studio Express). */ +typedef struct _REPARSE_DATA_BUFFER { + ULONG ReparseTag; + USHORT ReparseDataLength; + USHORT Reserved; + union { + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + ULONG Flags; + WCHAR PathBuffer[1]; + } SymbolicLinkReparseBuffer; + + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + WCHAR PathBuffer[1]; + } MountPointReparseBuffer; + + struct { + UCHAR DataBuffer[1]; + } GenericReparseBuffer; + }; +} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; + +#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\ + GenericReparseBuffer) +#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) static int win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag) @@ -4462,10 +4492,7 @@ find_data_handle = FindFirstFileW(lpFileName, &find_data); if(find_data_handle != INVALID_HANDLE_VALUE) { - /* IO_REPARSE_TAG_SYMLINK if it is a symlink and - IO_REPARSE_TAG_MOUNT_POINT if it is a junction point. */ - is_link = find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK || - find_data.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT; + is_link = find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK; FindClose(find_data_handle); } } diff -r ce070040e1a6 -r d7f128afe9db Modules/pyexpat.c --- a/Modules/pyexpat.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/pyexpat.c Sun Mar 23 09:44:28 2014 +0100 @@ -908,7 +908,7 @@ void *buf = XML_GetBuffer(self->itself, BUF_SIZE); if (buf == NULL) { Py_XDECREF(readmethod); - return get_parse_result(self, 0); + return PyErr_NoMemory(); } bytes_read = readinst(buf, BUF_SIZE, readmethod); diff -r ce070040e1a6 -r d7f128afe9db Modules/signalmodule.c --- a/Modules/signalmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Modules/signalmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -956,7 +956,7 @@ static struct PyModuleDef signalmodule = { PyModuleDef_HEAD_INIT, - "_signal", + "signal", module_doc, -1, signal_methods, @@ -967,7 +967,7 @@ }; PyMODINIT_FUNC -PyInit__signal(void) +PyInit_signal(void) { PyObject *m, *d, *x; int i; @@ -1380,7 +1380,7 @@ void PyOS_InitInterrupts(void) { - PyObject *m = PyImport_ImportModule("_signal"); + PyObject *m = PyImport_ImportModule("signal"); if (m) { Py_DECREF(m); } diff -r ce070040e1a6 -r d7f128afe9db Modules/winreparse.h --- a/Modules/winreparse.h Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#ifndef Py_WINREPARSE_H -#define Py_WINREPARSE_H - -#ifdef MS_WINDOWS -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* The following structure was copied from - http://msdn.microsoft.com/en-us/library/ff552012.aspx as the required - include doesn't seem to be present in the Windows SDK (at least as included - with Visual Studio Express). */ -typedef struct _REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - }; -} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; - -#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\ - GenericReparseBuffer) -#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) - -#ifdef __cplusplus -} -#endif - -#endif /* MS_WINDOWS */ - -#endif /* !Py_WINREPARSE_H */ diff -r ce070040e1a6 -r d7f128afe9db Objects/abstract.c --- a/Objects/abstract.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/abstract.c Sun Mar 23 09:44:28 2014 +0100 @@ -932,12 +932,6 @@ } PyObject * -PyNumber_MatrixMultiply(PyObject *v, PyObject *w) -{ - return binary_op(v, w, NB_SLOT(nb_matrix_multiply), "@"); -} - -PyObject * PyNumber_FloorDivide(PyObject *v, PyObject *w) { return binary_op(v, w, NB_SLOT(nb_floor_divide), "//"); @@ -1018,7 +1012,6 @@ INPLACE_BINOP(PyNumber_InPlaceLshift, nb_inplace_lshift, nb_lshift, "<<=") INPLACE_BINOP(PyNumber_InPlaceRshift, nb_inplace_rshift, nb_rshift, ">>=") INPLACE_BINOP(PyNumber_InPlaceSubtract, nb_inplace_subtract, nb_subtract, "-=") -INPLACE_BINOP(PyNumber_InMatrixMultiply, nb_inplace_matrix_multiply, nb_matrix_multiply, "@=") PyObject * PyNumber_InPlaceFloorDivide(PyObject *v, PyObject *w) @@ -1085,13 +1078,6 @@ } PyObject * -PyNumber_InPlaceMatrixMultiply(PyObject *v, PyObject *w) -{ - return binary_iop(v, w, NB_SLOT(nb_inplace_matrix_multiply), - NB_SLOT(nb_matrix_multiply), "@="); -} - -PyObject * PyNumber_InPlaceRemainder(PyObject *v, PyObject *w) { return binary_iop(v, w, NB_SLOT(nb_inplace_remainder), diff -r ce070040e1a6 -r d7f128afe9db Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/bytearrayobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -813,21 +813,9 @@ } else { if (count > 0) { - void *sval; - Py_ssize_t alloc; - - assert (Py_SIZE(self) == 0); - - alloc = count + 1; - sval = PyObject_Calloc(1, alloc); - if (sval == NULL) + if (PyByteArray_Resize((PyObject *)self, count)) return -1; - - PyObject_Free(self->ob_bytes); - - self->ob_bytes = self->ob_start = sval; - Py_SIZE(self) = count; - self->ob_alloc = alloc; + memset(PyByteArray_AS_STRING(self), 0, count); } return 0; } diff -r ce070040e1a6 -r d7f128afe9db Objects/bytesobject.c --- a/Objects/bytesobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/bytesobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -71,44 +71,6 @@ PyBytes_FromStringAndSize()) or the length of the string in the `str' parameter (for PyBytes_FromString()). */ -static PyObject * -_PyBytes_FromSize(Py_ssize_t size, int use_calloc) -{ - PyBytesObject *op; - assert(size >= 0); - if (size == 0 && (op = nullstring) != NULL) { -#ifdef COUNT_ALLOCS - null_strings++; -#endif - Py_INCREF(op); - return (PyObject *)op; - } - - if (size > PY_SSIZE_T_MAX - PyBytesObject_SIZE) { - PyErr_SetString(PyExc_OverflowError, - "byte string is too large"); - return NULL; - } - - /* Inline PyObject_NewVar */ - if (use_calloc) - op = (PyBytesObject *)PyObject_Calloc(1, PyBytesObject_SIZE + size); - else - op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size); - if (op == NULL) - return PyErr_NoMemory(); - (void)PyObject_INIT_VAR(op, &PyBytes_Type, size); - op->ob_shash = -1; - if (!use_calloc) - op->ob_sval[size] = '\0'; - /* empty byte string singleton */ - if (size == 0) { - nullstring = op; - Py_INCREF(op); - } - return (PyObject *) op; -} - PyObject * PyBytes_FromStringAndSize(const char *str, Py_ssize_t size) { @@ -118,6 +80,13 @@ "Negative size passed to PyBytes_FromStringAndSize"); return NULL; } + if (size == 0 && (op = nullstring) != NULL) { +#ifdef COUNT_ALLOCS + null_strings++; +#endif + Py_INCREF(op); + return (PyObject *)op; + } if (size == 1 && str != NULL && (op = characters[*str & UCHAR_MAX]) != NULL) { @@ -128,15 +97,26 @@ return (PyObject *)op; } - op = (PyBytesObject *)_PyBytes_FromSize(size, 0); + if (size > PY_SSIZE_T_MAX - PyBytesObject_SIZE) { + PyErr_SetString(PyExc_OverflowError, + "byte string is too large"); + return NULL; + } + + /* Inline PyObject_NewVar */ + op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size); if (op == NULL) - return NULL; - if (str == NULL) - return (PyObject *) op; - - Py_MEMCPY(op->ob_sval, str, size); + return PyErr_NoMemory(); + (void)PyObject_INIT_VAR(op, &PyBytes_Type, size); + op->ob_shash = -1; + if (str != NULL) + Py_MEMCPY(op->ob_sval, str, size); + op->ob_sval[size] = '\0'; /* share short strings */ - if (size == 1) { + if (size == 0) { + nullstring = op; + Py_INCREF(op); + } else if (size == 1 && str != NULL) { characters[*str & UCHAR_MAX] = op; Py_INCREF(op); } @@ -2502,7 +2482,7 @@ "argument"); return NULL; } - return PyBytes_FromStringAndSize(NULL, 0); + return PyBytes_FromString(""); } if (PyUnicode_Check(x)) { @@ -2552,9 +2532,11 @@ return NULL; } else { - new = _PyBytes_FromSize(size, 1); + new = PyBytes_FromStringAndSize(NULL, size); if (new == NULL) return NULL; + if (size > 0) + memset(((PyBytesObject*)new)->ob_sval, 0, size); return new; } @@ -2799,6 +2781,7 @@ void PyBytes_Concat(PyObject **pv, PyObject *w) { + PyObject *v; assert(pv != NULL); if (*pv == NULL) return; @@ -2806,45 +2789,9 @@ Py_CLEAR(*pv); return; } - - if (Py_REFCNT(*pv) == 1 && PyBytes_CheckExact(*pv)) { - /* Only one reference, so we can resize in place */ - Py_ssize_t oldsize; - Py_buffer wb; - - wb.len = -1; - if (_getbuffer(w, &wb) < 0) { - PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s", - Py_TYPE(w)->tp_name, Py_TYPE(*pv)->tp_name); - Py_CLEAR(*pv); - return; - } - - oldsize = PyBytes_GET_SIZE(*pv); - if (oldsize > PY_SSIZE_T_MAX - wb.len) { - PyErr_NoMemory(); - goto error; - } - if (_PyBytes_Resize(pv, oldsize + wb.len) < 0) - goto error; - - memcpy(PyBytes_AS_STRING(*pv) + oldsize, wb.buf, wb.len); - PyBuffer_Release(&wb); - return; - - error: - PyBuffer_Release(&wb); - Py_CLEAR(*pv); - return; - } - - else { - /* Multiple references, need to create new object */ - PyObject *v; - v = bytes_concat(*pv, w); - Py_DECREF(*pv); - *pv = v; - } + v = bytes_concat(*pv, w); + Py_DECREF(*pv); + *pv = v; } void diff -r ce070040e1a6 -r d7f128afe9db Objects/dictobject.c --- a/Objects/dictobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/dictobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -1101,44 +1101,6 @@ return *value_addr; } -PyObject * -_PyDict_GetItem_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash) -{ - PyDictObject *mp = (PyDictObject *)op; - PyDictKeyEntry *ep; - PyThreadState *tstate; - PyObject **value_addr; - - if (!PyDict_Check(op)) - return NULL; - - /* We can arrive here with a NULL tstate during initialization: try - running "python -Wi" for an example related to string interning. - Let's just hope that no exception occurs then... This must be - _PyThreadState_Current and not PyThreadState_GET() because in debug - mode, the latter complains if tstate is NULL. */ - tstate = (PyThreadState*)_Py_atomic_load_relaxed( - &_PyThreadState_Current); - if (tstate != NULL && tstate->curexc_type != NULL) { - /* preserve the existing exception */ - PyObject *err_type, *err_value, *err_tb; - PyErr_Fetch(&err_type, &err_value, &err_tb); - ep = (mp->ma_keys->dk_lookup)(mp, key, hash, &value_addr); - /* ignore errors */ - PyErr_Restore(err_type, err_value, err_tb); - if (ep == NULL) - return NULL; - } - else { - ep = (mp->ma_keys->dk_lookup)(mp, key, hash, &value_addr); - if (ep == NULL) { - PyErr_Clear(); - return NULL; - } - } - return *value_addr; -} - /* Variant of PyDict_GetItem() that doesn't suppress exceptions. This returns NULL *with* an exception set if an exception occurred. It returns NULL *without* an exception set if the key wasn't present. @@ -1246,24 +1208,6 @@ } int -_PyDict_SetItem_KnownHash(PyObject *op, PyObject *key, PyObject *value, - Py_hash_t hash) -{ - PyDictObject *mp; - - if (!PyDict_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - assert(key); - assert(value); - mp = (PyDictObject *)op; - - /* insertdict() handles any resizing that might be necessary */ - return insertdict(mp, key, hash, value); -} - -int PyDict_DelItem(PyObject *op, PyObject *key) { PyDictObject *mp; diff -r ce070040e1a6 -r d7f128afe9db Objects/exceptions.c --- a/Objects/exceptions.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/exceptions.c Sun Mar 23 09:44:28 2014 +0100 @@ -1837,10 +1837,6 @@ PyObject *reason_str = NULL; PyObject *encoding_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason and encoding as strings, which they might not be if they've been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -1959,10 +1955,6 @@ PyObject *reason_str = NULL; PyObject *encoding_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason and encoding as strings, which they might not be if they've been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -2057,10 +2049,6 @@ PyObject *result = NULL; PyObject *reason_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason as a string, which it might not be if it's been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -2124,7 +2112,7 @@ PyObject *object, Py_ssize_t start, Py_ssize_t end, const char *reason) { - return PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", + return PyObject_CallFunction(PyExc_UnicodeTranslateError, "Ons", object, start, end, reason); } diff -r ce070040e1a6 -r d7f128afe9db Objects/longobject.c --- a/Objects/longobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/longobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -3841,7 +3841,7 @@ if (Py_SIZE(b) < 0) { /* if exponent is negative */ if (c) { - PyErr_SetString(PyExc_ValueError, "pow() 2nd argument " + PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " "cannot be negative when 3rd argument specified"); goto Error; } diff -r ce070040e1a6 -r d7f128afe9db Objects/moduleobject.c --- a/Objects/moduleobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/moduleobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -32,26 +32,20 @@ module_init_dict(PyModuleObject *mod, PyObject *md_dict, PyObject *name, PyObject *doc) { - _Py_IDENTIFIER(__name__); - _Py_IDENTIFIER(__doc__); - _Py_IDENTIFIER(__package__); - _Py_IDENTIFIER(__loader__); - _Py_IDENTIFIER(__spec__); - if (md_dict == NULL) return -1; if (doc == NULL) doc = Py_None; - if (_PyDict_SetItemId(md_dict, &PyId___name__, name) != 0) + if (PyDict_SetItemString(md_dict, "__name__", name) != 0) return -1; - if (_PyDict_SetItemId(md_dict, &PyId___doc__, doc) != 0) + if (PyDict_SetItemString(md_dict, "__doc__", doc) != 0) return -1; - if (_PyDict_SetItemId(md_dict, &PyId___package__, Py_None) != 0) + if (PyDict_SetItemString(md_dict, "__package__", Py_None) != 0) return -1; - if (_PyDict_SetItemId(md_dict, &PyId___loader__, Py_None) != 0) + if (PyDict_SetItemString(md_dict, "__loader__", Py_None) != 0) return -1; - if (_PyDict_SetItemId(md_dict, &PyId___spec__, Py_None) != 0) + if (PyDict_SetItemString(md_dict, "__spec__", Py_None) != 0) return -1; if (PyUnicode_CheckExact(name)) { Py_INCREF(name); @@ -190,9 +184,8 @@ Py_DECREF(n); } if (module->m_doc != NULL) { - _Py_IDENTIFIER(__doc__); v = PyUnicode_FromString(module->m_doc); - if (v == NULL || _PyDict_SetItemId(d, &PyId___doc__, v) != 0) { + if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { Py_XDECREF(v); Py_DECREF(m); return NULL; @@ -221,7 +214,6 @@ PyObject* PyModule_GetNameObject(PyObject *m) { - _Py_IDENTIFIER(__name__); PyObject *d; PyObject *name; if (!PyModule_Check(m)) { @@ -230,7 +222,7 @@ } d = ((PyModuleObject *)m)->md_dict; if (d == NULL || - (name = _PyDict_GetItemId(d, &PyId___name__)) == NULL || + (name = PyDict_GetItemString(d, "__name__")) == NULL || !PyUnicode_Check(name)) { PyErr_SetString(PyExc_SystemError, "nameless module"); @@ -253,7 +245,6 @@ PyObject* PyModule_GetFilenameObject(PyObject *m) { - _Py_IDENTIFIER(__file__); PyObject *d; PyObject *fileobj; if (!PyModule_Check(m)) { @@ -262,7 +253,7 @@ } d = ((PyModuleObject *)m)->md_dict; if (d == NULL || - (fileobj = _PyDict_GetItemId(d, &PyId___file__)) == NULL || + (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || !PyUnicode_Check(fileobj)) { PyErr_SetString(PyExc_SystemError, "module filename missing"); @@ -420,31 +411,6 @@ return PyObject_CallMethod(interp->importlib, "_module_repr", "O", m); } -static PyObject* -module_getattro(PyModuleObject *m, PyObject *name) -{ - PyObject *attr, *mod_name; - attr = PyObject_GenericGetAttr((PyObject *)m, name); - if (attr || !PyErr_ExceptionMatches(PyExc_AttributeError)) - return attr; - PyErr_Clear(); - if (m->md_dict) { - _Py_IDENTIFIER(__name__); - mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); - if (mod_name) { - PyErr_Format(PyExc_AttributeError, - "module '%U' has no attribute '%U'", mod_name, name); - return NULL; - } - else if (PyErr_Occurred()) { - PyErr_Clear(); - } - } - PyErr_Format(PyExc_AttributeError, - "module has no attribute '%U'", name); - return NULL; -} - static int module_traverse(PyModuleObject *m, visitproc visit, void *arg) { @@ -498,6 +464,7 @@ {0} }; + PyDoc_STRVAR(module_doc, "module(name[, doc])\n\ \n\ @@ -521,7 +488,7 @@ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ - (getattrofunc)module_getattro, /* tp_getattro */ + PyObject_GenericGetAttr, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | diff -r ce070040e1a6 -r d7f128afe9db Objects/object.c --- a/Objects/object.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/object.c Sun Mar 23 09:44:28 2014 +0100 @@ -1849,8 +1849,6 @@ Py_ssize_t i; dict = PyThreadState_GetDict(); - /* Ignore a missing thread-state, so that this function can be called - early on startup. */ if (dict == NULL) return 0; list = _PyDict_GetItemId(dict, &PyId_Py_Repr); diff -r ce070040e1a6 -r d7f128afe9db Objects/obmalloc.c --- a/Objects/obmalloc.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/obmalloc.c Sun Mar 23 09:44:28 2014 +0100 @@ -5,7 +5,6 @@ #ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */ /* Forward declaration */ static void* _PyMem_DebugMalloc(void *ctx, size_t size); -static void* _PyMem_DebugCalloc(void *ctx, size_t nelem, size_t elsize); static void _PyMem_DebugFree(void *ctx, void *p); static void* _PyMem_DebugRealloc(void *ctx, void *ptr, size_t size); @@ -44,7 +43,6 @@ /* Forward declaration */ static void* _PyObject_Malloc(void *ctx, size_t size); -static void* _PyObject_Calloc(void *ctx, size_t nelem, size_t elsize); static void _PyObject_Free(void *ctx, void *p); static void* _PyObject_Realloc(void *ctx, void *ptr, size_t size); #endif @@ -53,7 +51,7 @@ static void * _PyMem_RawMalloc(void *ctx, size_t size) { - /* PyMem_RawMalloc(0) means malloc(1). Some systems would return NULL + /* PyMem_Malloc(0) means malloc(1). Some systems would return NULL for malloc(0), which would be treated as an error. Some platforms would return a pointer with no memory behind it, which would break pymalloc. To solve these problems, allocate an extra byte. */ @@ -63,20 +61,6 @@ } static void * -_PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize) -{ - /* PyMem_RawCalloc(0, 0) means calloc(1, 1). Some systems would return NULL - for calloc(0, 0), which would be treated as an error. Some platforms - would return a pointer with no memory behind it, which would break - pymalloc. To solve these problems, allocate an extra byte. */ - if (nelem == 0 || elsize == 0) { - nelem = 1; - elsize = 1; - } - return calloc(nelem, elsize); -} - -static void * _PyMem_RawRealloc(void *ctx, void *ptr, size_t size) { if (size == 0) @@ -139,9 +123,9 @@ #endif -#define PYRAW_FUNCS _PyMem_RawMalloc, _PyMem_RawCalloc, _PyMem_RawRealloc, _PyMem_RawFree +#define PYRAW_FUNCS _PyMem_RawMalloc, _PyMem_RawRealloc, _PyMem_RawFree #ifdef WITH_PYMALLOC -# define PYOBJ_FUNCS _PyObject_Malloc, _PyObject_Calloc, _PyObject_Realloc, _PyObject_Free +# define PYOBJ_FUNCS _PyObject_Malloc, _PyObject_Realloc, _PyObject_Free #else # define PYOBJ_FUNCS PYRAW_FUNCS #endif @@ -163,7 +147,7 @@ {'o', {NULL, PYOBJ_FUNCS}} }; -#define PYDBG_FUNCS _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree +#define PYDBG_FUNCS _PyMem_DebugMalloc, _PyMem_DebugRealloc, _PyMem_DebugFree #endif static PyMemAllocator _PyMem_Raw = { @@ -212,7 +196,6 @@ PyMemAllocator alloc; alloc.malloc = _PyMem_DebugMalloc; - alloc.calloc = _PyMem_DebugCalloc; alloc.realloc = _PyMem_DebugRealloc; alloc.free = _PyMem_DebugFree; @@ -245,10 +228,9 @@ case PYMEM_DOMAIN_MEM: *allocator = _PyMem; break; case PYMEM_DOMAIN_OBJ: *allocator = _PyObject; break; default: - /* unknown domain: set all attributes to NULL */ + /* unknown domain */ allocator->ctx = NULL; allocator->malloc = NULL; - allocator->calloc = NULL; allocator->realloc = NULL; allocator->free = NULL; } @@ -290,18 +272,10 @@ */ if (size > (size_t)PY_SSIZE_T_MAX) return NULL; + return _PyMem_Raw.malloc(_PyMem_Raw.ctx, size); } -void * -PyMem_RawCalloc(size_t nelem, size_t elsize) -{ - /* see PyMem_RawMalloc() */ - if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize) - return NULL; - return _PyMem_Raw.calloc(_PyMem_Raw.ctx, nelem, elsize); -} - void* PyMem_RawRealloc(void *ptr, size_t new_size) { @@ -326,15 +300,6 @@ } void * -PyMem_Calloc(size_t nelem, size_t elsize) -{ - /* see PyMem_RawMalloc() */ - if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize) - return NULL; - return _PyMem.calloc(_PyMem.ctx, nelem, elsize); -} - -void * PyMem_Realloc(void *ptr, size_t new_size) { /* see PyMem_RawMalloc() */ @@ -387,15 +352,6 @@ } void * -PyObject_Calloc(size_t nelem, size_t elsize) -{ - /* see PyMem_RawMalloc() */ - if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize) - return NULL; - return _PyObject.calloc(_PyObject.ctx, nelem, elsize); -} - -void * PyObject_Realloc(void *ptr, size_t new_size) { /* see PyMem_RawMalloc() */ @@ -1166,9 +1122,8 @@ */ static void * -_PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) +_PyObject_Malloc(void *ctx, size_t nbytes) { - size_t nbytes; block *bp; poolp pool; poolp next; @@ -1176,9 +1131,6 @@ _Py_AllocatedBlocks++; - assert(nelem <= PY_SSIZE_T_MAX / elsize); - nbytes = nelem * elsize; - #ifdef WITH_VALGRIND if (UNLIKELY(running_on_valgrind == -1)) running_on_valgrind = RUNNING_ON_VALGRIND; @@ -1186,9 +1138,9 @@ goto redirect; #endif - if (nelem == 0 || elsize == 0) - goto redirect; - + /* + * This implicitly redirects malloc(0). + */ if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) { LOCK(); /* @@ -1206,8 +1158,6 @@ assert(bp != NULL); if ((pool->freeblock = *(block **)bp) != NULL) { UNLOCK(); - if (use_calloc) - memset(bp, 0, nbytes); return (void *)bp; } /* @@ -1220,8 +1170,6 @@ pool->nextoffset += INDEX2SIZE(size); *(block **)(pool->freeblock) = NULL; UNLOCK(); - if (use_calloc) - memset(bp, 0, nbytes); return (void *)bp; } /* Pool is full, unlink from used pools. */ @@ -1230,8 +1178,6 @@ next->prevpool = pool; pool->nextpool = next; UNLOCK(); - if (use_calloc) - memset(bp, 0, nbytes); return (void *)bp; } @@ -1311,8 +1257,6 @@ assert(bp != NULL); pool->freeblock = *(block **)bp; UNLOCK(); - if (use_calloc) - memset(bp, 0, nbytes); return (void *)bp; } /* @@ -1328,8 +1272,6 @@ pool->freeblock = bp + size; *(block **)(pool->freeblock) = NULL; UNLOCK(); - if (use_calloc) - memset(bp, 0, nbytes); return (void *)bp; } @@ -1369,29 +1311,13 @@ * has been reached. */ { - void *result; - if (use_calloc) - result = PyMem_RawCalloc(nelem, elsize); - else - result = PyMem_RawMalloc(nbytes); + void *result = PyMem_RawMalloc(nbytes); if (!result) _Py_AllocatedBlocks--; return result; } } -static void * -_PyObject_Malloc(void *ctx, size_t nbytes) -{ - return _PyObject_Alloc(0, ctx, 1, nbytes); -} - -static void * -_PyObject_Calloc(void *ctx, size_t nelem, size_t elsize) -{ - return _PyObject_Alloc(1, ctx, nelem, elsize); -} - /* free */ ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS @@ -1635,7 +1561,7 @@ #endif if (p == NULL) - return _PyObject_Alloc(0, ctx, 1, nbytes); + return _PyObject_Malloc(ctx, nbytes); #ifdef WITH_VALGRIND /* Treat running_on_valgrind == -1 the same as 0 */ @@ -1663,7 +1589,7 @@ } size = nbytes; } - bp = _PyObject_Alloc(0, ctx, 1, nbytes); + bp = _PyObject_Malloc(ctx, nbytes); if (bp != NULL) { memcpy(bp, p, size); _PyObject_Free(ctx, p); @@ -1819,7 +1745,7 @@ */ static void * -_PyMem_DebugAlloc(int use_calloc, void *ctx, size_t nbytes) +_PyMem_DebugMalloc(void *ctx, size_t nbytes) { debug_alloc_api_t *api = (debug_alloc_api_t *)ctx; uchar *p; /* base address of malloc'ed block */ @@ -1832,10 +1758,7 @@ /* overflow: can't represent total as a size_t */ return NULL; - if (use_calloc) - p = (uchar *)api->alloc.calloc(api->alloc.ctx, 1, total); - else - p = (uchar *)api->alloc.malloc(api->alloc.ctx, total); + p = (uchar *)api->alloc.malloc(api->alloc.ctx, total); if (p == NULL) return NULL; @@ -1844,7 +1767,7 @@ p[SST] = (uchar)api->api_id; memset(p + SST + 1, FORBIDDENBYTE, SST-1); - if (nbytes > 0 && !use_calloc) + if (nbytes > 0) memset(p + 2*SST, CLEANBYTE, nbytes); /* at tail, write pad (SST bytes) and serialno (SST bytes) */ @@ -1855,21 +1778,6 @@ return p + 2*SST; } -static void * -_PyMem_DebugMalloc(void *ctx, size_t nbytes) -{ - return _PyMem_DebugAlloc(0, ctx, nbytes); -} - -static void * -_PyMem_DebugCalloc(void *ctx, size_t nelem, size_t elsize) -{ - size_t nbytes; - assert(elsize == 0 || nelem <= PY_SSIZE_T_MAX / elsize); - nbytes = nelem * elsize; - return _PyMem_DebugAlloc(1, ctx, nbytes); -} - /* The debug free first checks the 2*SST bytes on each end for sanity (in particular, that the FORBIDDENBYTEs with the api ID are still intact). Then fills the original bytes with DEADBYTE. @@ -1903,7 +1811,7 @@ int i; if (p == NULL) - return _PyMem_DebugAlloc(0, ctx, nbytes); + return _PyMem_DebugMalloc(ctx, nbytes); _PyMem_DebugCheckAddress(api->api_id, p); bumpserialno(); diff -r ce070040e1a6 -r d7f128afe9db Objects/stringlib/transmogrify.h --- a/Objects/stringlib/transmogrify.h Sat May 10 13:24:58 2014 -0400 +++ b/Objects/stringlib/transmogrify.h Sun Mar 23 09:44:28 2014 +0100 @@ -15,7 +15,7 @@ { const char *e, *p; char *q; - Py_ssize_t i, j; + size_t i, j; PyObject *u; static char *kwlist[] = {"tabsize", 0}; int tabsize = 8; @@ -27,31 +27,35 @@ /* First pass: determine size of output string */ i = j = 0; e = STRINGLIB_STR(self) + STRINGLIB_LEN(self); - for (p = STRINGLIB_STR(self); p < e; p++) { + for (p = STRINGLIB_STR(self); p < e; p++) if (*p == '\t') { if (tabsize > 0) { - Py_ssize_t incr = tabsize - (j % tabsize); - if (j > PY_SSIZE_T_MAX - incr) - goto overflow; - j += incr; + j += tabsize - (j % tabsize); + if (j > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, + "result is too long"); + return NULL; + } } } else { - if (j > PY_SSIZE_T_MAX - 1) - goto overflow; j++; if (*p == '\n' || *p == '\r') { - if (i > PY_SSIZE_T_MAX - j) - goto overflow; i += j; j = 0; + if (i > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, + "result is too long"); + return NULL; + } } } + + if ((i + j) > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, "result is too long"); + return NULL; } - if (i > PY_SSIZE_T_MAX - j) - goto overflow; - /* Second pass: create output string and fill it */ u = STRINGLIB_NEW(NULL, i + j); if (!u) @@ -59,8 +63,8 @@ j = 0; q = STRINGLIB_STR(u); - - for (p = STRINGLIB_STR(self); p < e; p++) { + + for (p = STRINGLIB_STR(self); p < e; p++) if (*p == '\t') { if (tabsize > 0) { i = tabsize - (j % tabsize); @@ -75,12 +79,8 @@ if (*p == '\n' || *p == '\r') j = 0; } - } return u; - overflow: - PyErr_SetString(PyExc_OverflowError, "result too long"); - return NULL; } Py_LOCAL_INLINE(PyObject *) diff -r ce070040e1a6 -r d7f128afe9db Objects/typeobject.c --- a/Objects/typeobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/typeobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -4469,8 +4469,6 @@ COPYNUM(nb_inplace_true_divide); COPYNUM(nb_inplace_floor_divide); COPYNUM(nb_index); - COPYNUM(nb_matrix_multiply); - COPYNUM(nb_inplace_matrix_multiply); } if (type->tp_as_sequence != NULL && base->tp_as_sequence != NULL) { @@ -5607,7 +5605,6 @@ SLOT1BIN(slot_nb_add, nb_add, "__add__", "__radd__") SLOT1BIN(slot_nb_subtract, nb_subtract, "__sub__", "__rsub__") SLOT1BIN(slot_nb_multiply, nb_multiply, "__mul__", "__rmul__") -SLOT1BIN(slot_nb_matrix_multiply, nb_matrix_multiply, "__matmul__", "__rmatmul__") SLOT1BIN(slot_nb_remainder, nb_remainder, "__mod__", "__rmod__") SLOT1BIN(slot_nb_divmod, nb_divmod, "__divmod__", "__rdivmod__") @@ -5701,7 +5698,6 @@ SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O") -SLOT1(slot_nb_inplace_matrix_multiply, "__imatmul__", PyObject *, "O") SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O") /* Can't use SLOT1 here, because nb_inplace_power is ternary */ static PyObject * @@ -6184,7 +6180,7 @@ TPSLOT("__gt__", tp_richcompare, slot_tp_richcompare, richcmp_gt, "__gt__($self, value, /)\n--\n\nReturn self>value."), TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge, - "__ge__($self, value, /)\n--\n\nReturn self>=value."), + "__ge__=($self, value, /)\n--\n\nReturn self>=value."), TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, "__iter__($self, /)\n--\n\nImplement iter(self)."), TPSLOT("__next__", tp_iternext, slot_tp_iternext, wrap_next, @@ -6280,14 +6276,8 @@ slot_nb_inplace_true_divide, wrap_binaryfunc, "/"), NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, "__index__($self, /)\n--\n\n" - "Return self converted to an integer, if self is suitable " + "Return self converted to an integer, if self is suitable" "for use as an index into a list."), - BINSLOT("__matmul__", nb_matrix_multiply, slot_nb_matrix_multiply, - "@"), - RBINSLOT("__rmatmul__", nb_matrix_multiply, slot_nb_matrix_multiply, - "@"), - IBSLOT("__imatmul__", nb_inplace_matrix_multiply, slot_nb_inplace_matrix_multiply, - wrap_binaryfunc, "@="), MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, "__len__($self, /)\n--\n\nReturn len(self)."), MPSLOT("__getitem__", mp_subscript, slot_mp_subscript, diff -r ce070040e1a6 -r d7f128afe9db Objects/typeslots.inc --- a/Objects/typeslots.inc Sat May 10 13:24:58 2014 -0400 +++ b/Objects/typeslots.inc Sun Mar 23 09:44:28 2014 +0100 @@ -73,5 +73,3 @@ offsetof(PyHeapTypeObject, ht_type.tp_members), offsetof(PyHeapTypeObject, ht_type.tp_getset), offsetof(PyHeapTypeObject, ht_type.tp_free), -offsetof(PyHeapTypeObject, as_number.nb_matrix_multiply), -offsetof(PyHeapTypeObject, as_number.nb_inplace_matrix_multiply), diff -r ce070040e1a6 -r d7f128afe9db Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sat May 10 13:24:58 2014 -0400 +++ b/Objects/unicodeobject.c Sun Mar 23 09:44:28 2014 +0100 @@ -8473,10 +8473,10 @@ } else if (PyLong_Check(x)) { long value = PyLong_AS_LONG(x); - if (value < 0 || value > MAX_UNICODE) { - PyErr_Format(PyExc_ValueError, - "character mapping must be in range(0x%x)", - MAX_UNICODE+1); + long max = PyUnicode_GetMax(); + if (value < 0 || value > max) { + PyErr_Format(PyExc_TypeError, + "character mapping must be in range(0x%x)", max+1); Py_DECREF(x); return -1; } @@ -8495,168 +8495,76 @@ return -1; } } - -/* lookup the character, write the result into the writer. - Return 1 if the result was written into the writer, return 0 if the mapping - was undefined, raise an exception return -1 on error. */ +/* ensure that *outobj is at least requiredsize characters long, + if not reallocate and adjust various state variables. + Return 0 on success, -1 on error */ static int -charmaptranslate_output(Py_UCS4 ch, PyObject *mapping, - _PyUnicodeWriter *writer) -{ - PyObject *item; - - if (charmaptranslate_lookup(ch, mapping, &item)) - return -1; - - if (item == NULL) { +charmaptranslate_makespace(Py_UCS4 **outobj, Py_ssize_t *psize, + Py_ssize_t requiredsize) +{ + Py_ssize_t oldsize = *psize; + Py_UCS4 *new_outobj; + if (requiredsize > oldsize) { + /* exponentially overallocate to minimize reallocations */ + if (requiredsize < 2 * oldsize) + requiredsize = 2 * oldsize; + new_outobj = PyMem_Realloc(*outobj, requiredsize * sizeof(Py_UCS4)); + if (new_outobj == 0) + return -1; + *outobj = new_outobj; + *psize = requiredsize; + } + return 0; +} +/* lookup the character, put the result in the output string and adjust + various state variables. Return a new reference to the object that + was put in the output buffer in *result, or Py_None, if the mapping was + undefined (in which case no character was written). + The called must decref result. + Return 0 on success, -1 on error. */ +static int +charmaptranslate_output(PyObject *input, Py_ssize_t ipos, + PyObject *mapping, Py_UCS4 **output, + Py_ssize_t *osize, Py_ssize_t *opos, + PyObject **res) +{ + Py_UCS4 curinp = PyUnicode_READ_CHAR(input, ipos); + if (charmaptranslate_lookup(curinp, mapping, res)) + return -1; + if (*res==NULL) { /* not found => default to 1:1 mapping */ - if (_PyUnicodeWriter_WriteCharInline(writer, ch) < 0) { + (*output)[(*opos)++] = curinp; + } + else if (*res==Py_None) + ; + else if (PyLong_Check(*res)) { + /* no overflow check, because we know that the space is enough */ + (*output)[(*opos)++] = (Py_UCS4)PyLong_AS_LONG(*res); + } + else if (PyUnicode_Check(*res)) { + Py_ssize_t repsize; + if (PyUnicode_READY(*res) == -1) return -1; - } - return 1; - } - - if (item == Py_None) { - Py_DECREF(item); - return 0; - } - - if (PyLong_Check(item)) { - long ch = (Py_UCS4)PyLong_AS_LONG(item); - /* PyLong_AS_LONG() cannot fail, charmaptranslate_lookup() already - used it */ - if (_PyUnicodeWriter_WriteCharInline(writer, ch) < 0) { - Py_DECREF(item); - return -1; - } - Py_DECREF(item); - return 1; - } - - if (!PyUnicode_Check(item)) { - Py_DECREF(item); - return -1; - } - - if (_PyUnicodeWriter_WriteStr(writer, item) < 0) { - Py_DECREF(item); - return -1; - } - - Py_DECREF(item); - return 1; -} - -static int -unicode_fast_translate_lookup(PyObject *mapping, Py_UCS1 ch, - Py_UCS1 *translate) -{ - PyObject *item = NULL; - int ret = 0; - - if (charmaptranslate_lookup(ch, mapping, &item)) { - return -1; - } - - if (item == Py_None) { - /* deletion */ - translate[ch] = 0xfe; - } - else if (item == NULL) { - /* not found => default to 1:1 mapping */ - translate[ch] = ch; - return 1; - } - else if (PyLong_Check(item)) { - long replace = PyLong_AS_LONG(item); - /* PyLong_AS_LONG() cannot fail, charmaptranslate_lookup() already - used it */ - if (127 < replace) { - /* invalid character or character outside ASCII: - skip the fast translate */ - goto exit; - } - translate[ch] = (Py_UCS1)replace; - } - else if (PyUnicode_Check(item)) { - Py_UCS4 replace; - - if (PyUnicode_READY(item) == -1) { - Py_DECREF(item); - return -1; - } - if (PyUnicode_GET_LENGTH(item) != 1) - goto exit; - - replace = PyUnicode_READ_CHAR(item, 0); - if (replace > 127) - goto exit; - translate[ch] = (Py_UCS1)replace; - } - else { - /* not None, NULL, long or unicode */ - goto exit; - } - ret = 1; - - exit: - Py_DECREF(item); - return ret; -} - -/* Fast path for ascii => ascii translation. Return 1 if the whole string - was translated into writer, return 0 if the input string was partially - translated into writer, raise an exception and return -1 on error. */ -static int -unicode_fast_translate(PyObject *input, PyObject *mapping, - _PyUnicodeWriter *writer, int ignore) -{ - Py_UCS1 ascii_table[128], ch, ch2; - Py_ssize_t len; - Py_UCS1 *in, *end, *out; - int res = 0; - - if (PyUnicode_READY(input) == -1) - return -1; - if (!PyUnicode_IS_ASCII(input)) - return 0; - len = PyUnicode_GET_LENGTH(input); - - memset(ascii_table, 0xff, 128); - - in = PyUnicode_1BYTE_DATA(input); - end = in + len; - - assert(PyUnicode_IS_ASCII(writer->buffer)); - assert(PyUnicode_GET_LENGTH(writer->buffer) == len); - out = PyUnicode_1BYTE_DATA(writer->buffer); - - for (; in < end; in++) { - ch = *in; - ch2 = ascii_table[ch]; - if (ch2 == 0xff) { - int translate = unicode_fast_translate_lookup(mapping, ch, - ascii_table); - if (translate < 0) + repsize = PyUnicode_GET_LENGTH(*res); + if (repsize==1) { + /* no overflow check, because we know that the space is enough */ + (*output)[(*opos)++] = PyUnicode_READ_CHAR(*res, 0); + } + else if (repsize!=0) { + /* more than one character */ + Py_ssize_t requiredsize = *opos + + (PyUnicode_GET_LENGTH(input) - ipos) + + repsize - 1; + Py_ssize_t i; + if (charmaptranslate_makespace(output, osize, requiredsize)) return -1; - if (translate == 0) - goto exit; - ch2 = ascii_table[ch]; - } - if (ch2 == 0xfe) { - if (ignore) - continue; - goto exit; - } - assert(ch2 < 128); - *out = ch2; - out++; - } - res = 1; - -exit: - writer->pos = out - PyUnicode_1BYTE_DATA(writer->buffer); - return res; + for(i = 0; i < repsize; i++) + (*output)[(*opos)++] = PyUnicode_READ_CHAR(*res, i); + } + } + else + return -1; + return 0; } PyObject * @@ -8665,17 +8573,22 @@ const char *errors) { /* input object */ - char *data; + char *idata; Py_ssize_t size, i; int kind; /* output buffer */ - _PyUnicodeWriter writer; - /* error handler */ + Py_UCS4 *output = NULL; + Py_ssize_t osize; + PyObject *res; + /* current output position */ + Py_ssize_t opos; char *reason = "character maps to "; PyObject *errorHandler = NULL; PyObject *exc = NULL; - int ignore; - int res; + /* the following variable is used for caching string comparisons + * -1=not initialized, 0=unknown, 1=strict, 2=replace, + * 3=ignore, 4=xmlcharrefreplace */ + int known_errorHandler = -1; if (mapping == NULL) { PyErr_BadArgument(); @@ -8684,9 +8597,10 @@ if (PyUnicode_READY(input) == -1) return NULL; - data = (char*)PyUnicode_DATA(input); + idata = (char*)PyUnicode_DATA(input); kind = PyUnicode_KIND(input); size = PyUnicode_GET_LENGTH(input); + i = 0; if (size == 0) { Py_INCREF(input); @@ -8695,81 +8609,121 @@ /* allocate enough for a simple 1:1 translation without replacements, if we need more, we'll resize */ - _PyUnicodeWriter_Init(&writer); - if (_PyUnicodeWriter_Prepare(&writer, size, 127) == -1) + osize = size; + output = PyMem_Malloc(osize * sizeof(Py_UCS4)); + opos = 0; + if (output == NULL) { + PyErr_NoMemory(); goto onError; - - ignore = (errors != NULL && strcmp(errors, "ignore") == 0); - - res = unicode_fast_translate(input, mapping, &writer, ignore); - if (res < 0) { - _PyUnicodeWriter_Dealloc(&writer); - return NULL; - } - if (res == 1) - return _PyUnicodeWriter_Finish(&writer); - - i = writer.pos; + } + while (i adjust input pointer */ + } + Py_XDECREF(x); + if (x!=Py_None) /* it worked => adjust input pointer */ ++i; - continue; - } - - /* untranslatable character */ - collstart = i; - collend = i+1; - - /* find all untranslatable characters */ - while (collend < size) { - PyObject *x; - ch = PyUnicode_READ(kind, data, collend); - if (charmaptranslate_lookup(ch, mapping, &x)) + else { /* untranslatable character */ + PyObject *repunicode = NULL; /* initialize to prevent gcc warning */ + Py_ssize_t repsize; + Py_ssize_t newpos; + Py_ssize_t uni2; + /* startpos for collecting untranslatable chars */ + Py_ssize_t collstart = i; + Py_ssize_t collend = i+1; + Py_ssize_t coll; + + /* find all untranslatable characters */ + while (collend < size) { + if (charmaptranslate_lookup(PyUnicode_READ(kind,idata, collend), mapping, &x)) + goto onError; + Py_XDECREF(x); + if (x!=Py_None) + break; + ++collend; + } + /* cache callback name lookup + * (if not done yet, i.e. it's the first error) */ + if (known_errorHandler==-1) { + if ((errors==NULL) || (!strcmp(errors, "strict"))) + known_errorHandler = 1; + else if (!strcmp(errors, "replace")) + known_errorHandler = 2; + else if (!strcmp(errors, "ignore")) + known_errorHandler = 3; + else if (!strcmp(errors, "xmlcharrefreplace")) + known_errorHandler = 4; + else + known_errorHandler = 0; + } + switch (known_errorHandler) { + case 1: /* strict */ + make_translate_exception(&exc, + input, collstart, collend, reason); + if (exc != NULL) + PyCodec_StrictErrors(exc); goto onError; - Py_XDECREF(x); - if (x != Py_None) + case 2: /* replace */ + /* No need to check for space, this is a 1:1 replacement */ + for (coll = collstart; coll0; ++uni2) + output[opos++] = PyUnicode_READ_CHAR(repunicode, uni2); + i = newpos; Py_DECREF(repunicode); - goto onError; - } - Py_DECREF(repunicode); - i = newpos; - } - } + } + } + } + res = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, output, opos); + if (!res) + goto onError; + PyMem_Free(output); Py_XDECREF(exc); Py_XDECREF(errorHandler); - return _PyUnicodeWriter_Finish(&writer); + return res; onError: - _PyUnicodeWriter_Dealloc(&writer); + PyMem_Free(output); Py_XDECREF(exc); Py_XDECREF(errorHandler); return NULL; diff -r ce070040e1a6 -r d7f128afe9db PC/VS9.0/pyproject.vsprops --- a/PC/VS9.0/pyproject.vsprops Sat May 10 13:24:58 2014 -0400 +++ b/PC/VS9.0/pyproject.vsprops Sun Mar 23 09:44:28 2014 +0100 @@ -62,7 +62,7 @@ /> "+makefile) + + if arch == "amd64": + create_makefile64(makefile, m32) + fix_makefile(makefile) + copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) + copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) + + # If the assembler files don't exist in tmpXX, copy them there + if perl is None and os.path.exists("asm"+dirsuffix): + if not os.path.exists("tmp"+dirsuffix): + os.mkdir("tmp"+dirsuffix) + for f in os.listdir("asm"+dirsuffix): + if not f.endswith(".asm"): continue + if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue + shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) + + # Now run make. + if arch == "amd64": + rc = os.system("nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm") + if rc: + print("nasm assembler has failed.") + sys.exit(rc) + + copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") + copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") + + #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) + makeCommand = "nmake /nologo -f \"%s\"" % makefile + print("Executing ssl makefiles:", makeCommand) + sys.stdout.flush() + rc = os.system(makeCommand) + if rc: + print("Executing "+makefile+" failed") + print(rc) + sys.exit(rc) + finally: + os.chdir(old_cd) + sys.exit(rc) + +if __name__=='__main__': + main() diff -r ce070040e1a6 -r d7f128afe9db PCbuild/prepare_ssl.bat --- a/PCbuild/prepare_ssl.bat Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -@echo off -if not defined HOST_PYTHON ( - if %1 EQU Debug ( - shift - set HOST_PYTHON=python_d.exe - if not exist python35_d.dll exit 1 - ) ELSE ( - set HOST_PYTHON=python.exe - if not exist python35.dll exit 1 - ) -) -%HOST_PYTHON% prepare_ssl.py %1 diff -r ce070040e1a6 -r d7f128afe9db PCbuild/prepare_ssl.py --- a/PCbuild/prepare_ssl.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -# Script for preparing OpenSSL for building on Windows. -# Uses Perl to create nmake makefiles and otherwise prepare the way -# for building on 32 or 64 bit platforms. - -# Script originally authored by Mark Hammond. -# Major revisions by: -# Martin v. Löwis -# Christian Heimes -# Zachary Ware - -# THEORETICALLY, you can: -# * Unpack the latest OpenSSL release where $(opensslDir) in -# PCbuild\pyproject.props expects it to be. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script with the OpenSSL source dir as the only argument. -# -# it should configure OpenSSL such that it is ready to be built by -# ssl.vcxproj on 32 or 64 bit platforms. - -import os -import re -import sys -import shutil -import subprocess - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - try: - subprocess.check_output([perl, "-e", "use Win32;"]) - except subprocess.CalledProcessError: - continue - else: - return perl - - if perls: - print("The following perl interpreters were found:") - for p in perls: - print(" ", p) - print(" None of these versions appear suitable for building OpenSSL") - else: - print("NO perl interpreters were found on this machine at all!") - print(" Please install ActivePerl and ensure it appears on your path") - -def create_makefile64(makefile, m32): - """Create and fix makefile for 64bit - - Replace 32 with 64bit directories - """ - if not os.path.isfile(m32): - return - with open(m32) as fin: - with open(makefile, 'w') as fout: - for line in fin: - line = line.replace("=tmp32", "=tmp64") - line = line.replace("=out32", "=out64") - line = line.replace("=inc32", "=inc64") - # force 64 bit machine - line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64") - line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ") - # don't link against the lib on 64bit systems - line = line.replace("bufferoverflowu.lib", "") - fout.write(line) - os.unlink(m32) - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return - with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' - fout.write(line) - -def run_configure(configure, do_script): - print("perl Configure "+configure+" no-idea no-mdc2") - os.system("perl Configure "+configure+" no-idea no-mdc2") - print(do_script) - os.system(do_script) - -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) - -def prep(arch): - if arch == "x86": - configure = "VC-WIN32" - do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" - elif arch == "amd64": - configure = "VC-WIN64A" - do_script = "ms\\do_win64a" - makefile = "ms\\nt64.mak" - m32 = makefile.replace('64', '') - dirsuffix = "64" - #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" - else: - raise ValueError('Unrecognized platform: %s' % arch) - - # rebuild makefile when we do the role over from 32 to 64 build - if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile): - os.unlink(m32) - - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - print("Creating the makefiles...") - sys.stdout.flush() - run_configure(configure, do_script) - - if arch == "amd64": - create_makefile64(makefile, m32) - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - else: - print(makefile, 'already exists!') - - # If the assembler files don't exist in tmpXX, copy them there - if os.path.exists("asm"+dirsuffix): - if not os.path.exists("tmp"+dirsuffix): - os.mkdir("tmp"+dirsuffix) - for f in os.listdir("asm"+dirsuffix): - if not f.endswith(".asm"): continue - if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue - shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) - -def main(): - if len(sys.argv) == 1: - print("Not enough arguments: directory containing OpenSSL", - "sources must be supplied") - sys.exit(1) - - if len(sys.argv) > 2: - print("Too many arguments supplied, all we need is the directory", - "containing OpenSSL sources") - sys.exit(1) - - ssl_dir = sys.argv[1] - - if not os.path.exists(ssl_dir) and os.path.isdir(ssl_dir): - print(ssl_dir, "is not an existing directory!") - sys.exit(1) - - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl: - print("Found a working perl at '%s'" % (perl,)) - else: - sys.exit(1) - sys.stdout.flush() - - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - - old_cwd = os.getcwd() - try: - os.chdir(ssl_dir) - for arch in ['amd64', 'x86']: - prep(arch) - finally: - os.chdir(old_cwd) - -if __name__=='__main__': - main() diff -r ce070040e1a6 -r d7f128afe9db PCbuild/pyproject.props --- a/PCbuild/pyproject.props Sat May 10 13:24:58 2014 -0400 +++ b/PCbuild/pyproject.props Sun Mar 23 09:44:28 2014 +0100 @@ -20,7 +20,7 @@ $(externalsDir)\sqlite-3.8.3.1 $(externalsDir)\bzip2-1.0.6 $(externalsDir)\xz-5.0.5 - $(externalsDir)\openssl-1.0.1g + $(externalsDir)\openssl-1.0.1e $(externalsDir)\tcl-8.6.1.0 $(externalsDir)\tk-8.6.1.0 $(externalsDir)\tix-8.4.3.4 diff -r ce070040e1a6 -r d7f128afe9db PCbuild/python.vcxproj --- a/PCbuild/python.vcxproj Sat May 10 13:24:58 2014 -0400 +++ b/PCbuild/python.vcxproj Sun Mar 23 09:44:28 2014 +0100 @@ -156,14 +156,6 @@ AllRules.ruleset - Link - Link - Link - Link - Link - Link - Link - Link @@ -184,25 +176,6 @@ 2000000 0x1d000000 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -226,25 +199,6 @@ 2000000 0x1d000000 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -267,25 +221,6 @@ 2000000 0x1d000000 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -311,25 +246,6 @@ 4194304 0x1d000000 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -352,25 +268,6 @@ - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -397,25 +294,6 @@ MachineX64 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -438,25 +316,6 @@ - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -483,25 +342,6 @@ MachineX64 - - echo @rem This script invokes the most recently built Python with all arguments> "$(SolutionDir)..\python.bat" -echo @rem passed through to the interpreter. This file is generated by the>> "$(SolutionDir)..\python.bat" -echo @rem build process and any changes *will* be thrown away by the next>> "$(SolutionDir)..\python.bat" -echo @rem rebuild.>> "$(SolutionDir)..\python.bat" -echo @rem This is only meant as a convenience for developing CPython>> "$(SolutionDir)..\python.bat" -echo @rem and using it outside of that context is ill-advised.>> "$(SolutionDir)..\python.bat" -echo @echo Running $(Configuration)^^^|$(Platform) interpreter...>> "$(SolutionDir)..\python.bat" -echo @"$(OutDir)python$(PyDebugExt).exe" %%*>> "$(SolutionDir)..\python.bat" - - - Creating convenience batch file for easily invoking the newly built interpreter. - - - $(SolutionDir)..\python.bat - - - $(OutDir)python$(PyDebugExt).exe;%(Inputs) - @@ -521,4 +361,4 @@ - \ No newline at end of file + diff -r ce070040e1a6 -r d7f128afe9db PCbuild/pythoncore.vcxproj --- a/PCbuild/pythoncore.vcxproj Sat May 10 13:24:58 2014 -0400 +++ b/PCbuild/pythoncore.vcxproj Sun Mar 23 09:44:28 2014 +0100 @@ -173,7 +173,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -184,7 +184,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -209,7 +209,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -219,7 +219,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -254,7 +254,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -292,7 +292,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -314,7 +314,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -325,7 +325,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -350,7 +350,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -361,7 +361,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -383,7 +383,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -394,7 +394,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) @@ -419,7 +419,7 @@ Generate build information... - "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)\" + "$(SolutionDir)make_buildinfo.exe" Release "$(IntDir)" $(IntDir)getbuildinfo.o;%(AdditionalDependencies) @@ -430,7 +430,7 @@ $(KillPythonExe) IF %ERRORLEVEL% NEQ 0 ( - echo kill_python: war^ning: could not kill running Pythons, exit code %ERRORLEVEL% + echo kill_python: warning: could not kill running Pythons, exit code %ERRORLEVEL% exit /b 0 ) diff -r ce070040e1a6 -r d7f128afe9db PCbuild/readme.txt --- a/PCbuild/readme.txt Sat May 10 13:24:58 2014 -0400 +++ b/PCbuild/readme.txt Sun Mar 23 09:44:28 2014 +0100 @@ -168,7 +168,7 @@ Homepage: http://tukaani.org/xz/ _ssl - Python wrapper for version 1.0.1g of the OpenSSL secure sockets + Python wrapper for version 1.0.1e of the OpenSSL secure sockets library, which is built by ssl.vcxproj Homepage: http://www.openssl.org/ @@ -181,19 +181,30 @@ you should first try to update NASM and do a full rebuild of OpenSSL. - The ssl sub-project expects your OpenSSL sources to have already - been configured and be ready to build. If you get your sources - from svn.python.org as suggested in the "Getting External Sources" - section below, the OpenSSL source will already be ready to go. If - you want to build a different version, you will need to run + If you like to use the official sources instead of the files from + python.org's subversion repository, Perl is required to build the + necessary makefiles and assembly files. ActivePerl is available + from + http://www.activestate.com/activeperl/ + The svn.python.org version contains pre-built makefiles and assembly + files. - PCbuild\prepare_ssl.py path\to\openssl-source-dir + The build process makes sure that no patented algorithms are + included. For now RC5, MDC2 and IDEA are excluded from the build. + You may have to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if + using official sources; the svn.python.org-hosted version is already + fixed. - That script will prepare your OpenSSL sources in the same way that - those available on svn.python.org have been prepared. Note that - Perl must be installed and available on your PATH to configure - OpenSSL. ActivePerl is recommended and is available from - http://www.activestate.com/activeperl/ + The ssl.vcxproj sub-project simply invokes PCbuild/build_ssl.py, + which locates and builds OpenSSL. + + build_ssl.py attempts to catch the most common errors (such as not + being able to find OpenSSL sources, or not being able to find a Perl + that works with OpenSSL) and give a reasonable error message. If + you have a problem that doesn't seem to be handled correctly (e.g., + you know you have ActivePerl but we can't find it), please take a + peek at build_ssl.py and suggest patches. Note that build_ssl.py + should be able to be run directly from the command-line. The ssl sub-project does not have the ability to clean the OpenSSL build; if you need to rebuild, you'll have to clean it by hand. @@ -255,7 +266,8 @@ you just have to set x64 as platform. In addition, the HOST_PYTHON environment variable must point to a Python interpreter (at least 2.4), to support cross-compilation from Win32. Note that Visual Studio -requires Professional Edition or better in order to build 64-bit +requires either Standard Edition or better, or Express Edition with the +Windows SDK 64-bit compilers to be available in order to build 64-bit binaries. @@ -309,7 +321,6 @@ * pyproject (base settings for all projects, user macros like PyDllName) * release (release macro: NDEBUG) * sqlite3 (used only by sqlite3.vcxproj) - * tcltk (used by _tkinter, tcl, tk and tix projects) * x64 (AMD64 / x64 platform specific settings) The pyproject property file defines _WIN32 and x64 defines _WIN64 and diff -r ce070040e1a6 -r d7f128afe9db PCbuild/ssl.vcxproj --- a/PCbuild/ssl.vcxproj Sat May 10 13:24:58 2014 -0400 +++ b/PCbuild/ssl.vcxproj Sun Mar 23 09:44:28 2014 +0100 @@ -118,12 +118,9 @@ <_ProjectFileVersion>10.0.30319.1 - -cd "$(SolutionDir)$(opensslDir)" -copy /Y crypto\buildinf_x86.h crypto\buildinf.h -copy /Y crypto\opensslconf_x86.h crypto\opensslconf.h -nmake /nologo -f "ms\nt.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -132,13 +129,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm || echo nasm failed! && exit -copy /Y crypto\buildinf_amd64.h crypto\buildinf.h -copy /Y crypto\opensslconf_amd64.h crypto\opensslconf.h -nmake /nologo -f "ms\nt64.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -147,12 +140,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -copy /Y crypto\buildinf_x86.h crypto\buildinf.h -copy /Y crypto\opensslconf_x86.h crypto\opensslconf.h -nmake /nologo -f "ms\nt.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -161,13 +151,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm || echo nasm failed! && exit -copy /Y crypto\buildinf_amd64.h crypto\buildinf.h -copy /Y crypto\opensslconf_amd64.h crypto\opensslconf.h -nmake /nologo -f "ms\nt64.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -176,12 +162,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -copy /Y crypto\buildinf_x86.h crypto\buildinf.h -copy /Y crypto\opensslconf_x86.h crypto\opensslconf.h -nmake /nologo -f "ms\nt.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -190,13 +173,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm || echo nasm failed! && exit -copy /Y crypto\buildinf_amd64.h crypto\buildinf.h -copy /Y crypto\opensslconf_amd64.h crypto\opensslconf.h -nmake /nologo -f "ms\nt64.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -205,12 +184,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -copy /Y crypto\buildinf_x86.h crypto\buildinf.h -copy /Y crypto\opensslconf_x86.h crypto\opensslconf.h -nmake /nologo -f "ms\nt.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -219,13 +195,9 @@ $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - -cd "$(SolutionDir)$(opensslDir)" -nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm || echo nasm failed! && exit -copy /Y crypto\buildinf_amd64.h crypto\buildinf.h -copy /Y crypto\opensslconf_amd64.h crypto\opensslconf.h -nmake /nologo -f "ms\nt64.mak" - + cd "$(SolutionDir)" +"$(PythonExe)" build_ssl.py Release $(Platform) -a + echo OpenSSL must be cleaned manually if you want to rebuild it. @@ -237,6 +209,12 @@ + + + {b11d750f-cd1f-4a96-85ce-e69a5c5259f9} + false + + diff -r ce070040e1a6 -r d7f128afe9db Parser/Python.asdl --- a/Parser/Python.asdl Sat May 10 13:24:58 2014 -0400 +++ b/Parser/Python.asdl Sun Mar 23 09:44:28 2014 +0100 @@ -91,7 +91,7 @@ boolop = And | Or - operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift + operator = Add | Sub | Mult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv unaryop = Invert | Not | UAdd | USub diff -r ce070040e1a6 -r d7f128afe9db Parser/asdl.py --- a/Parser/asdl.py Sat May 10 13:24:58 2014 -0400 +++ b/Parser/asdl.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,53 +1,255 @@ -#------------------------------------------------------------------------------- -# Parser for ASDL [1] definition files. Reads in an ASDL description and parses -# it into an AST that describes it. -# -# The EBNF we're parsing here: Figure 1 of the paper [1]. Extended to support -# modules and attributes after a product. Words starting with Capital letters -# are terminals. Literal tokens are in "double quotes". Others are -# non-terminals. Id is either TokenId or ConstructorId. -# -# module ::= "module" Id "{" [definitions] "}" -# definitions ::= { TypeId "=" type } -# type ::= product | sum -# product ::= fields ["attributes" fields] -# fields ::= "(" { field, "," } field ")" -# field ::= TypeId ["?" | "*"] [Id] -# sum ::= constructor { "|" constructor } ["attributes" fields] -# constructor ::= ConstructorId [fields] -# -# [1] "The Zephyr Abstract Syntax Description Language" by Wang, et. al. See -# http://asdl.sourceforge.net/ -#------------------------------------------------------------------------------- -from collections import namedtuple -import re +"""An implementation of the Zephyr Abstract Syntax Definition Language. -__all__ = [ - 'builtin_types', 'parse', 'AST', 'Module', 'Type', 'Constructor', - 'Field', 'Sum', 'Product', 'VisitorBase', 'Check', 'check'] +See http://asdl.sourceforge.net/ and +http://www.cs.princeton.edu/research/techreps/TR-554-97 -# The following classes define nodes into which the ASDL description is parsed. -# Note: this is a "meta-AST". ASDL files (such as Python.asdl) describe the AST -# structure used by a programming language. But ASDL files themselves need to be -# parsed. This module parses ASDL files and uses a simple AST to represent them. -# See the EBNF at the top of the file to understand the logical connection -# between the various node types. +Only supports top level module decl, not view. I'm guessing that view +is intended to support the browser and I'm not interested in the +browser. -builtin_types = set( - ['identifier', 'string', 'bytes', 'int', 'object', 'singleton']) +Changes for Python: Add support for module versions +""" -class AST: +import os +import sys +import traceback + +import spark + +def output(*strings): + for s in strings: + sys.stdout.write(str(s) + "\n") + + +class Token(object): + # spark seems to dispatch in the parser based on a token's + # type attribute + def __init__(self, type, lineno): + self.type = type + self.lineno = lineno + + def __str__(self): + return self.type + def __repr__(self): - raise NotImplementedError + return str(self) + +class Id(Token): + def __init__(self, value, lineno): + self.type = 'Id' + self.value = value + self.lineno = lineno + + def __str__(self): + return self.value + +class String(Token): + def __init__(self, value, lineno): + self.type = 'String' + self.value = value + self.lineno = lineno + +class ASDLSyntaxError(Exception): + + def __init__(self, lineno, token=None, msg=None): + self.lineno = lineno + self.token = token + self.msg = msg + + def __str__(self): + if self.msg is None: + return "Error at '%s', line %d" % (self.token, self.lineno) + else: + return "%s, line %d" % (self.msg, self.lineno) + +class ASDLScanner(spark.GenericScanner, object): + + def tokenize(self, input): + self.rv = [] + self.lineno = 1 + super(ASDLScanner, self).tokenize(input) + return self.rv + + def t_id(self, s): + r"[\w\.]+" + # XXX doesn't distinguish upper vs. lower, which is + # significant for ASDL. + self.rv.append(Id(s, self.lineno)) + + def t_string(self, s): + r'"[^"]*"' + self.rv.append(String(s, self.lineno)) + + def t_xxx(self, s): # not sure what this production means + r"<=" + self.rv.append(Token(s, self.lineno)) + + def t_punctuation(self, s): + r"[\{\}\*\=\|\(\)\,\?\:]" + self.rv.append(Token(s, self.lineno)) + + def t_comment(self, s): + r"\-\-[^\n]*" + pass + + def t_newline(self, s): + r"\n" + self.lineno += 1 + + def t_whitespace(self, s): + r"[ \t]+" + pass + + def t_default(self, s): + r" . +" + raise ValueError("unmatched input: %r" % s) + +class ASDLParser(spark.GenericParser, object): + def __init__(self): + super(ASDLParser, self).__init__("module") + + def typestring(self, tok): + return tok.type + + def error(self, tok): + raise ASDLSyntaxError(tok.lineno, tok) + + def p_module_0(self, info): + " module ::= Id Id { } " + module, name, _0, _1 = info + if module.value != "module": + raise ASDLSyntaxError(module.lineno, + msg="expected 'module', found %s" % module) + return Module(name, None) + + def p_module(self, info): + " module ::= Id Id { definitions } " + module, name, _0, definitions, _1 = info + if module.value != "module": + raise ASDLSyntaxError(module.lineno, + msg="expected 'module', found %s" % module) + return Module(name, definitions) + + def p_definition_0(self, definition): + " definitions ::= definition " + return definition[0] + + def p_definition_1(self, definitions): + " definitions ::= definition definitions " + return definitions[0] + definitions[1] + + def p_definition(self, info): + " definition ::= Id = type " + id, _, type = info + return [Type(id, type)] + + def p_type_0(self, product): + " type ::= product " + return product[0] + + def p_type_1(self, sum): + " type ::= sum " + return Sum(sum[0]) + + def p_type_2(self, info): + " type ::= sum Id ( fields ) " + sum, id, _0, attributes, _1 = info + if id.value != "attributes": + raise ASDLSyntaxError(id.lineno, + msg="expected attributes, found %s" % id) + return Sum(sum, attributes) + + def p_product_0(self, info): + " product ::= ( fields ) " + _0, fields, _1 = info + return Product(fields) + + def p_product_1(self, info): + " product ::= ( fields ) Id ( fields ) " + _0, fields, _1, id, _2, attributes, _3 = info + if id.value != "attributes": + raise ASDLSyntaxError(id.lineno, + msg="expected attributes, found %s" % id) + return Product(fields, attributes) + + def p_sum_0(self, constructor): + " sum ::= constructor " + return [constructor[0]] + + def p_sum_1(self, info): + " sum ::= constructor | sum " + constructor, _, sum = info + return [constructor] + sum + + def p_sum_2(self, info): + " sum ::= constructor | sum " + constructor, _, sum = info + return [constructor] + sum + + def p_constructor_0(self, id): + " constructor ::= Id " + return Constructor(id[0]) + + def p_constructor_1(self, info): + " constructor ::= Id ( fields ) " + id, _0, fields, _1 = info + return Constructor(id, fields) + + def p_fields_0(self, field): + " fields ::= field " + return [field[0]] + + def p_fields_1(self, info): + " fields ::= fields , field " + fields, _, field = info + return fields + [field] + + def p_field_0(self, type_): + " field ::= Id " + return Field(type_[0]) + + def p_field_1(self, info): + " field ::= Id Id " + type, name = info + return Field(type, name) + + def p_field_2(self, info): + " field ::= Id * Id " + type, _, name = info + return Field(type, name, seq=True) + + def p_field_3(self, info): + " field ::= Id ? Id " + type, _, name = info + return Field(type, name, opt=True) + + def p_field_4(self, type_): + " field ::= Id * " + return Field(type_[0], seq=True) + + def p_field_5(self, type_): + " field ::= Id ? " + return Field(type[0], opt=True) + +builtin_types = ("identifier", "string", "bytes", "int", "object", "singleton") + +# below is a collection of classes to capture the AST of an AST :-) +# not sure if any of the methods are useful yet, but I'm adding them +# piecemeal as they seem helpful + +class AST(object): + pass # a marker class class Module(AST): def __init__(self, name, dfns): self.name = name self.dfns = dfns - self.types = {type.name: type.value for type in dfns} + self.types = {} # maps type name to value (from dfns) + for type in dfns: + self.types[type.name.value] = type.value def __repr__(self): - return 'Module({0.name}, {0.dfns})'.format(self) + return "Module(%s, %s)" % (self.name, self.dfns) class Type(AST): def __init__(self, name, value): @@ -55,7 +257,7 @@ self.value = value def __repr__(self): - return 'Type({0.name}, {0.value})'.format(self) + return "Type(%s, %s)" % (self.name, self.value) class Constructor(AST): def __init__(self, name, fields=None): @@ -63,7 +265,7 @@ self.fields = fields or [] def __repr__(self): - return 'Constructor({0.name}, {0.fields})'.format(self) + return "Constructor(%s, %s)" % (self.name, self.fields) class Field(AST): def __init__(self, type, name=None, seq=False, opt=False): @@ -80,9 +282,9 @@ else: extra = "" if self.name is None: - return 'Field({0.type}{1})'.format(self, extra) + return "Field(%s%s)" % (self.type, extra) else: - return 'Field({0.type}, {0.name}{1})'.format(self, extra) + return "Field(%s, %s%s)" % (self.type, self.name, extra) class Sum(AST): def __init__(self, types, attributes=None): @@ -90,10 +292,10 @@ self.attributes = attributes or [] def __repr__(self): - if self.attributes: - return 'Sum({0.types}, {0.attributes})'.format(self) + if self.attributes is None: + return "Sum(%s)" % self.types else: - return 'Sum({0.types})'.format(self) + return "Sum(%s, %s)" % (self.types, self.attributes) class Product(AST): def __init__(self, fields, attributes=None): @@ -101,43 +303,49 @@ self.attributes = attributes or [] def __repr__(self): - if self.attributes: - return 'Product({0.fields}, {0.attributes})'.format(self) + if self.attributes is None: + return "Product(%s)" % self.fields else: - return 'Product({0.fields})'.format(self) + return "Product(%s, %s)" % (self.fields, self.attributes) -# A generic visitor for the meta-AST that describes ASDL. This can be used by -# emitters. Note that this visitor does not provide a generic visit method, so a -# subclass needs to define visit methods from visitModule to as deep as the -# interesting node. -# We also define a Check visitor that makes sure the parsed ASDL is well-formed. +class VisitorBase(object): -class VisitorBase: - """Generic tree visitor for ASTs.""" - def __init__(self): + def __init__(self, skip=False): self.cache = {} + self.skip = skip - def visit(self, obj, *args): - klass = obj.__class__ + def visit(self, object, *args): + meth = self._dispatch(object) + if meth is None: + return + try: + meth(object, *args) + except Exception: + output("Error visiting" + repr(object)) + output(str(sys.exc_info()[1])) + traceback.print_exc() + # XXX hack + if hasattr(self, 'file'): + self.file.flush() + os._exit(1) + + def _dispatch(self, object): + assert isinstance(object, AST), repr(object) + klass = object.__class__ meth = self.cache.get(klass) if meth is None: methname = "visit" + klass.__name__ - meth = getattr(self, methname, None) + if self.skip: + meth = getattr(self, methname, None) + else: + meth = getattr(self, methname) self.cache[klass] = meth - if meth: - try: - meth(obj, *args) - except Exception as e: - print("Error visiting %r: %s" % (obj, e)) - raise + return meth class Check(VisitorBase): - """A visitor that checks a parsed ASDL tree for correctness. - Errors are printed and accumulated. - """ def __init__(self): - super().__init__() + super(Check, self).__init__(skip=True) self.cons = {} self.errors = 0 self.types = {} @@ -159,8 +367,8 @@ if conflict is None: self.cons[key] = name else: - print('Redefinition of constructor {}'.format(key)) - print('Defined in {} and {}'.format(conflict, name)) + output("Redefinition of constructor %s" % key) + output("Defined in %s and %s" % (conflict, name)) self.errors += 1 for f in cons.fields: self.visit(f, key) @@ -175,11 +383,6 @@ self.visit(f, name) def check(mod): - """Check the parsed ASDL tree for correctness. - - Return True if success. For failure, the errors are printed out and False - is returned. - """ v = Check() v.visit(mod) @@ -187,190 +390,47 @@ if t not in mod.types and not t in builtin_types: v.errors += 1 uses = ", ".join(v.types[t]) - print('Undefined type {}, used in {}'.format(t, uses)) + output("Undefined type %s, used in %s" % (t, uses)) + return not v.errors -# The ASDL parser itself comes next. The only interesting external interface -# here is the top-level parse function. +def parse(file): + scanner = ASDLScanner() + parser = ASDLParser() -def parse(filename): - """Parse ASDL from the given file and return a Module node describing it.""" - with open(filename) as f: - parser = ASDLParser() - return parser.parse(f.read()) + f = open(file) + try: + buf = f.read() + finally: + f.close() + tokens = scanner.tokenize(buf) + try: + return parser.parse(tokens) + except ASDLSyntaxError: + err = sys.exc_info()[1] + output(str(err)) + lines = buf.split("\n") + output(lines[err.lineno - 1]) # lines starts at 0, files at 1 -# Types for describing tokens in an ASDL specification. -class TokenKind: - """TokenKind is provides a scope for enumerated token kinds.""" - (ConstructorId, TypeId, Equals, Comma, Question, Pipe, Asterisk, - LParen, RParen, LBrace, RBrace) = range(11) +if __name__ == "__main__": + import glob + import sys - operator_table = { - '=': Equals, ',': Comma, '?': Question, '|': Pipe, '(': LParen, - ')': RParen, '*': Asterisk, '{': LBrace, '}': RBrace} + if len(sys.argv) > 1: + files = sys.argv[1:] + else: + testdir = "tests" + files = glob.glob(testdir + "/*.asdl") -Token = namedtuple('Token', 'kind value lineno') - -class ASDLSyntaxError(Exception): - def __init__(self, msg, lineno=None): - self.msg = msg - self.lineno = lineno or '' - - def __str__(self): - return 'Syntax error on line {0.lineno}: {0.msg}'.format(self) - -def tokenize_asdl(buf): - """Tokenize the given buffer. Yield Token objects.""" - for lineno, line in enumerate(buf.splitlines(), 1): - for m in re.finditer(r'\s*(\w+|--.*|.)', line.strip()): - c = m.group(1) - if c[0].isalpha(): - # Some kind of identifier - if c[0].isupper(): - yield Token(TokenKind.ConstructorId, c, lineno) - else: - yield Token(TokenKind.TypeId, c, lineno) - elif c[:2] == '--': - # Comment - break - else: - # Operators - try: - op_kind = TokenKind.operator_table[c] - except KeyError: - raise ASDLSyntaxError('Invalid operator %s' % c, lineno) - yield Token(op_kind, c, lineno) - -class ASDLParser: - """Parser for ASDL files. - - Create, then call the parse method on a buffer containing ASDL. - This is a simple recursive descent parser that uses tokenize_asdl for the - lexing. - """ - def __init__(self): - self._tokenizer = None - self.cur_token = None - - def parse(self, buf): - """Parse the ASDL in the buffer and return an AST with a Module root. - """ - self._tokenizer = tokenize_asdl(buf) - self._advance() - return self._parse_module() - - def _parse_module(self): - if self._at_keyword('module'): - self._advance() + for file in files: + output(file) + mod = parse(file) + if not mod: + break + output("module", mod.name) + output(len(mod.dfns), "definitions") + if not check(mod): + output("Check failed") else: - raise ASDLSyntaxError( - 'Expected "module" (found {})'.format(self.cur_token.value), - self.cur_token.lineno) - name = self._match(self._id_kinds) - self._match(TokenKind.LBrace) - defs = self._parse_definitions() - self._match(TokenKind.RBrace) - return Module(name, defs) - - def _parse_definitions(self): - defs = [] - while self.cur_token.kind == TokenKind.TypeId: - typename = self._advance() - self._match(TokenKind.Equals) - type = self._parse_type() - defs.append(Type(typename, type)) - return defs - - def _parse_type(self): - if self.cur_token.kind == TokenKind.LParen: - # If we see a (, it's a product - return self._parse_product() - else: - # Otherwise it's a sum. Look for ConstructorId - sumlist = [Constructor(self._match(TokenKind.ConstructorId), - self._parse_optional_fields())] - while self.cur_token.kind == TokenKind.Pipe: - # More constructors - self._advance() - sumlist.append(Constructor( - self._match(TokenKind.ConstructorId), - self._parse_optional_fields())) - return Sum(sumlist, self._parse_optional_attributes()) - - def _parse_product(self): - return Product(self._parse_fields(), self._parse_optional_attributes()) - - def _parse_fields(self): - fields = [] - self._match(TokenKind.LParen) - while self.cur_token.kind == TokenKind.TypeId: - typename = self._advance() - is_seq, is_opt = self._parse_optional_field_quantifier() - id = (self._advance() if self.cur_token.kind in self._id_kinds - else None) - fields.append(Field(typename, id, seq=is_seq, opt=is_opt)) - if self.cur_token.kind == TokenKind.RParen: - break - elif self.cur_token.kind == TokenKind.Comma: - self._advance() - self._match(TokenKind.RParen) - return fields - - def _parse_optional_fields(self): - if self.cur_token.kind == TokenKind.LParen: - return self._parse_fields() - else: - return None - - def _parse_optional_attributes(self): - if self._at_keyword('attributes'): - self._advance() - return self._parse_fields() - else: - return None - - def _parse_optional_field_quantifier(self): - is_seq, is_opt = False, False - if self.cur_token.kind == TokenKind.Asterisk: - is_seq = True - self._advance() - elif self.cur_token.kind == TokenKind.Question: - is_opt = True - self._advance() - return is_seq, is_opt - - def _advance(self): - """ Return the value of the current token and read the next one into - self.cur_token. - """ - cur_val = None if self.cur_token is None else self.cur_token.value - try: - self.cur_token = next(self._tokenizer) - except StopIteration: - self.cur_token = None - return cur_val - - _id_kinds = (TokenKind.ConstructorId, TokenKind.TypeId) - - def _match(self, kind): - """The 'match' primitive of RD parsers. - - * Verifies that the current token is of the given kind (kind can - be a tuple, in which the kind must match one of its members). - * Returns the value of the current token - * Reads in the next token - """ - if (isinstance(kind, tuple) and self.cur_token.kind in kind or - self.cur_token.kind == kind - ): - value = self.cur_token.value - self._advance() - return value - else: - raise ASDLSyntaxError( - 'Unmatched {} (found {})'.format(kind, self.cur_token.kind), - self.cur_token.lineno) - - def _at_keyword(self, keyword): - return (self.cur_token.kind == TokenKind.TypeId and - self.cur_token.value == keyword) + for dfn in mod.dfns: + output(dfn.name, dfn.value) diff -r ce070040e1a6 -r d7f128afe9db Parser/asdl_c.py --- a/Parser/asdl_c.py Sat May 10 13:24:58 2014 -0400 +++ b/Parser/asdl_c.py Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,9 @@ #! /usr/bin/env python """Generate C code from an ASDL description.""" +# TO DO +# handle fields that have a type but no name + import os, sys import asdl @@ -11,8 +14,12 @@ def get_c_type(name): """Return a string for the C name of the type. - This function special cases the default types provided by asdl. + This function special cases the default types provided by asdl: + identifier, string, int. """ + # XXX ack! need to figure out where Id is useful and where string + if isinstance(name, asdl.Id): + name = name.value if name in asdl.builtin_types: return name else: @@ -137,7 +144,7 @@ class StructVisitor(EmitVisitor): - """Visitor to generate typedefs for AST.""" + """Visitor to generate typdefs for AST.""" def visitModule(self, mod): for dfn in mod.dfns: @@ -181,6 +188,9 @@ self.visit(f, depth + 1) self.emit("} %s;" % cons.name, depth) self.emit("", depth) + else: + # XXX not sure what I want here, nothing is probably fine + pass def visitField(self, field, depth): # XXX need to lookup field.type, because it might be something @@ -188,7 +198,7 @@ ctype = get_c_type(field.type) name = field.name if field.seq: - if field.type == 'cmpop': + if field.type.value in ('cmpop',): self.emit("asdl_int_seq *%(name)s;" % locals(), depth) else: self.emit("asdl_seq *%(name)s;" % locals(), depth) @@ -243,7 +253,7 @@ name = f.name # XXX should extend get_c_type() to handle this if f.seq: - if f.type == 'cmpop': + if f.type.value in ('cmpop',): ctype = "asdl_int_seq *" else: ctype = "asdl_seq *" @@ -427,7 +437,7 @@ self.emit("", 0) for f in t.fields: self.visitField(f, t.name, sum=sum, depth=2) - args = [f.name for f in t.fields] + [a.name for a in sum.attributes] + args = [f.name.value for f in t.fields] + [a.name.value for a in sum.attributes] self.emit("*out = %s(%s);" % (t.name, self.buildArgs(args)), 2) self.emit("if (*out == NULL) goto failed;", 2) self.emit("return 0;", 2) @@ -455,7 +465,7 @@ self.emit("", 0) for f in prod.fields: self.visitField(f, name, prod=prod, depth=1) - args = [f.name for f in prod.fields] + args = [f.name.value for f in prod.fields] self.emit("*out = %s(%s);" % (name, self.buildArgs(args)), 1) self.emit("return 0;", 1) self.emit("failed:", 0) @@ -477,8 +487,8 @@ def isSimpleSum(self, field): # XXX can the members of this list be determined automatically? - return field.type in ('expr_context', 'boolop', 'operator', - 'unaryop', 'cmpop') + return field.type.value in ('expr_context', 'boolop', 'operator', + 'unaryop', 'cmpop') def isNumeric(self, field): return get_c_type(field.type) in ("int", "bool") @@ -950,7 +960,7 @@ def visitProduct(self, prod, name): if prod.fields: - fields = name+"_fields" + fields = name.value+"_fields" else: fields = "NULL" self.emit('%s_type = make_type("%s", &AST_type, %s, %d);' % @@ -977,7 +987,7 @@ def visitConstructor(self, cons, name, simple): if cons.fields: - fields = cons.name+"_fields" + fields = cons.name.value+"_fields" else: fields = "NULL" self.emit('%s_type = make_type("%s", %s_type, %s, %d);' % @@ -1160,7 +1170,7 @@ def set(self, field, value, depth): if field.seq: # XXX should really check for is_simple, but that requires a symbol table - if field.type == "cmpop": + if field.type.value == "cmpop": # While the sequence elements are stored as void*, # ast2obj_cmpop expects an enum self.emit("{", depth) @@ -1239,15 +1249,12 @@ common_msg = "/* File automatically generated by %s. */\n\n" -def main(srcfile, dump_module=False): +def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = common_msg % argv0 mod = asdl.parse(srcfile) - if dump_module: - print('Parsed Module:') - print(mod) if not asdl.check(mod): sys.exit(1) if INC_DIR: @@ -1294,19 +1301,16 @@ INC_DIR = '' SRC_DIR = '' - dump_module = False - opts, args = getopt.getopt(sys.argv[1:], "dh:c:") + opts, args = getopt.getopt(sys.argv[1:], "h:c:") + if len(opts) != 1: + sys.stdout.write("Must specify exactly one output file\n") + sys.exit(1) for o, v in opts: if o == '-h': INC_DIR = v if o == '-c': SRC_DIR = v - if o == '-d': - dump_module = True - if INC_DIR and SRC_DIR: - print('Must specify exactly one output file') + if len(args) != 1: + sys.stdout.write("Must specify single input file\n") sys.exit(1) - elif len(args) != 1: - print('Must specify single input file') - sys.exit(1) - main(args[0], dump_module) + main(args[0]) diff -r ce070040e1a6 -r d7f128afe9db Parser/spark.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Parser/spark.py Sun Mar 23 09:44:28 2014 +0100 @@ -0,0 +1,849 @@ +# Copyright (c) 1998-2002 John Aycock +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +__version__ = 'SPARK-0.7 (pre-alpha-5)' + +import re + +# Compatibility with older pythons. +def output(string='', end='\n'): + sys.stdout.write(string + end) + +try: + sorted +except NameError: + def sorted(seq): + seq2 = seq[:] + seq2.sort() + return seq2 + +def _namelist(instance): + namelist, namedict, classlist = [], {}, [instance.__class__] + for c in classlist: + for b in c.__bases__: + classlist.append(b) + for name in c.__dict__.keys(): + if name not in namedict: + namelist.append(name) + namedict[name] = 1 + return namelist + +class GenericScanner: + def __init__(self, flags=0): + pattern = self.reflect() + self.re = re.compile(pattern, re.VERBOSE|flags) + + self.index2func = {} + for name, number in self.re.groupindex.items(): + self.index2func[number-1] = getattr(self, 't_' + name) + + def makeRE(self, name): + doc = getattr(self, name).__doc__ + rv = '(?P<%s>%s)' % (name[2:], doc) + return rv + + def reflect(self): + rv = [] + for name in _namelist(self): + if name[:2] == 't_' and name != 't_default': + rv.append(self.makeRE(name)) + + rv.append(self.makeRE('t_default')) + return '|'.join(rv) + + def error(self, s, pos): + output("Lexical error at position %s" % pos) + raise SystemExit + + def tokenize(self, s): + pos = 0 + n = len(s) + while pos < n: + m = self.re.match(s, pos) + if m is None: + self.error(s, pos) + + groups = m.groups() + for i in range(len(groups)): + if groups[i] and i in self.index2func: + self.index2func[i](groups[i]) + pos = m.end() + + def t_default(self, s): + r'( . | \n )+' + output("Specification error: unmatched input") + raise SystemExit + +# +# Extracted from GenericParser and made global so that [un]picking works. +# +class _State: + def __init__(self, stateno, items): + self.T, self.complete, self.items = [], [], items + self.stateno = stateno + +class GenericParser: + # + # An Earley parser, as per J. Earley, "An Efficient Context-Free + # Parsing Algorithm", CACM 13(2), pp. 94-102. Also J. C. Earley, + # "An Efficient Context-Free Parsing Algorithm", Ph.D. thesis, + # Carnegie-Mellon University, August 1968. New formulation of + # the parser according to J. Aycock, "Practical Earley Parsing + # and the SPARK Toolkit", Ph.D. thesis, University of Victoria, + # 2001, and J. Aycock and R. N. Horspool, "Practical Earley + # Parsing", unpublished paper, 2001. + # + + def __init__(self, start): + self.rules = {} + self.rule2func = {} + self.rule2name = {} + self.collectRules() + self.augment(start) + self.ruleschanged = 1 + + _NULLABLE = '\e_' + _START = 'START' + _BOF = '|-' + + # + # When pickling, take the time to generate the full state machine; + # some information is then extraneous, too. Unfortunately we + # can't save the rule2func map. + # + def __getstate__(self): + if self.ruleschanged: + # + # XXX - duplicated from parse() + # + self.computeNull() + self.newrules = {} + self.new2old = {} + self.makeNewRules() + self.ruleschanged = 0 + self.edges, self.cores = {}, {} + self.states = { 0: self.makeState0() } + self.makeState(0, self._BOF) + # + # XXX - should find a better way to do this.. + # + changes = 1 + while changes: + changes = 0 + for k, v in self.edges.items(): + if v is None: + state, sym = k + if state in self.states: + self.goto(state, sym) + changes = 1 + rv = self.__dict__.copy() + for s in self.states.values(): + del s.items + del rv['rule2func'] + del rv['nullable'] + del rv['cores'] + return rv + + def __setstate__(self, D): + self.rules = {} + self.rule2func = {} + self.rule2name = {} + self.collectRules() + start = D['rules'][self._START][0][1][1] # Blech. + self.augment(start) + D['rule2func'] = self.rule2func + D['makeSet'] = self.makeSet_fast + self.__dict__ = D + + # + # A hook for GenericASTBuilder and GenericASTMatcher. Mess + # thee not with this; nor shall thee toucheth the _preprocess + # argument to addRule. + # + def preprocess(self, rule, func): return rule, func + + def addRule(self, doc, func, _preprocess=1): + fn = func + rules = doc.split() + + index = [] + for i in range(len(rules)): + if rules[i] == '::=': + index.append(i-1) + index.append(len(rules)) + + for i in range(len(index)-1): + lhs = rules[index[i]] + rhs = rules[index[i]+2:index[i+1]] + rule = (lhs, tuple(rhs)) + + if _preprocess: + rule, fn = self.preprocess(rule, func) + + if lhs in self.rules: + self.rules[lhs].append(rule) + else: + self.rules[lhs] = [ rule ] + self.rule2func[rule] = fn + self.rule2name[rule] = func.__name__[2:] + self.ruleschanged = 1 + + def collectRules(self): + for name in _namelist(self): + if name[:2] == 'p_': + func = getattr(self, name) + doc = func.__doc__ + self.addRule(doc, func) + + def augment(self, start): + rule = '%s ::= %s %s' % (self._START, self._BOF, start) + self.addRule(rule, lambda args: args[1], 0) + + def computeNull(self): + self.nullable = {} + tbd = [] + + for rulelist in self.rules.values(): + lhs = rulelist[0][0] + self.nullable[lhs] = 0 + for rule in rulelist: + rhs = rule[1] + if len(rhs) == 0: + self.nullable[lhs] = 1 + continue + # + # We only need to consider rules which + # consist entirely of nonterminal symbols. + # This should be a savings on typical + # grammars. + # + for sym in rhs: + if sym not in self.rules: + break + else: + tbd.append(rule) + changes = 1 + while changes: + changes = 0 + for lhs, rhs in tbd: + if self.nullable[lhs]: + continue + for sym in rhs: + if not self.nullable[sym]: + break + else: + self.nullable[lhs] = 1 + changes = 1 + + def makeState0(self): + s0 = _State(0, []) + for rule in self.newrules[self._START]: + s0.items.append((rule, 0)) + return s0 + + def finalState(self, tokens): + # + # Yuck. + # + if len(self.newrules[self._START]) == 2 and len(tokens) == 0: + return 1 + start = self.rules[self._START][0][1][1] + return self.goto(1, start) + + def makeNewRules(self): + worklist = [] + for rulelist in self.rules.values(): + for rule in rulelist: + worklist.append((rule, 0, 1, rule)) + + for rule, i, candidate, oldrule in worklist: + lhs, rhs = rule + n = len(rhs) + while i < n: + sym = rhs[i] + if sym not in self.rules or \ + not self.nullable[sym]: + candidate = 0 + i = i + 1 + continue + + newrhs = list(rhs) + newrhs[i] = self._NULLABLE+sym + newrule = (lhs, tuple(newrhs)) + worklist.append((newrule, i+1, + candidate, oldrule)) + candidate = 0 + i = i + 1 + else: + if candidate: + lhs = self._NULLABLE+lhs + rule = (lhs, rhs) + if lhs in self.newrules: + self.newrules[lhs].append(rule) + else: + self.newrules[lhs] = [ rule ] + self.new2old[rule] = oldrule + + def typestring(self, token): + return None + + def error(self, token): + output("Syntax error at or near `%s' token" % token) + raise SystemExit + + def parse(self, tokens): + sets = [ [(1,0), (2,0)] ] + self.links = {} + + if self.ruleschanged: + self.computeNull() + self.newrules = {} + self.new2old = {} + self.makeNewRules() + self.ruleschanged = 0 + self.edges, self.cores = {}, {} + self.states = { 0: self.makeState0() } + self.makeState(0, self._BOF) + + for i in range(len(tokens)): + sets.append([]) + + if sets[i] == []: + break + self.makeSet(tokens[i], sets, i) + else: + sets.append([]) + self.makeSet(None, sets, len(tokens)) + + #_dump(tokens, sets, self.states) + + finalitem = (self.finalState(tokens), 0) + if finalitem not in sets[-2]: + if len(tokens) > 0: + self.error(tokens[i-1]) + else: + self.error(None) + + return self.buildTree(self._START, finalitem, + tokens, len(sets)-2) + + def isnullable(self, sym): + # + # For symbols in G_e only. If we weren't supporting 1.5, + # could just use sym.startswith(). + # + return self._NULLABLE == sym[0:len(self._NULLABLE)] + + def skip(self, hs, pos=0): + n = len(hs[1]) + while pos < n: + if not self.isnullable(hs[1][pos]): + break + pos = pos + 1 + return pos + + def makeState(self, state, sym): + assert sym is not None + # + # Compute \epsilon-kernel state's core and see if + # it exists already. + # + kitems = [] + for rule, pos in self.states[state].items: + lhs, rhs = rule + if rhs[pos:pos+1] == (sym,): + kitems.append((rule, self.skip(rule, pos+1))) + core = kitems + + core.sort() + tcore = tuple(core) + if tcore in self.cores: + return self.cores[tcore] + # + # Nope, doesn't exist. Compute it and the associated + # \epsilon-nonkernel state together; we'll need it right away. + # + k = self.cores[tcore] = len(self.states) + K, NK = _State(k, kitems), _State(k+1, []) + self.states[k] = K + predicted = {} + + edges = self.edges + rules = self.newrules + for X in K, NK: + worklist = X.items + for item in worklist: + rule, pos = item + lhs, rhs = rule + if pos == len(rhs): + X.complete.append(rule) + continue + + nextSym = rhs[pos] + key = (X.stateno, nextSym) + if nextSym not in rules: + if key not in edges: + edges[key] = None + X.T.append(nextSym) + else: + edges[key] = None + if nextSym not in predicted: + predicted[nextSym] = 1 + for prule in rules[nextSym]: + ppos = self.skip(prule) + new = (prule, ppos) + NK.items.append(new) + # + # Problem: we know K needs generating, but we + # don't yet know about NK. Can't commit anything + # regarding NK to self.edges until we're sure. Should + # we delay committing on both K and NK to avoid this + # hacky code? This creates other problems.. + # + if X is K: + edges = {} + + if NK.items == []: + return k + + # + # Check for \epsilon-nonkernel's core. Unfortunately we + # need to know the entire set of predicted nonterminals + # to do this without accidentally duplicating states. + # + core = sorted(predicted.keys()) + tcore = tuple(core) + if tcore in self.cores: + self.edges[(k, None)] = self.cores[tcore] + return k + + nk = self.cores[tcore] = self.edges[(k, None)] = NK.stateno + self.edges.update(edges) + self.states[nk] = NK + return k + + def goto(self, state, sym): + key = (state, sym) + if key not in self.edges: + # + # No transitions from state on sym. + # + return None + + rv = self.edges[key] + if rv is None: + # + # Target state isn't generated yet. Remedy this. + # + rv = self.makeState(state, sym) + self.edges[key] = rv + return rv + + def gotoT(self, state, t): + return [self.goto(state, t)] + + def gotoST(self, state, st): + rv = [] + for t in self.states[state].T: + if st == t: + rv.append(self.goto(state, t)) + return rv + + def add(self, set, item, i=None, predecessor=None, causal=None): + if predecessor is None: + if item not in set: + set.append(item) + else: + key = (item, i) + if item not in set: + self.links[key] = [] + set.append(item) + self.links[key].append((predecessor, causal)) + + def makeSet(self, token, sets, i): + cur, next = sets[i], sets[i+1] + + ttype = token is not None and self.typestring(token) or None + if ttype is not None: + fn, arg = self.gotoT, ttype + else: + fn, arg = self.gotoST, token + + for item in cur: + ptr = (item, i) + state, parent = item + add = fn(state, arg) + for k in add: + if k is not None: + self.add(next, (k, parent), i+1, ptr) + nk = self.goto(k, None) + if nk is not None: + self.add(next, (nk, i+1)) + + if parent == i: + continue + + for rule in self.states[state].complete: + lhs, rhs = rule + for pitem in sets[parent]: + pstate, pparent = pitem + k = self.goto(pstate, lhs) + if k is not None: + why = (item, i, rule) + pptr = (pitem, parent) + self.add(cur, (k, pparent), + i, pptr, why) + nk = self.goto(k, None) + if nk is not None: + self.add(cur, (nk, i)) + + def makeSet_fast(self, token, sets, i): + # + # Call *only* when the entire state machine has been built! + # It relies on self.edges being filled in completely, and + # then duplicates and inlines code to boost speed at the + # cost of extreme ugliness. + # + cur, next = sets[i], sets[i+1] + ttype = token is not None and self.typestring(token) or None + + for item in cur: + ptr = (item, i) + state, parent = item + if ttype is not None: + k = self.edges.get((state, ttype), None) + if k is not None: + #self.add(next, (k, parent), i+1, ptr) + #INLINED --v + new = (k, parent) + key = (new, i+1) + if new not in next: + self.links[key] = [] + next.append(new) + self.links[key].append((ptr, None)) + #INLINED --^ + #nk = self.goto(k, None) + nk = self.edges.get((k, None), None) + if nk is not None: + #self.add(next, (nk, i+1)) + #INLINED --v + new = (nk, i+1) + if new not in next: + next.append(new) + #INLINED --^ + else: + add = self.gotoST(state, token) + for k in add: + if k is not None: + self.add(next, (k, parent), i+1, ptr) + #nk = self.goto(k, None) + nk = self.edges.get((k, None), None) + if nk is not None: + self.add(next, (nk, i+1)) + + if parent == i: + continue + + for rule in self.states[state].complete: + lhs, rhs = rule + for pitem in sets[parent]: + pstate, pparent = pitem + #k = self.goto(pstate, lhs) + k = self.edges.get((pstate, lhs), None) + if k is not None: + why = (item, i, rule) + pptr = (pitem, parent) + #self.add(cur, (k, pparent), + # i, pptr, why) + #INLINED --v + new = (k, pparent) + key = (new, i) + if new not in cur: + self.links[key] = [] + cur.append(new) + self.links[key].append((pptr, why)) + #INLINED --^ + #nk = self.goto(k, None) + nk = self.edges.get((k, None), None) + if nk is not None: + #self.add(cur, (nk, i)) + #INLINED --v + new = (nk, i) + if new not in cur: + cur.append(new) + #INLINED --^ + + def predecessor(self, key, causal): + for p, c in self.links[key]: + if c == causal: + return p + assert 0 + + def causal(self, key): + links = self.links[key] + if len(links) == 1: + return links[0][1] + choices = [] + rule2cause = {} + for p, c in links: + rule = c[2] + choices.append(rule) + rule2cause[rule] = c + return rule2cause[self.ambiguity(choices)] + + def deriveEpsilon(self, nt): + if len(self.newrules[nt]) > 1: + rule = self.ambiguity(self.newrules[nt]) + else: + rule = self.newrules[nt][0] + #output(rule) + + rhs = rule[1] + attr = [None] * len(rhs) + + for i in range(len(rhs)-1, -1, -1): + attr[i] = self.deriveEpsilon(rhs[i]) + return self.rule2func[self.new2old[rule]](attr) + + def buildTree(self, nt, item, tokens, k): + state, parent = item + + choices = [] + for rule in self.states[state].complete: + if rule[0] == nt: + choices.append(rule) + rule = choices[0] + if len(choices) > 1: + rule = self.ambiguity(choices) + #output(rule) + + rhs = rule[1] + attr = [None] * len(rhs) + + for i in range(len(rhs)-1, -1, -1): + sym = rhs[i] + if sym not in self.newrules: + if sym != self._BOF: + attr[i] = tokens[k-1] + key = (item, k) + item, k = self.predecessor(key, None) + #elif self.isnullable(sym): + elif self._NULLABLE == sym[0:len(self._NULLABLE)]: + attr[i] = self.deriveEpsilon(sym) + else: + key = (item, k) + why = self.causal(key) + attr[i] = self.buildTree(sym, why[0], + tokens, why[1]) + item, k = self.predecessor(key, why) + return self.rule2func[self.new2old[rule]](attr) + + def ambiguity(self, rules): + # + # XXX - problem here and in collectRules() if the same rule + # appears in >1 method. Also undefined results if rules + # causing the ambiguity appear in the same method. + # + sortlist = [] + name2index = {} + for i in range(len(rules)): + lhs, rhs = rule = rules[i] + name = self.rule2name[self.new2old[rule]] + sortlist.append((len(rhs), name)) + name2index[name] = i + sortlist.sort() + list = [b for a, b in sortlist] + return rules[name2index[self.resolve(list)]] + + def resolve(self, list): + # + # Resolve ambiguity in favor of the shortest RHS. + # Since we walk the tree from the top down, this + # should effectively resolve in favor of a "shift". + # + return list[0] + +# +# GenericASTBuilder automagically constructs a concrete/abstract syntax tree +# for a given input. The extra argument is a class (not an instance!) +# which supports the "__setslice__" and "__len__" methods. +# +# XXX - silently overrides any user code in methods. +# + +class GenericASTBuilder(GenericParser): + def __init__(self, AST, start): + GenericParser.__init__(self, start) + self.AST = AST + + def preprocess(self, rule, func): + rebind = lambda lhs, self=self: \ + lambda args, lhs=lhs, self=self: \ + self.buildASTNode(args, lhs) + lhs, rhs = rule + return rule, rebind(lhs) + + def buildASTNode(self, args, lhs): + children = [] + for arg in args: + if isinstance(arg, self.AST): + children.append(arg) + else: + children.append(self.terminal(arg)) + return self.nonterminal(lhs, children) + + def terminal(self, token): return token + + def nonterminal(self, type, args): + rv = self.AST(type) + rv[:len(args)] = args + return rv + +# +# GenericASTTraversal is a Visitor pattern according to Design Patterns. For +# each node it attempts to invoke the method n_, falling +# back onto the default() method if the n_* can't be found. The preorder +# traversal also looks for an exit hook named n__exit (no default +# routine is called if it's not found). To prematurely halt traversal +# of a subtree, call the prune() method -- this only makes sense for a +# preorder traversal. Node type is determined via the typestring() method. +# + +class GenericASTTraversalPruningException: + pass + +class GenericASTTraversal: + def __init__(self, ast): + self.ast = ast + + def typestring(self, node): + return node.type + + def prune(self): + raise GenericASTTraversalPruningException + + def preorder(self, node=None): + if node is None: + node = self.ast + + try: + name = 'n_' + self.typestring(node) + if hasattr(self, name): + func = getattr(self, name) + func(node) + else: + self.default(node) + except GenericASTTraversalPruningException: + return + + for kid in node: + self.preorder(kid) + + name = name + '_exit' + if hasattr(self, name): + func = getattr(self, name) + func(node) + + def postorder(self, node=None): + if node is None: + node = self.ast + + for kid in node: + self.postorder(kid) + + name = 'n_' + self.typestring(node) + if hasattr(self, name): + func = getattr(self, name) + func(node) + else: + self.default(node) + + + def default(self, node): + pass + +# +# GenericASTMatcher. AST nodes must have "__getitem__" and "__cmp__" +# implemented. +# +# XXX - makes assumptions about how GenericParser walks the parse tree. +# + +class GenericASTMatcher(GenericParser): + def __init__(self, start, ast): + GenericParser.__init__(self, start) + self.ast = ast + + def preprocess(self, rule, func): + rebind = lambda func, self=self: \ + lambda args, func=func, self=self: \ + self.foundMatch(args, func) + lhs, rhs = rule + rhslist = list(rhs) + rhslist.reverse() + + return (lhs, tuple(rhslist)), rebind(func) + + def foundMatch(self, args, func): + func(args[-1]) + return args[-1] + + def match_r(self, node): + self.input.insert(0, node) + children = 0 + + for child in node: + if children == 0: + self.input.insert(0, '(') + children = children + 1 + self.match_r(child) + + if children > 0: + self.input.insert(0, ')') + + def match(self, ast=None): + if ast is None: + ast = self.ast + self.input = [] + + self.match_r(ast) + self.parse(self.input) + + def resolve(self, list): + # + # Resolve ambiguity in favor of the longest RHS. + # + return list[-1] + +def _dump(tokens, sets, states): + for i in range(len(sets)): + output('set %d' % i) + for item in sets[i]: + output('\t', item) + for (lhs, rhs), pos in states[item[0]].items: + output('\t\t', lhs, '::=', end='') + output(' '.join(rhs[:pos]), end='') + output('.', end='') + output(' '.join(rhs[pos:])) + if i < len(tokens): + output() + output('token %s' % str(tokens[i])) + output() diff -r ce070040e1a6 -r d7f128afe9db Parser/tokenizer.c --- a/Parser/tokenizer.c Sat May 10 13:24:58 2014 -0400 +++ b/Parser/tokenizer.c Sun Mar 23 09:44:28 2014 +0100 @@ -98,7 +98,6 @@ "DOUBLESLASH", "DOUBLESLASHEQUAL", "AT", - "ATEQUAL", "RARROW", "ELLIPSIS", /* This table must match the #defines in token.h! */ @@ -1132,7 +1131,7 @@ case '}': return RBRACE; case '^': return CIRCUMFLEX; case '~': return TILDE; - case '@': return AT; + case '@': return AT; default: return OP; } } @@ -1208,11 +1207,6 @@ case '=': return CIRCUMFLEXEQUAL; } break; - case '@': - switch (c2) { - case '=': return ATEQUAL; - } - break; } return OP; } diff -r ce070040e1a6 -r d7f128afe9db Python/Python-ast.c --- a/Python/Python-ast.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/Python-ast.c Sun Mar 23 09:44:28 2014 +0100 @@ -349,14 +349,13 @@ static PyTypeObject *Or_type; static PyTypeObject *operator_type; static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton, -*MatMult_singleton, *Div_singleton, *Mod_singleton, *Pow_singleton, -*LShift_singleton, *RShift_singleton, *BitOr_singleton, *BitXor_singleton, -*BitAnd_singleton, *FloorDiv_singleton; +*Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton, +*RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton, +*FloorDiv_singleton; static PyObject* ast2obj_operator(operator_ty); static PyTypeObject *Add_type; static PyTypeObject *Sub_type; static PyTypeObject *Mult_type; -static PyTypeObject *MatMult_type; static PyTypeObject *Div_type; static PyTypeObject *Mod_type; static PyTypeObject *Pow_type; @@ -971,10 +970,6 @@ if (!Mult_type) return 0; Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); if (!Mult_singleton) return 0; - MatMult_type = make_type("MatMult", operator_type, NULL, 0); - if (!MatMult_type) return 0; - MatMult_singleton = PyType_GenericNew(MatMult_type, NULL, NULL); - if (!MatMult_singleton) return 0; Div_type = make_type("Div", operator_type, NULL, 0); if (!Div_type) return 0; Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); @@ -3237,9 +3232,6 @@ case Mult: Py_INCREF(Mult_singleton); return Mult_singleton; - case MatMult: - Py_INCREF(MatMult_singleton); - return MatMult_singleton; case Div: Py_INCREF(Div_singleton); return Div_singleton; @@ -6183,14 +6175,6 @@ *out = Mult; return 0; } - isinstance = PyObject_IsInstance(obj, (PyObject *)MatMult_type); - if (isinstance == -1) { - return 1; - } - if (isinstance) { - *out = MatMult; - return 0; - } isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); if (isinstance == -1) { return 1; @@ -6972,8 +6956,6 @@ if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return NULL; if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return NULL; if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return NULL; - if (PyDict_SetItemString(d, "MatMult", (PyObject*)MatMult_type) < 0) return - NULL; if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return NULL; if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return NULL; if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return NULL; diff -r ce070040e1a6 -r d7f128afe9db Python/ast.c --- a/Python/ast.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/ast.c Sun Mar 23 09:44:28 2014 +0100 @@ -825,8 +825,6 @@ return Sub; case STAR: return Mult; - case AT: - return MatMult; case SLASH: return Div; case DOUBLESLASH: @@ -1032,8 +1030,6 @@ return Pow; else return Mult; - case '@': - return MatMult; default: PyErr_Format(PyExc_SystemError, "invalid augassign: %s", STR(n)); return (operator_ty)0; @@ -2270,7 +2266,7 @@ and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* - term: factor (('*'|'@'|'/'|'%'|'//') factor)* + term: factor (('*'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power power: atom trailer* ('**' factor)* */ @@ -2581,7 +2577,7 @@ /* expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*) testlist_star_expr: (test|star_expr) (',' test|star_expr)* [','] - augassign: '+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' + augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=' test: ... here starts the operator precendence dance */ diff -r ce070040e1a6 -r d7f128afe9db Python/bltinmodule.c --- a/Python/bltinmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/bltinmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -1325,7 +1325,7 @@ } PyDoc_STRVAR(len_doc, -"len(object)\n\ +"len(module, object)\n\ \n\ Return the number of items of a sequence or mapping."); diff -r ce070040e1a6 -r d7f128afe9db Python/ceval.c --- a/Python/ceval.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/ceval.c Sun Mar 23 09:44:28 2014 +0100 @@ -1495,18 +1495,6 @@ DISPATCH(); } - TARGET(BINARY_MATRIX_MULTIPLY) { - PyObject *right = POP(); - PyObject *left = TOP(); - PyObject *res = PyNumber_MatrixMultiply(left, right); - Py_DECREF(left); - Py_DECREF(right); - SET_TOP(res); - if (res == NULL) - goto error; - DISPATCH(); - } - TARGET(BINARY_TRUE_DIVIDE) { PyObject *divisor = POP(); PyObject *dividend = TOP(); @@ -1697,18 +1685,6 @@ DISPATCH(); } - TARGET(INPLACE_MATRIX_MULTIPLY) { - PyObject *right = POP(); - PyObject *left = TOP(); - PyObject *res = PyNumber_InPlaceMatrixMultiply(left, right); - Py_DECREF(left); - Py_DECREF(right); - SET_TOP(res); - if (res == NULL) - goto error; - DISPATCH(); - } - TARGET(INPLACE_TRUE_DIVIDE) { PyObject *divisor = POP(); PyObject *dividend = TOP(); @@ -1926,7 +1902,7 @@ if (v == Py_None) retval = Py_TYPE(reciever)->tp_iternext(reciever); else - retval = _PyObject_CallMethodIdObjArgs(reciever, &PyId_send, v, NULL); + retval = _PyObject_CallMethodId(reciever, &PyId_send, "O", v); } Py_DECREF(v); if (retval == NULL) { diff -r ce070040e1a6 -r d7f128afe9db Python/compile.c --- a/Python/compile.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/compile.c Sun Mar 23 09:44:28 2014 +0100 @@ -881,7 +881,6 @@ case BINARY_POWER: case BINARY_MULTIPLY: - case BINARY_MATRIX_MULTIPLY: case BINARY_MODULO: case BINARY_ADD: case BINARY_SUBTRACT: @@ -896,7 +895,6 @@ case INPLACE_ADD: case INPLACE_SUBTRACT: case INPLACE_MULTIPLY: - case INPLACE_MATRIX_MULTIPLY: case INPLACE_MODULO: return -1; case STORE_SUBSCR: @@ -2627,8 +2625,6 @@ return BINARY_SUBTRACT; case Mult: return BINARY_MULTIPLY; - case MatMult: - return BINARY_MATRIX_MULTIPLY; case Div: return BINARY_TRUE_DIVIDE; case Mod: @@ -2693,8 +2689,6 @@ return INPLACE_SUBTRACT; case Mult: return INPLACE_MULTIPLY; - case MatMult: - return INPLACE_MATRIX_MULTIPLY; case Div: return INPLACE_TRUE_DIVIDE; case Mod: diff -r ce070040e1a6 -r d7f128afe9db Python/condvar.h --- a/Python/condvar.h Sat May 10 13:24:58 2014 -0400 +++ b/Python/condvar.h Sun Mar 23 09:44:28 2014 +0100 @@ -60,7 +60,7 @@ #include #define PyCOND_ADD_MICROSECONDS(tv, interval) \ -do { /* TODO: add overflow and truncation checks */ \ +do { \ tv.tv_usec += (long) interval; \ tv.tv_sec += tv.tv_usec / 1000000; \ tv.tv_usec %= 1000000; \ @@ -89,7 +89,7 @@ /* return 0 for success, 1 on timeout, -1 on error */ Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, long us) { int r; struct timespec ts; @@ -270,9 +270,9 @@ } Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, long us) { - return _PyCOND_WAIT_MS(cv, cs, (DWORD)(us/1000)); + return _PyCOND_WAIT_MS(cv, cs, us/1000); } Py_LOCAL_INLINE(int) @@ -363,9 +363,9 @@ * 2 to indicate that we don't know. */ Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, long us) { - return SleepConditionVariableSRW(cv, cs, (DWORD)(us/1000), 0) ? 2 : -1; + return SleepConditionVariableSRW(cv, cs, us/1000, 0) ? 2 : -1; } Py_LOCAL_INLINE(int) diff -r ce070040e1a6 -r d7f128afe9db Python/formatter_unicode.c --- a/Python/formatter_unicode.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/formatter_unicode.c Sun Mar 23 09:44:28 2014 +0100 @@ -156,9 +156,8 @@ Py_ssize_t consumed; int align_specified = 0; - int fill_char_specified = 0; - format->fill_char = ' '; + format->fill_char = '\0'; format->align = default_align; format->alternate = 0; format->sign = '\0'; @@ -172,7 +171,6 @@ if (end-pos >= 2 && is_alignment_token(READ_spec(pos+1))) { format->align = READ_spec(pos+1); format->fill_char = READ_spec(pos); - fill_char_specified = 1; align_specified = 1; pos += 2; } @@ -196,7 +194,7 @@ } /* The special case for 0-padding (backwards compat) */ - if (!fill_char_specified && end-pos >= 1 && READ_spec(pos) == '0') { + if (format->fill_char == '\0' && end-pos >= 1 && READ_spec(pos) == '0') { format->fill_char = '0'; if (!align_specified) { format->align = '='; @@ -786,7 +784,9 @@ goto done; /* Write into that space. First the padding. */ - result = fill_padding(writer, len, format->fill_char, lpad, rpad); + result = fill_padding(writer, len, + format->fill_char=='\0'?' ':format->fill_char, + lpad, rpad); if (result == -1) goto done; @@ -846,13 +846,6 @@ " format specifier 'c'"); goto done; } - /* error to request alternate format */ - if (format->alternate) { - PyErr_SetString(PyExc_ValueError, - "Alternate form (#) not allowed with integer" - " format specifier 'c'"); - goto done; - } /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ @@ -963,7 +956,8 @@ /* Populate the memory. */ result = fill_number(writer, &spec, tmp, inumeric_chars, inumeric_chars + n_digits, - tmp, prefix, format->fill_char, + tmp, prefix, + format->fill_char == '\0' ? ' ' : format->fill_char, &locale, format->type == 'X'); done: @@ -1110,7 +1104,8 @@ /* Populate the memory. */ result = fill_number(writer, &spec, unicode_tmp, index, index + n_digits, - NULL, 0, format->fill_char, + NULL, 0, + format->fill_char == '\0' ? ' ' : format->fill_char, &locale, 0); done: @@ -1316,7 +1311,8 @@ /* Populate the memory. First, the padding. */ result = fill_padding(writer, n_re_total + n_im_total + 1 + add_parens * 2, - format->fill_char, lpad, rpad); + format->fill_char=='\0' ? ' ' : format->fill_char, + lpad, rpad); if (result == -1) goto done; diff -r ce070040e1a6 -r d7f128afe9db Python/graminit.c --- a/Python/graminit.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/graminit.c Sun Mar 23 09:44:28 2014 +0100 @@ -476,7 +476,7 @@ {2, arcs_16_1}, {3, arcs_16_2}, }; -static arc arcs_17_0[13] = { +static arc arcs_17_0[12] = { {49, 1}, {50, 1}, {51, 1}, @@ -489,20 +489,19 @@ {58, 1}, {59, 1}, {60, 1}, - {61, 1}, }; static arc arcs_17_1[1] = { {0, 1}, }; static state states_17[2] = { - {13, arcs_17_0}, + {12, arcs_17_0}, {1, arcs_17_1}, }; static arc arcs_18_0[1] = { - {62, 1}, + {61, 1}, }; static arc arcs_18_1[1] = { - {63, 2}, + {62, 2}, }; static arc arcs_18_2[1] = { {0, 2}, @@ -513,7 +512,7 @@ {1, arcs_18_2}, }; static arc arcs_19_0[1] = { - {64, 1}, + {63, 1}, }; static arc arcs_19_1[1] = { {0, 1}, @@ -523,11 +522,11 @@ {1, arcs_19_1}, }; static arc arcs_20_0[5] = { + {64, 1}, {65, 1}, {66, 1}, {67, 1}, {68, 1}, - {69, 1}, }; static arc arcs_20_1[1] = { {0, 1}, @@ -537,7 +536,7 @@ {1, arcs_20_1}, }; static arc arcs_21_0[1] = { - {70, 1}, + {69, 1}, }; static arc arcs_21_1[1] = { {0, 1}, @@ -547,7 +546,7 @@ {1, arcs_21_1}, }; static arc arcs_22_0[1] = { - {71, 1}, + {70, 1}, }; static arc arcs_22_1[1] = { {0, 1}, @@ -557,7 +556,7 @@ {1, arcs_22_1}, }; static arc arcs_23_0[1] = { - {72, 1}, + {71, 1}, }; static arc arcs_23_1[2] = { {9, 2}, @@ -582,14 +581,14 @@ {1, arcs_24_1}, }; static arc arcs_25_0[1] = { - {73, 1}, + {72, 1}, }; static arc arcs_25_1[2] = { {24, 2}, {0, 1}, }; static arc arcs_25_2[2] = { - {74, 3}, + {73, 3}, {0, 2}, }; static arc arcs_25_3[1] = { @@ -606,8 +605,8 @@ {1, arcs_25_4}, }; static arc arcs_26_0[2] = { + {74, 1}, {75, 1}, - {76, 1}, }; static arc arcs_26_1[1] = { {0, 1}, @@ -617,10 +616,10 @@ {1, arcs_26_1}, }; static arc arcs_27_0[1] = { - {77, 1}, + {76, 1}, }; static arc arcs_27_1[1] = { - {78, 2}, + {77, 2}, }; static arc arcs_27_2[1] = { {0, 2}, @@ -631,32 +630,32 @@ {1, arcs_27_2}, }; static arc arcs_28_0[1] = { - {74, 1}, + {73, 1}, }; static arc arcs_28_1[3] = { + {78, 2}, {79, 2}, - {80, 2}, {12, 3}, }; static arc arcs_28_2[4] = { + {78, 2}, {79, 2}, - {80, 2}, {12, 3}, - {77, 4}, + {76, 4}, }; static arc arcs_28_3[1] = { - {77, 4}, + {76, 4}, }; static arc arcs_28_4[3] = { {31, 5}, {13, 6}, - {81, 5}, + {80, 5}, }; static arc arcs_28_5[1] = { {0, 5}, }; static arc arcs_28_6[1] = { - {81, 7}, + {80, 7}, }; static arc arcs_28_7[1] = { {15, 5}, @@ -675,7 +674,7 @@ {21, 1}, }; static arc arcs_29_1[2] = { - {83, 2}, + {82, 2}, {0, 1}, }; static arc arcs_29_2[1] = { @@ -694,7 +693,7 @@ {12, 1}, }; static arc arcs_30_1[2] = { - {83, 2}, + {82, 2}, {0, 1}, }; static arc arcs_30_2[1] = { @@ -710,14 +709,14 @@ {1, arcs_30_3}, }; static arc arcs_31_0[1] = { - {82, 1}, + {81, 1}, }; static arc arcs_31_1[2] = { {30, 2}, {0, 1}, }; static arc arcs_31_2[2] = { - {82, 1}, + {81, 1}, {0, 2}, }; static state states_31[3] = { @@ -726,7 +725,7 @@ {2, arcs_31_2}, }; static arc arcs_32_0[1] = { - {84, 1}, + {83, 1}, }; static arc arcs_32_1[2] = { {30, 0}, @@ -740,7 +739,7 @@ {21, 1}, }; static arc arcs_33_1[2] = { - {79, 0}, + {78, 0}, {0, 1}, }; static state states_33[2] = { @@ -748,7 +747,7 @@ {2, arcs_33_1}, }; static arc arcs_34_0[1] = { - {85, 1}, + {84, 1}, }; static arc arcs_34_1[1] = { {21, 2}, @@ -763,7 +762,7 @@ {2, arcs_34_2}, }; static arc arcs_35_0[1] = { - {86, 1}, + {85, 1}, }; static arc arcs_35_1[1] = { {21, 2}, @@ -778,7 +777,7 @@ {2, arcs_35_2}, }; static arc arcs_36_0[1] = { - {87, 1}, + {86, 1}, }; static arc arcs_36_1[1] = { {24, 2}, @@ -801,11 +800,11 @@ {1, arcs_36_4}, }; static arc arcs_37_0[8] = { + {87, 1}, {88, 1}, {89, 1}, {90, 1}, {91, 1}, - {92, 1}, {19, 1}, {18, 1}, {17, 1}, @@ -818,7 +817,7 @@ {1, arcs_37_1}, }; static arc arcs_38_0[1] = { - {93, 1}, + {92, 1}, }; static arc arcs_38_1[1] = { {24, 2}, @@ -830,8 +829,8 @@ {26, 4}, }; static arc arcs_38_4[3] = { - {94, 1}, - {95, 5}, + {93, 1}, + {94, 5}, {0, 4}, }; static arc arcs_38_5[1] = { @@ -854,7 +853,7 @@ {1, arcs_38_7}, }; static arc arcs_39_0[1] = { - {96, 1}, + {95, 1}, }; static arc arcs_39_1[1] = { {24, 2}, @@ -866,7 +865,7 @@ {26, 4}, }; static arc arcs_39_4[2] = { - {95, 5}, + {94, 5}, {0, 4}, }; static arc arcs_39_5[1] = { @@ -889,13 +888,13 @@ {1, arcs_39_7}, }; static arc arcs_40_0[1] = { - {97, 1}, + {96, 1}, }; static arc arcs_40_1[1] = { - {63, 2}, + {62, 2}, }; static arc arcs_40_2[1] = { - {98, 3}, + {97, 3}, }; static arc arcs_40_3[1] = { {9, 4}, @@ -907,7 +906,7 @@ {26, 6}, }; static arc arcs_40_6[2] = { - {95, 7}, + {94, 7}, {0, 6}, }; static arc arcs_40_7[1] = { @@ -932,7 +931,7 @@ {1, arcs_40_9}, }; static arc arcs_41_0[1] = { - {99, 1}, + {98, 1}, }; static arc arcs_41_1[1] = { {25, 2}, @@ -941,8 +940,8 @@ {26, 3}, }; static arc arcs_41_3[2] = { - {100, 4}, - {101, 5}, + {99, 4}, + {100, 5}, }; static arc arcs_41_4[1] = { {25, 6}, @@ -957,9 +956,9 @@ {26, 9}, }; static arc arcs_41_8[4] = { - {100, 4}, - {95, 10}, - {101, 5}, + {99, 4}, + {94, 10}, + {100, 5}, {0, 8}, }; static arc arcs_41_9[1] = { @@ -972,7 +971,7 @@ {26, 12}, }; static arc arcs_41_12[2] = { - {101, 5}, + {100, 5}, {0, 12}, }; static state states_41[13] = { @@ -991,10 +990,10 @@ {2, arcs_41_12}, }; static arc arcs_42_0[1] = { - {102, 1}, + {101, 1}, }; static arc arcs_42_1[1] = { - {103, 2}, + {102, 2}, }; static arc arcs_42_2[2] = { {30, 1}, @@ -1017,11 +1016,11 @@ {24, 1}, }; static arc arcs_43_1[2] = { - {83, 2}, + {82, 2}, {0, 1}, }; static arc arcs_43_2[1] = { - {104, 3}, + {103, 3}, }; static arc arcs_43_3[1] = { {0, 3}, @@ -1033,14 +1032,14 @@ {1, arcs_43_3}, }; static arc arcs_44_0[1] = { - {105, 1}, + {104, 1}, }; static arc arcs_44_1[2] = { {24, 2}, {0, 1}, }; static arc arcs_44_2[2] = { - {83, 3}, + {82, 3}, {0, 2}, }; static arc arcs_44_3[1] = { @@ -1064,14 +1063,14 @@ {0, 1}, }; static arc arcs_45_2[1] = { - {106, 3}, + {105, 3}, }; static arc arcs_45_3[1] = { {6, 4}, }; static arc arcs_45_4[2] = { {6, 4}, - {107, 1}, + {106, 1}, }; static state states_45[5] = { {2, arcs_45_0}, @@ -1081,21 +1080,21 @@ {2, arcs_45_4}, }; static arc arcs_46_0[2] = { - {108, 1}, - {109, 2}, + {107, 1}, + {108, 2}, }; static arc arcs_46_1[2] = { - {93, 3}, + {92, 3}, {0, 1}, }; static arc arcs_46_2[1] = { {0, 2}, }; static arc arcs_46_3[1] = { - {108, 4}, + {107, 4}, }; static arc arcs_46_4[1] = { - {95, 5}, + {94, 5}, }; static arc arcs_46_5[1] = { {24, 2}, @@ -1109,8 +1108,8 @@ {1, arcs_46_5}, }; static arc arcs_47_0[2] = { - {108, 1}, - {111, 1}, + {107, 1}, + {110, 1}, }; static arc arcs_47_1[1] = { {0, 1}, @@ -1120,7 +1119,7 @@ {1, arcs_47_1}, }; static arc arcs_48_0[1] = { - {112, 1}, + {111, 1}, }; static arc arcs_48_1[2] = { {33, 2}, @@ -1143,7 +1142,7 @@ {1, arcs_48_4}, }; static arc arcs_49_0[1] = { - {112, 1}, + {111, 1}, }; static arc arcs_49_1[2] = { {33, 2}, @@ -1153,7 +1152,7 @@ {25, 3}, }; static arc arcs_49_3[1] = { - {110, 4}, + {109, 4}, }; static arc arcs_49_4[1] = { {0, 4}, @@ -1166,10 +1165,10 @@ {1, arcs_49_4}, }; static arc arcs_50_0[1] = { - {113, 1}, + {112, 1}, }; static arc arcs_50_1[2] = { - {114, 0}, + {113, 0}, {0, 1}, }; static state states_50[2] = { @@ -1177,10 +1176,10 @@ {2, arcs_50_1}, }; static arc arcs_51_0[1] = { - {115, 1}, + {114, 1}, }; static arc arcs_51_1[2] = { - {116, 0}, + {115, 0}, {0, 1}, }; static state states_51[2] = { @@ -1188,11 +1187,11 @@ {2, arcs_51_1}, }; static arc arcs_52_0[2] = { - {117, 1}, - {118, 2}, + {116, 1}, + {117, 2}, }; static arc arcs_52_1[1] = { - {115, 2}, + {114, 2}, }; static arc arcs_52_2[1] = { {0, 2}, @@ -1203,10 +1202,10 @@ {1, arcs_52_2}, }; static arc arcs_53_0[1] = { - {104, 1}, + {103, 1}, }; static arc arcs_53_1[2] = { - {119, 0}, + {118, 0}, {0, 1}, }; static state states_53[2] = { @@ -1214,25 +1213,25 @@ {2, arcs_53_1}, }; static arc arcs_54_0[10] = { + {119, 1}, {120, 1}, {121, 1}, {122, 1}, {123, 1}, {124, 1}, {125, 1}, - {126, 1}, - {98, 1}, - {117, 2}, - {127, 3}, + {97, 1}, + {116, 2}, + {126, 3}, }; static arc arcs_54_1[1] = { {0, 1}, }; static arc arcs_54_2[1] = { - {98, 1}, + {97, 1}, }; static arc arcs_54_3[2] = { - {117, 1}, + {116, 1}, {0, 3}, }; static state states_54[4] = { @@ -1245,7 +1244,7 @@ {31, 1}, }; static arc arcs_55_1[1] = { - {104, 2}, + {103, 2}, }; static arc arcs_55_2[1] = { {0, 2}, @@ -1256,10 +1255,10 @@ {1, arcs_55_2}, }; static arc arcs_56_0[1] = { - {128, 1}, + {127, 1}, }; static arc arcs_56_1[2] = { - {129, 0}, + {128, 0}, {0, 1}, }; static state states_56[2] = { @@ -1267,10 +1266,10 @@ {2, arcs_56_1}, }; static arc arcs_57_0[1] = { - {130, 1}, + {129, 1}, }; static arc arcs_57_1[2] = { - {131, 0}, + {130, 0}, {0, 1}, }; static state states_57[2] = { @@ -1278,10 +1277,10 @@ {2, arcs_57_1}, }; static arc arcs_58_0[1] = { - {132, 1}, + {131, 1}, }; static arc arcs_58_1[2] = { - {133, 0}, + {132, 0}, {0, 1}, }; static state states_58[2] = { @@ -1289,11 +1288,11 @@ {2, arcs_58_1}, }; static arc arcs_59_0[1] = { - {134, 1}, + {133, 1}, }; static arc arcs_59_1[3] = { + {134, 0}, {135, 0}, - {136, 0}, {0, 1}, }; static state states_59[2] = { @@ -1301,11 +1300,11 @@ {3, arcs_59_1}, }; static arc arcs_60_0[1] = { - {137, 1}, + {136, 1}, }; static arc arcs_60_1[3] = { + {137, 0}, {138, 0}, - {139, 0}, {0, 1}, }; static state states_60[2] = { @@ -1313,28 +1312,27 @@ {3, arcs_60_1}, }; static arc arcs_61_0[1] = { - {140, 1}, + {139, 1}, }; -static arc arcs_61_1[6] = { +static arc arcs_61_1[5] = { {31, 0}, - {11, 0}, + {140, 0}, {141, 0}, {142, 0}, - {143, 0}, {0, 1}, }; static state states_61[2] = { {1, arcs_61_0}, - {6, arcs_61_1}, + {5, arcs_61_1}, }; static arc arcs_62_0[4] = { + {137, 1}, {138, 1}, - {139, 1}, - {144, 1}, - {145, 2}, + {143, 1}, + {144, 2}, }; static arc arcs_62_1[1] = { - {140, 2}, + {139, 2}, }; static arc arcs_62_2[1] = { {0, 2}, @@ -1345,15 +1343,15 @@ {1, arcs_62_2}, }; static arc arcs_63_0[1] = { - {146, 1}, + {145, 1}, }; static arc arcs_63_1[3] = { - {147, 1}, + {146, 1}, {32, 2}, {0, 1}, }; static arc arcs_63_2[1] = { - {140, 3}, + {139, 3}, }; static arc arcs_63_3[1] = { {0, 3}, @@ -1366,44 +1364,44 @@ }; static arc arcs_64_0[10] = { {13, 1}, - {149, 2}, - {151, 3}, + {148, 2}, + {150, 3}, {21, 4}, - {154, 4}, - {155, 5}, - {80, 4}, + {153, 4}, + {154, 5}, + {79, 4}, + {155, 4}, {156, 4}, {157, 4}, - {158, 4}, }; static arc arcs_64_1[3] = { {47, 6}, - {148, 6}, + {147, 6}, {15, 4}, }; static arc arcs_64_2[2] = { - {148, 7}, - {150, 4}, + {147, 7}, + {149, 4}, }; static arc arcs_64_3[2] = { - {152, 8}, - {153, 4}, + {151, 8}, + {152, 4}, }; static arc arcs_64_4[1] = { {0, 4}, }; static arc arcs_64_5[2] = { - {155, 5}, + {154, 5}, {0, 5}, }; static arc arcs_64_6[1] = { {15, 4}, }; static arc arcs_64_7[1] = { - {150, 4}, + {149, 4}, }; static arc arcs_64_8[1] = { - {153, 4}, + {152, 4}, }; static state states_64[9] = { {10, arcs_64_0}, @@ -1421,7 +1419,7 @@ {48, 1}, }; static arc arcs_65_1[3] = { - {159, 2}, + {158, 2}, {30, 3}, {0, 1}, }; @@ -1446,15 +1444,15 @@ }; static arc arcs_66_0[3] = { {13, 1}, - {149, 2}, - {79, 3}, + {148, 2}, + {78, 3}, }; static arc arcs_66_1[2] = { {14, 4}, {15, 5}, }; static arc arcs_66_2[1] = { - {160, 6}, + {159, 6}, }; static arc arcs_66_3[1] = { {21, 5}, @@ -1466,7 +1464,7 @@ {0, 5}, }; static arc arcs_66_6[1] = { - {150, 5}, + {149, 5}, }; static state states_66[7] = { {3, arcs_66_0}, @@ -1478,14 +1476,14 @@ {1, arcs_66_6}, }; static arc arcs_67_0[1] = { - {161, 1}, + {160, 1}, }; static arc arcs_67_1[2] = { {30, 2}, {0, 1}, }; static arc arcs_67_2[2] = { - {161, 1}, + {160, 1}, {0, 2}, }; static state states_67[3] = { @@ -1503,11 +1501,11 @@ }; static arc arcs_68_2[3] = { {24, 3}, - {162, 4}, + {161, 4}, {0, 2}, }; static arc arcs_68_3[2] = { - {162, 4}, + {161, 4}, {0, 3}, }; static arc arcs_68_4[1] = { @@ -1536,7 +1534,7 @@ {1, arcs_69_2}, }; static arc arcs_70_0[2] = { - {104, 1}, + {103, 1}, {48, 1}, }; static arc arcs_70_1[2] = { @@ -1544,7 +1542,7 @@ {0, 1}, }; static arc arcs_70_2[3] = { - {104, 1}, + {103, 1}, {48, 1}, {0, 2}, }; @@ -1574,7 +1572,7 @@ }; static arc arcs_72_1[4] = { {25, 2}, - {159, 3}, + {158, 3}, {30, 4}, {0, 1}, }; @@ -1589,7 +1587,7 @@ {0, 4}, }; static arc arcs_72_5[3] = { - {159, 3}, + {158, 3}, {30, 7}, {0, 5}, }; @@ -1625,7 +1623,7 @@ {2, arcs_72_10}, }; static arc arcs_73_0[1] = { - {163, 1}, + {162, 1}, }; static arc arcs_73_1[1] = { {21, 2}, @@ -1661,7 +1659,7 @@ {1, arcs_73_7}, }; static arc arcs_74_0[3] = { - {164, 1}, + {163, 1}, {31, 2}, {32, 3}, }; @@ -1676,7 +1674,7 @@ {24, 6}, }; static arc arcs_74_4[4] = { - {164, 1}, + {163, 1}, {31, 2}, {32, 3}, {0, 4}, @@ -1689,7 +1687,7 @@ {0, 6}, }; static arc arcs_74_7[2] = { - {164, 5}, + {163, 5}, {32, 3}, }; static state states_74[8] = { @@ -1706,7 +1704,7 @@ {24, 1}, }; static arc arcs_75_1[3] = { - {159, 2}, + {158, 2}, {29, 3}, {0, 1}, }; @@ -1723,8 +1721,8 @@ {1, arcs_75_3}, }; static arc arcs_76_0[2] = { - {159, 1}, - {166, 1}, + {158, 1}, + {165, 1}, }; static arc arcs_76_1[1] = { {0, 1}, @@ -1734,19 +1732,19 @@ {1, arcs_76_1}, }; static arc arcs_77_0[1] = { - {97, 1}, + {96, 1}, }; static arc arcs_77_1[1] = { - {63, 2}, + {62, 2}, }; static arc arcs_77_2[1] = { - {98, 3}, + {97, 3}, }; static arc arcs_77_3[1] = { - {108, 4}, + {107, 4}, }; static arc arcs_77_4[2] = { - {165, 5}, + {164, 5}, {0, 4}, }; static arc arcs_77_5[1] = { @@ -1761,13 +1759,13 @@ {1, arcs_77_5}, }; static arc arcs_78_0[1] = { - {93, 1}, + {92, 1}, }; static arc arcs_78_1[1] = { - {110, 2}, + {109, 2}, }; static arc arcs_78_2[2] = { - {165, 3}, + {164, 3}, {0, 2}, }; static arc arcs_78_3[1] = { @@ -1790,10 +1788,10 @@ {1, arcs_79_1}, }; static arc arcs_80_0[1] = { - {168, 1}, + {167, 1}, }; static arc arcs_80_1[2] = { - {169, 2}, + {168, 2}, {0, 1}, }; static arc arcs_80_2[1] = { @@ -1805,7 +1803,7 @@ {1, arcs_80_2}, }; static arc arcs_81_0[2] = { - {74, 1}, + {73, 1}, {9, 2}, }; static arc arcs_81_1[1] = { @@ -1821,11 +1819,11 @@ }; static dfa dfas[82] = { {256, "single_input", 0, 3, states_0, - "\004\050\060\200\000\000\000\100\301\047\341\040\113\000\041\000\000\014\241\174\010\001"}, + "\004\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204\000"}, {257, "file_input", 0, 2, states_1, - "\204\050\060\200\000\000\000\100\301\047\341\040\113\000\041\000\000\014\241\174\010\001"}, + "\204\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204\000"}, {258, "eval_input", 0, 3, states_2, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, @@ -1845,39 +1843,39 @@ {267, "vfpdef", 0, 2, states_11, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {268, "stmt", 0, 2, states_12, - "\000\050\060\200\000\000\000\100\301\047\341\040\113\000\041\000\000\014\241\174\010\001"}, + "\000\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204\000"}, {269, "simple_stmt", 0, 4, states_13, - "\000\040\040\200\000\000\000\100\301\047\341\000\000\000\041\000\000\014\241\174\000\001"}, + "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200\000"}, {270, "small_stmt", 0, 2, states_14, - "\000\040\040\200\000\000\000\100\301\047\341\000\000\000\041\000\000\014\241\174\000\001"}, + "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200\000"}, {271, "expr_stmt", 0, 6, states_15, - "\000\040\040\200\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {272, "testlist_star_expr", 0, 3, states_16, - "\000\040\040\200\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {273, "augassign", 0, 2, states_17, - "\000\000\000\000\000\000\376\077\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\376\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "del_stmt", 0, 3, states_18, - "\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {275, "pass_stmt", 0, 2, states_19, - "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "flow_stmt", 0, 2, states_20, - "\000\000\000\000\000\000\000\000\300\003\000\000\000\000\000\000\000\000\000\000\000\001"}, + "\000\000\000\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000\000\000\200\000"}, {277, "break_stmt", 0, 2, states_21, + "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {278, "continue_stmt", 0, 2, states_22, "\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {278, "continue_stmt", 0, 2, states_22, + {279, "return_stmt", 0, 3, states_23, "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {279, "return_stmt", 0, 3, states_23, + {280, "yield_stmt", 0, 2, states_24, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"}, + {281, "raise_stmt", 0, 5, states_25, "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000"}, - {280, "yield_stmt", 0, 2, states_24, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, - {281, "raise_stmt", 0, 5, states_25, + {282, "import_stmt", 0, 2, states_26, + "\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000\000"}, + {283, "import_name", 0, 3, states_27, + "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, + {284, "import_from", 0, 8, states_28, "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"}, - {282, "import_stmt", 0, 2, states_26, - "\000\000\000\000\000\000\000\000\000\044\000\000\000\000\000\000\000\000\000\000\000\000"}, - {283, "import_name", 0, 3, states_27, - "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, - {284, "import_from", 0, 8, states_28, - "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, {285, "import_as_name", 0, 4, states_29, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {286, "dotted_as_name", 0, 4, states_30, @@ -1889,103 +1887,103 @@ {289, "dotted_name", 0, 2, states_33, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {290, "global_stmt", 0, 3, states_34, + "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"}, + {291, "nonlocal_stmt", 0, 3, states_35, "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"}, - {291, "nonlocal_stmt", 0, 3, states_35, + {292, "assert_stmt", 0, 5, states_36, "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"}, - {292, "assert_stmt", 0, 5, states_36, - "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"}, {293, "compound_stmt", 0, 2, states_37, - "\000\010\020\000\000\000\000\000\000\000\000\040\113\000\000\000\000\000\000\000\010\000"}, + "\000\010\020\000\000\000\000\000\000\000\000\220\045\000\000\000\000\000\000\000\004\000"}, {294, "if_stmt", 0, 8, states_38, - "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {295, "while_stmt", 0, 8, states_39, + "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, + {296, "for_stmt", 0, 10, states_40, "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"}, - {296, "for_stmt", 0, 10, states_40, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, {297, "try_stmt", 0, 13, states_41, - "\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {298, "with_stmt", 0, 5, states_42, - "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, {299, "with_item", 0, 4, states_43, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {300, "except_clause", 0, 5, states_44, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"}, {301, "suite", 0, 5, states_45, - "\004\040\040\200\000\000\000\100\301\047\341\000\000\000\041\000\000\014\241\174\000\001"}, + "\004\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200\000"}, {302, "test", 0, 6, states_46, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {303, "test_nocond", 0, 2, states_47, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {304, "lambdef", 0, 5, states_48, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000"}, {305, "lambdef_nocond", 0, 5, states_49, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000"}, {306, "or_test", 0, 2, states_50, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\040\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000\000"}, {307, "and_test", 0, 2, states_51, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\040\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000\000"}, {308, "not_test", 0, 3, states_52, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\040\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000\000"}, {309, "comparison", 0, 2, states_53, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {310, "comp_op", 0, 4, states_54, - "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\040\377\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\220\177\000\000\000\000\000\000"}, {311, "star_expr", 0, 3, states_55, "\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {312, "expr", 0, 2, states_56, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {313, "xor_expr", 0, 2, states_57, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {314, "and_expr", 0, 2, states_58, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {315, "shift_expr", 0, 2, states_59, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {316, "arith_expr", 0, 2, states_60, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {317, "term", 0, 2, states_61, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {318, "factor", 0, 3, states_62, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {319, "power", 0, 4, states_63, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\240\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000\000"}, {320, "atom", 0, 9, states_64, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\240\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000\000"}, {321, "testlist_comp", 0, 5, states_65, - "\000\040\040\200\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {322, "trailer", 0, 7, states_66, - "\000\040\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\040\000\000\000"}, + "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\020\000\000\000"}, {323, "subscriptlist", 0, 3, states_67, - "\000\040\040\002\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {324, "subscript", 0, 5, states_68, - "\000\040\040\002\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {325, "sliceop", 0, 3, states_69, "\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {326, "exprlist", 0, 3, states_70, - "\000\040\040\200\000\000\000\000\000\000\001\000\000\000\000\000\000\014\241\174\000\000"}, + "\000\040\040\200\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000\000"}, {327, "testlist", 0, 3, states_71, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {328, "dictorsetmaker", 0, 11, states_72, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {329, "classdef", 0, 8, states_73, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000"}, {330, "arglist", 0, 8, states_74, - "\000\040\040\200\001\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\200\001\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {331, "argument", 0, 4, states_75, - "\000\040\040\000\000\000\000\000\000\000\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000\000"}, {332, "comp_iter", 0, 2, states_76, - "\000\000\000\000\000\000\000\000\000\000\000\040\002\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\000"}, {333, "comp_for", 0, 6, states_77, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"}, {334, "comp_if", 0, 4, states_78, - "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {335, "encoding_decl", 0, 2, states_79, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {336, "yield_expr", 0, 3, states_80, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"}, {337, "yield_arg", 0, 3, states_81, - "\000\040\040\000\000\000\000\000\000\004\001\000\000\000\041\000\000\014\241\174\000\000"}, + "\000\040\040\000\000\000\000\000\000\202\000\000\000\200\020\000\000\206\120\076\000\000"}, }; -static label labels[170] = { +static label labels[169] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2009,7 +2007,7 @@ {1, "def"}, {1, 0}, {263, 0}, - {51, 0}, + {50, 0}, {302, 0}, {11, 0}, {301, 0}, @@ -2038,7 +2036,6 @@ {36, 0}, {37, 0}, {38, 0}, - {50, 0}, {39, 0}, {40, 0}, {41, 0}, @@ -2066,7 +2063,7 @@ {1, "import"}, {288, 0}, {23, 0}, - {52, 0}, + {51, 0}, {287, 0}, {285, 0}, {1, "as"}, @@ -2160,6 +2157,6 @@ grammar _PyParser_Grammar = { 82, dfas, - {170, labels}, + {169, labels}, 256 }; diff -r ce070040e1a6 -r d7f128afe9db Python/import.c --- a/Python/import.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/import.c Sun Mar 23 09:44:28 2014 +0100 @@ -837,10 +837,12 @@ return m; } -static PyObject * -module_dict_for_exec(PyObject *name) +PyObject* +PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, + PyObject *cpathname) { - PyObject *m, *d = NULL; + PyObject *modules = PyImport_GetModuleDict(); + PyObject *m, *d, *v; m = PyImport_AddModuleObject(name); if (m == NULL) @@ -850,51 +852,9 @@ d = PyModule_GetDict(m); if (PyDict_GetItemString(d, "__builtins__") == NULL) { if (PyDict_SetItemString(d, "__builtins__", - PyEval_GetBuiltins()) != 0) { - remove_module(name); - return NULL; - } + PyEval_GetBuiltins()) != 0) + goto error; } - - return d; -} - -static PyObject * -exec_code_in_module(PyObject *name, PyObject *module_dict, PyObject *code_object) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *v, *m; - - v = PyEval_EvalCode(code_object, module_dict, module_dict); - if (v == NULL) { - remove_module(name); - return NULL; - } - Py_DECREF(v); - - if ((m = PyDict_GetItem(modules, name)) == NULL) { - PyErr_Format(PyExc_ImportError, - "Loaded module %R not found in sys.modules", - name); - return NULL; - } - - Py_INCREF(m); - - return m; -} - -PyObject* -PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, - PyObject *cpathname) -{ - PyObject *d, *v; - - d = module_dict_for_exec(name); - if (d == NULL) { - return NULL; - } - if (pathname != NULL) { v = pathname; } @@ -914,7 +874,25 @@ if (PyDict_SetItemString(d, "__cached__", v) != 0) PyErr_Clear(); /* Not important enough to report */ - return exec_code_in_module(name, d, co); + v = PyEval_EvalCode(co, d, d); + if (v == NULL) + goto error; + Py_DECREF(v); + + if ((m = PyDict_GetItem(modules, name)) == NULL) { + PyErr_Format(PyExc_ImportError, + "Loaded module %R not found in sys.modules", + name); + return NULL; + } + + Py_INCREF(m); + + return m; + + error: + remove_module(name); + return NULL; } @@ -1228,7 +1206,7 @@ PyImport_ImportFrozenModuleObject(PyObject *name) { const struct _frozen *p; - PyObject *co, *m, *d; + PyObject *co, *m, *path; int ispackage; int size; @@ -1257,7 +1235,7 @@ } if (ispackage) { /* Set __path__ to the empty list */ - PyObject *l; + PyObject *d, *l; int err; m = PyImport_AddModuleObject(name); if (m == NULL) @@ -1272,11 +1250,11 @@ if (err != 0) goto err_return; } - d = module_dict_for_exec(name); - if (d == NULL) { + path = PyUnicode_FromString(""); + if (path == NULL) goto err_return; - } - m = exec_code_in_module(name, d, co); + m = PyImport_ExecCodeModuleObject(name, co, path, NULL); + Py_DECREF(path); if (m == NULL) goto err_return; Py_DECREF(co); diff -r ce070040e1a6 -r d7f128afe9db Python/importlib.h --- a/Python/importlib.h Sat May 10 13:24:58 2014 -0400 +++ b/Python/importlib.h Sun Mar 23 09:44:28 2014 +0100 @@ -702,7 +702,7 @@ 5,0,0,0,218,25,95,99,97,108,108,95,119,105,116,104, 95,102,114,97,109,101,115,95,114,101,109,111,118,101,100,57, 1,0,0,115,2,0,0,0,0,8,114,114,0,0,0,105, - 248,12,0,0,233,2,0,0,0,114,13,0,0,0,115,2, + 238,12,0,0,233,2,0,0,0,114,13,0,0,0,115,2, 0,0,0,13,10,90,11,95,95,112,121,99,97,99,104,101, 95,95,122,3,46,112,121,122,4,46,112,121,99,122,4,46, 112,121,111,78,99,2,0,0,0,0,0,0,0,11,0,0, @@ -771,7 +771,7 @@ 3,116,97,103,218,8,102,105,108,101,110,97,109,101,114,4, 0,0,0,114,4,0,0,0,114,5,0,0,0,218,17,99, 97,99,104,101,95,102,114,111,109,95,115,111,117,114,99,101, - 182,1,0,0,115,22,0,0,0,0,13,31,1,6,1,9, + 181,1,0,0,115,22,0,0,0,0,13,31,1,6,1,9, 2,6,1,18,1,24,1,12,1,12,1,15,1,31,1,114, 132,0,0,0,99,1,0,0,0,0,0,0,0,5,0,0, 0,5,0,0,0,67,0,0,0,115,193,0,0,0,116,0, @@ -828,7 +828,7 @@ 95,102,105,108,101,110,97,109,101,90,7,112,121,99,97,99, 104,101,114,129,0,0,0,114,4,0,0,0,114,4,0,0, 0,114,5,0,0,0,218,17,115,111,117,114,99,101,95,102, - 114,111,109,95,99,97,99,104,101,209,1,0,0,115,24,0, + 114,111,109,95,99,97,99,104,101,208,1,0,0,115,24,0, 0,0,0,9,18,1,15,1,18,1,18,1,12,1,3,1, 24,1,21,1,3,1,21,1,19,1,114,135,0,0,0,99, 1,0,0,0,0,0,0,0,5,0,0,0,13,0,0,0, @@ -865,7 +865,7 @@ 105,111,110,218,11,115,111,117,114,99,101,95,112,97,116,104, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218, 15,95,103,101,116,95,115,111,117,114,99,101,102,105,108,101, - 232,1,0,0,115,20,0,0,0,0,7,18,1,4,1,24, + 231,1,0,0,115,20,0,0,0,0,7,18,1,4,1,24, 1,35,1,4,1,3,1,16,1,19,1,21,1,114,142,0, 0,0,99,1,0,0,0,0,0,0,0,2,0,0,0,11, 0,0,0,67,0,0,0,115,60,0,0,0,121,19,0,116, @@ -880,7 +880,7 @@ 114,41,0,0,0,114,40,0,0,0,41,2,114,35,0,0, 0,114,42,0,0,0,114,4,0,0,0,114,4,0,0,0, 114,5,0,0,0,218,10,95,99,97,108,99,95,109,111,100, - 101,251,1,0,0,115,12,0,0,0,0,2,3,1,19,1, + 101,250,1,0,0,115,12,0,0,0,0,2,3,1,19,1, 13,1,11,3,10,1,114,144,0,0,0,218,9,118,101,114, 98,111,115,105,116,121,114,29,0,0,0,99,1,0,0,0, 1,0,0,0,3,0,0,0,4,0,0,0,71,0,0,0, @@ -901,7 +901,7 @@ 6,115,116,100,101,114,114,41,3,218,7,109,101,115,115,97, 103,101,114,145,0,0,0,114,80,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,16,95,118,101, - 114,98,111,115,101,95,109,101,115,115,97,103,101,7,2,0, + 114,98,111,115,101,95,109,101,115,115,97,103,101,6,2,0, 0,115,8,0,0,0,0,2,18,1,15,1,13,1,114,152, 0,0,0,99,1,0,0,0,0,0,0,0,2,0,0,0, 4,0,0,0,3,0,0,0,115,38,0,0,0,100,1,0, @@ -937,14 +937,14 @@ 0,0,114,80,0,0,0,114,108,0,0,0,41,1,218,6, 109,101,116,104,111,100,114,4,0,0,0,114,5,0,0,0, 218,19,95,99,104,101,99,107,95,110,97,109,101,95,119,114, - 97,112,112,101,114,23,2,0,0,115,10,0,0,0,0,1, + 97,112,112,101,114,22,2,0,0,115,10,0,0,0,0,1, 12,1,12,1,15,1,25,1,122,40,95,99,104,101,99,107, 95,110,97,109,101,46,60,108,111,99,97,108,115,62,46,95, 99,104,101,99,107,95,110,97,109,101,95,119,114,97,112,112, 101,114,41,1,114,65,0,0,0,41,2,114,154,0,0,0, 114,155,0,0,0,114,4,0,0,0,41,1,114,154,0,0, 0,114,5,0,0,0,218,11,95,99,104,101,99,107,95,110, - 97,109,101,15,2,0,0,115,6,0,0,0,0,8,21,6, + 97,109,101,14,2,0,0,115,6,0,0,0,0,8,21,6, 13,1,114,156,0,0,0,99,1,0,0,0,0,0,0,0, 2,0,0,0,3,0,0,0,3,0,0,0,115,35,0,0, 0,135,0,0,102,1,0,100,1,0,100,2,0,134,0,0, @@ -966,7 +966,7 @@ 0,0,218,8,102,117,108,108,110,97,109,101,41,1,218,3, 102,120,110,114,4,0,0,0,114,5,0,0,0,218,25,95, 114,101,113,117,105,114,101,115,95,98,117,105,108,116,105,110, - 95,119,114,97,112,112,101,114,35,2,0,0,115,8,0,0, + 95,119,114,97,112,112,101,114,34,2,0,0,115,8,0,0, 0,0,1,15,1,18,1,12,1,122,52,95,114,101,113,117, 105,114,101,115,95,98,117,105,108,116,105,110,46,60,108,111, 99,97,108,115,62,46,95,114,101,113,117,105,114,101,115,95, @@ -974,7 +974,7 @@ 1,114,65,0,0,0,41,2,114,159,0,0,0,114,160,0, 0,0,114,4,0,0,0,41,1,114,159,0,0,0,114,5, 0,0,0,218,17,95,114,101,113,117,105,114,101,115,95,98, - 117,105,108,116,105,110,33,2,0,0,115,6,0,0,0,0, + 117,105,108,116,105,110,32,2,0,0,115,6,0,0,0,0, 2,18,5,13,1,114,161,0,0,0,99,1,0,0,0,0, 0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,115, 35,0,0,0,135,0,0,102,1,0,100,1,0,100,2,0, @@ -995,7 +995,7 @@ 2,114,71,0,0,0,114,158,0,0,0,41,1,114,159,0, 0,0,114,4,0,0,0,114,5,0,0,0,218,24,95,114, 101,113,117,105,114,101,115,95,102,114,111,122,101,110,95,119, - 114,97,112,112,101,114,46,2,0,0,115,8,0,0,0,0, + 114,97,112,112,101,114,45,2,0,0,115,8,0,0,0,0, 1,15,1,18,1,12,1,122,50,95,114,101,113,117,105,114, 101,115,95,102,114,111,122,101,110,46,60,108,111,99,97,108, 115,62,46,95,114,101,113,117,105,114,101,115,95,102,114,111, @@ -1003,7 +1003,7 @@ 0,0,41,2,114,159,0,0,0,114,163,0,0,0,114,4, 0,0,0,41,1,114,159,0,0,0,114,5,0,0,0,218, 16,95,114,101,113,117,105,114,101,115,95,102,114,111,122,101, - 110,44,2,0,0,115,6,0,0,0,0,2,18,5,13,1, + 110,43,2,0,0,115,6,0,0,0,0,2,18,5,13,1, 114,164,0,0,0,99,2,0,0,0,0,0,0,0,5,0, 0,0,5,0,0,0,67,0,0,0,115,87,0,0,0,124, 0,0,106,0,0,124,1,0,131,1,0,92,2,0,125,2, @@ -1032,7 +1032,7 @@ 108,111,97,100,101,114,218,8,112,111,114,116,105,111,110,115, 218,3,109,115,103,114,4,0,0,0,114,4,0,0,0,114, 5,0,0,0,218,17,95,102,105,110,100,95,109,111,100,117, - 108,101,95,115,104,105,109,55,2,0,0,115,10,0,0,0, + 108,101,95,115,104,105,109,54,2,0,0,115,10,0,0,0, 0,10,21,1,24,1,6,1,32,1,114,172,0,0,0,99, 2,0,0,0,0,0,0,0,5,0,0,0,3,0,0,0, 67,0,0,0,115,93,0,0,0,116,0,0,124,1,0,124, @@ -1057,7 +1057,7 @@ 4,115,112,101,99,218,7,109,101,116,104,111,100,115,218,6, 109,111,100,117,108,101,114,4,0,0,0,114,4,0,0,0, 114,5,0,0,0,218,17,95,108,111,97,100,95,109,111,100, - 117,108,101,95,115,104,105,109,72,2,0,0,115,14,0,0, + 117,108,101,95,115,104,105,109,71,2,0,0,115,14,0,0, 0,0,6,15,1,12,1,15,1,13,1,13,1,11,2,114, 180,0,0,0,99,4,0,0,0,0,0,0,0,11,0,0, 0,19,0,0,0,67,0,0,0,115,243,1,0,0,105,0, @@ -1142,7 +1142,7 @@ 101,95,109,116,105,109,101,218,11,115,111,117,114,99,101,95, 115,105,122,101,114,4,0,0,0,114,4,0,0,0,114,5, 0,0,0,218,25,95,118,97,108,105,100,97,116,101,95,98, - 121,116,101,99,111,100,101,95,104,101,97,100,101,114,88,2, + 121,116,101,99,111,100,101,95,104,101,97,100,101,114,87,2, 0,0,115,76,0,0,0,0,11,6,1,12,1,13,3,6, 1,12,1,13,1,16,1,16,1,16,1,12,1,18,1,10, 1,18,1,18,1,15,1,10,1,15,1,18,1,15,1,10, @@ -1173,7 +1173,7 @@ 41,5,114,53,0,0,0,114,67,0,0,0,114,140,0,0, 0,114,141,0,0,0,218,4,99,111,100,101,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,17,95,99,111, - 109,112,105,108,101,95,98,121,116,101,99,111,100,101,143,2, + 109,112,105,108,101,95,98,121,116,101,99,111,100,101,142,2, 0,0,115,16,0,0,0,0,2,15,1,15,1,13,1,12, 1,19,1,4,2,18,1,114,195,0,0,0,114,84,0,0, 0,99,3,0,0,0,0,0,0,0,4,0,0,0,3,0, @@ -1193,7 +1193,7 @@ 5,100,117,109,112,115,41,4,114,194,0,0,0,114,183,0, 0,0,114,189,0,0,0,114,53,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,17,95,99,111, - 100,101,95,116,111,95,98,121,116,101,99,111,100,101,155,2, + 100,101,95,116,111,95,98,121,116,101,99,111,100,101,154,2, 0,0,115,10,0,0,0,0,3,12,1,19,1,19,1,22, 1,114,198,0,0,0,99,1,0,0,0,0,0,0,0,5, 0,0,0,4,0,0,0,67,0,0,0,115,89,0,0,0, @@ -1222,7 +1222,7 @@ 101,218,8,101,110,99,111,100,105,110,103,90,15,110,101,119, 108,105,110,101,95,100,101,99,111,100,101,114,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,13,100,101,99, - 111,100,101,95,115,111,117,114,99,101,165,2,0,0,115,10, + 111,100,101,95,115,111,117,114,99,101,164,2,0,0,115,10, 0,0,0,0,5,12,1,18,1,15,1,18,1,114,203,0, 0,0,99,1,0,0,0,0,0,0,0,5,0,0,0,35, 0,0,0,67,0,0,0,115,15,1,0,0,116,0,0,124, @@ -1256,7 +1256,7 @@ 95,95,114,47,0,0,0,41,5,114,179,0,0,0,114,169, 0,0,0,114,177,0,0,0,114,67,0,0,0,114,131,0, 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,12,95,109,111,100,117,108,101,95,114,101,112,114,179, + 0,218,12,95,109,111,100,117,108,101,95,114,101,112,114,178, 2,0,0,115,46,0,0,0,0,2,18,1,15,4,3,1, 17,1,13,1,8,1,3,1,13,1,13,1,5,2,12,1, 16,4,3,1,13,1,13,1,11,1,3,1,13,1,13,1, @@ -1273,7 +1273,7 @@ 83,41,1,78,41,3,218,7,95,109,111,100,117,108,101,114, 208,0,0,0,218,5,95,115,112,101,99,41,2,114,71,0, 0,0,114,179,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,72,0,0,0,217,2,0,0,115, + 0,114,5,0,0,0,114,72,0,0,0,216,2,0,0,115, 4,0,0,0,0,1,9,1,122,26,95,105,110,115,116,97, 108,108,101,100,95,115,97,102,101,108,121,46,95,95,105,110, 105,116,95,95,99,1,0,0,0,0,0,0,0,1,0,0, @@ -1284,7 +1284,7 @@ 13,95,105,110,105,116,105,97,108,105,122,105,110,103,114,213, 0,0,0,114,7,0,0,0,114,73,0,0,0,114,67,0, 0,0,41,1,114,71,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,75,0,0,0,221,2,0, + 0,0,0,114,5,0,0,0,114,75,0,0,0,220,2,0, 0,115,4,0,0,0,0,4,12,1,122,27,95,105,110,115, 116,97,108,108,101,100,95,115,97,102,101,108,121,46,95,95, 101,110,116,101,114,95,95,99,1,0,0,0,0,0,0,0, @@ -1302,7 +1302,7 @@ 124,1,0,100,0,0,107,9,0,86,1,113,3,0,100,0, 0,83,41,1,78,114,4,0,0,0,41,2,114,22,0,0, 0,114,76,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,77,0,0,0,231,2,0,0,115,2, + 114,5,0,0,0,114,77,0,0,0,230,2,0,0,115,2, 0,0,0,6,0,122,45,95,105,110,115,116,97,108,108,101, 100,95,115,97,102,101,108,121,46,95,95,101,120,105,116,95, 95,46,60,108,111,99,97,108,115,62,46,60,103,101,110,101, @@ -1312,14 +1312,14 @@ 67,0,0,0,114,79,0,0,0,114,152,0,0,0,114,169, 0,0,0,114,215,0,0,0,41,3,114,71,0,0,0,114, 80,0,0,0,114,177,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,81,0,0,0,228,2,0, + 0,0,0,114,5,0,0,0,114,81,0,0,0,227,2,0, 0,115,18,0,0,0,0,1,3,1,9,1,25,1,3,1, 17,1,13,1,8,2,26,2,122,26,95,105,110,115,116,97, 108,108,101,100,95,115,97,102,101,108,121,46,95,95,101,120, 105,116,95,95,78,41,6,114,57,0,0,0,114,56,0,0, 0,114,58,0,0,0,114,72,0,0,0,114,75,0,0,0, 114,81,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,212,0,0,0,215,2, + 4,0,0,0,114,5,0,0,0,114,212,0,0,0,214,2, 0,0,115,6,0,0,0,12,2,12,4,12,7,114,212,0, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,8, 0,0,0,64,0,0,0,115,172,0,0,0,101,0,0,90, @@ -1444,7 +1444,7 @@ 97,99,104,101,100,41,6,114,71,0,0,0,114,67,0,0, 0,114,169,0,0,0,114,217,0,0,0,114,218,0,0,0, 114,219,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,72,0,0,0,23,3,0,0,115,14,0, + 5,0,0,0,114,72,0,0,0,22,3,0,0,115,14,0, 0,0,0,2,9,1,9,1,9,1,9,1,21,3,9,1, 122,19,77,111,100,117,108,101,83,112,101,99,46,95,95,105, 110,105,116,95,95,99,1,0,0,0,0,0,0,0,2,0, @@ -1469,7 +1469,7 @@ 95,95,99,108,97,115,115,95,95,114,57,0,0,0,114,26, 0,0,0,41,2,114,71,0,0,0,114,80,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,101, - 0,0,0,35,3,0,0,115,16,0,0,0,0,1,15,1, + 0,0,0,34,3,0,0,115,16,0,0,0,0,1,15,1, 21,1,15,1,28,1,15,1,6,1,22,1,122,19,77,111, 100,117,108,101,83,112,101,99,46,95,95,114,101,112,114,95, 95,99,2,0,0,0,0,0,0,0,3,0,0,0,13,0, @@ -1488,7 +1488,7 @@ 104,97,115,95,108,111,99,97,116,105,111,110,114,209,0,0, 0,41,3,114,71,0,0,0,218,5,111,116,104,101,114,218, 4,115,109,115,108,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,218,6,95,95,101,113,95,95,45,3,0,0, + 5,0,0,0,218,6,95,95,101,113,95,95,44,3,0,0, 115,20,0,0,0,0,1,9,1,3,1,18,1,18,1,18, 1,15,1,18,1,20,1,13,1,122,17,77,111,100,117,108, 101,83,112,101,99,46,95,95,101,113,95,95,99,1,0,0, @@ -1509,7 +1509,7 @@ 0,0,0,114,124,0,0,0,218,17,66,89,84,69,67,79, 68,69,95,83,85,70,70,73,88,69,83,41,2,114,71,0, 0,0,114,131,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,225,0,0,0,57,3,0,0,115, + 0,114,5,0,0,0,114,225,0,0,0,56,3,0,0,115, 22,0,0,0,0,2,15,1,24,1,9,1,21,1,3,1, 19,1,13,1,8,1,21,1,18,1,122,17,77,111,100,117, 108,101,83,112,101,99,46,99,97,99,104,101,100,99,2,0, @@ -1517,7 +1517,7 @@ 0,0,115,13,0,0,0,124,1,0,124,0,0,95,0,0, 100,0,0,83,41,1,78,41,1,114,222,0,0,0,41,2, 114,71,0,0,0,114,225,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,225,0,0,0,71,3, + 4,0,0,0,114,5,0,0,0,114,225,0,0,0,70,3, 0,0,115,2,0,0,0,0,2,99,1,0,0,0,0,0, 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,46, 0,0,0,124,0,0,106,0,0,100,1,0,107,8,0,114, @@ -1528,14 +1528,14 @@ 114,101,110,116,46,78,114,116,0,0,0,114,84,0,0,0, 41,3,114,220,0,0,0,114,67,0,0,0,114,32,0,0, 0,41,1,114,71,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,218,6,112,97,114,101,110,116,75, + 0,0,114,5,0,0,0,218,6,112,97,114,101,110,116,74, 3,0,0,115,6,0,0,0,0,3,15,1,20,2,122,17, 77,111,100,117,108,101,83,112,101,99,46,112,97,114,101,110, 116,99,1,0,0,0,0,0,0,0,1,0,0,0,1,0, 0,0,67,0,0,0,115,7,0,0,0,124,0,0,106,0, 0,83,41,1,78,41,1,114,221,0,0,0,41,1,114,71, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,226,0,0,0,83,3,0,0,115,2,0,0,0, + 0,0,114,226,0,0,0,82,3,0,0,115,2,0,0,0, 0,2,122,23,77,111,100,117,108,101,83,112,101,99,46,104, 97,115,95,108,111,99,97,116,105,111,110,99,2,0,0,0, 0,0,0,0,2,0,0,0,2,0,0,0,67,0,0,0, @@ -1543,14 +1543,14 @@ 0,95,1,0,100,0,0,83,41,1,78,41,2,218,4,98, 111,111,108,114,221,0,0,0,41,2,114,71,0,0,0,218, 5,118,97,108,117,101,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,226,0,0,0,87,3,0,0,115,2, + 114,5,0,0,0,114,226,0,0,0,86,3,0,0,115,2, 0,0,0,0,2,41,12,114,57,0,0,0,114,56,0,0, 0,114,58,0,0,0,114,59,0,0,0,114,72,0,0,0, 114,101,0,0,0,114,229,0,0,0,218,8,112,114,111,112, 101,114,116,121,114,225,0,0,0,218,6,115,101,116,116,101, 114,114,233,0,0,0,114,226,0,0,0,114,4,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 216,0,0,0,242,2,0,0,115,20,0,0,0,12,35,6, + 216,0,0,0,241,2,0,0,115,20,0,0,0,12,35,6, 2,15,1,15,11,12,10,12,12,18,14,21,4,18,8,18, 4,114,216,0,0,0,114,217,0,0,0,114,219,0,0,0, 99,2,0,0,0,2,0,0,0,5,0,0,0,15,0,0, @@ -1578,7 +1578,7 @@ 0,0,114,216,0,0,0,41,5,114,67,0,0,0,114,169, 0,0,0,114,217,0,0,0,114,219,0,0,0,90,6,115, 101,97,114,99,104,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,173,0,0,0,92,3,0,0,115,28,0, + 5,0,0,0,114,173,0,0,0,91,3,0,0,115,28,0, 0,0,0,2,15,1,12,1,16,1,18,1,15,1,7,2, 12,1,15,1,3,1,19,1,13,1,14,3,9,2,114,173, 0,0,0,114,169,0,0,0,114,220,0,0,0,99,2,0, @@ -1640,7 +1640,7 @@ 218,12,108,111,97,100,101,114,95,99,108,97,115,115,114,127, 0,0,0,114,219,0,0,0,90,7,100,105,114,110,97,109, 101,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,239,0,0,0,117,3,0,0,115,60,0,0,0,0,12, + 114,239,0,0,0,116,3,0,0,115,60,0,0,0,0,12, 12,4,6,1,15,2,3,1,19,1,13,1,11,8,21,1, 9,3,12,1,22,1,21,1,15,1,9,1,8,2,7,3, 12,2,15,1,3,1,19,1,13,1,5,2,6,1,18,2, @@ -1680,7 +1680,7 @@ 217,0,0,0,114,177,0,0,0,114,67,0,0,0,114,242, 0,0,0,114,225,0,0,0,114,220,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,218,17,95,115, - 112,101,99,95,102,114,111,109,95,109,111,100,117,108,101,181, + 112,101,99,95,102,114,111,109,95,109,111,100,117,108,101,180, 3,0,0,115,72,0,0,0,0,2,3,1,13,1,13,1, 5,2,12,1,4,2,9,1,12,1,3,1,13,1,13,2, 8,1,3,1,13,1,13,1,11,1,12,1,12,1,3,1, @@ -1707,7 +1707,7 @@ 124,0,0,95,0,0,100,0,0,83,41,1,78,41,1,114, 177,0,0,0,41,2,114,71,0,0,0,114,177,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 72,0,0,0,233,3,0,0,115,2,0,0,0,0,1,122, + 72,0,0,0,232,3,0,0,115,2,0,0,0,0,1,122, 21,95,83,112,101,99,77,101,116,104,111,100,115,46,95,95, 105,110,105,116,95,95,99,1,0,0,0,0,0,0,0,3, 0,0,0,3,0,0,0,67,0,0,0,115,158,0,0,0, @@ -1733,7 +1733,7 @@ 0,114,169,0,0,0,114,47,0,0,0,114,226,0,0,0, 41,3,114,71,0,0,0,114,177,0,0,0,114,67,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,205,0,0,0,236,3,0,0,115,18,0,0,0,0,3, + 114,205,0,0,0,235,3,0,0,115,18,0,0,0,0,3, 9,1,30,1,15,1,15,1,13,2,22,2,9,1,19,2, 122,24,95,83,112,101,99,77,101,116,104,111,100,115,46,109, 111,100,117,108,101,95,114,101,112,114,218,9,95,111,118,101, @@ -1824,7 +1824,7 @@ 71,0,0,0,114,179,0,0,0,114,248,0,0,0,114,249, 0,0,0,114,177,0,0,0,114,169,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,218,17,105,110, - 105,116,95,109,111,100,117,108,101,95,97,116,116,114,115,252, + 105,116,95,109,111,100,117,108,101,95,97,116,116,114,115,251, 3,0,0,115,88,0,0,0,0,17,9,6,12,1,24,1, 3,1,16,1,13,1,8,3,30,1,9,1,12,2,15,1, 15,1,18,1,3,1,13,1,13,1,8,3,30,1,3,1, @@ -1856,7 +1856,7 @@ 0,0,114,68,0,0,0,114,67,0,0,0,114,254,0,0, 0,41,3,114,71,0,0,0,114,177,0,0,0,114,179,0, 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,6,99,114,101,97,116,101,76,4,0,0,115,16,0, + 0,218,6,99,114,101,97,116,101,75,4,0,0,115,16,0, 0,0,0,7,9,2,18,3,21,2,6,1,12,4,18,1, 13,1,122,19,95,83,112,101,99,77,101,116,104,111,100,115, 46,99,114,101,97,116,101,99,2,0,0,0,0,0,0,0, @@ -1878,7 +1878,7 @@ 0,114,169,0,0,0,218,11,101,120,101,99,95,109,111,100, 117,108,101,41,2,114,71,0,0,0,114,179,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,5, - 95,101,120,101,99,99,4,0,0,115,2,0,0,0,0,7, + 95,101,120,101,99,98,4,0,0,115,2,0,0,0,0,7, 122,18,95,83,112,101,99,77,101,116,104,111,100,115,46,95, 101,120,101,99,99,2,0,0,0,0,0,0,0,4,0,0, 0,11,0,0,0,67,0,0,0,115,17,1,0,0,124,0, @@ -1915,7 +1915,7 @@ 111,100,117,108,101,114,2,1,0,0,41,4,114,71,0,0, 0,114,179,0,0,0,114,67,0,0,0,114,171,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 175,0,0,0,109,4,0,0,115,32,0,0,0,0,2,12, + 175,0,0,0,108,4,0,0,115,32,0,0,0,0,2,12, 1,10,1,13,1,24,1,15,1,21,1,18,1,18,1,27, 2,19,1,4,1,19,1,21,4,22,2,19,1,122,17,95, 83,112,101,99,77,101,116,104,111,100,115,46,101,120,101,99, @@ -1948,7 +1948,7 @@ 0,0,114,177,0,0,0,114,179,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,25,95,108,111, 97,100,95,98,97,99,107,119,97,114,100,95,99,111,109,112, - 97,116,105,98,108,101,133,4,0,0,115,42,0,0,0,0, + 97,116,105,98,108,101,132,4,0,0,115,42,0,0,0,0, 4,9,1,19,2,16,1,24,1,3,1,16,1,13,1,8, 1,24,1,3,4,12,1,15,1,32,1,13,1,8,1,24, 1,3,1,13,1,13,1,8,1,122,38,95,83,112,101,99, @@ -1975,7 +1975,7 @@ 7,0,0,0,114,73,0,0,0,41,2,114,71,0,0,0, 114,179,0,0,0,114,4,0,0,0,114,4,0,0,0,114, 5,0,0,0,218,14,95,108,111,97,100,95,117,110,108,111, - 99,107,101,100,163,4,0,0,115,20,0,0,0,0,2,18, + 99,107,101,100,162,4,0,0,115,20,0,0,0,0,2,18, 2,21,1,13,2,12,1,13,1,18,1,18,1,30,3,19, 5,122,27,95,83,112,101,99,77,101,116,104,111,100,115,46, 95,108,111,97,100,95,117,110,108,111,99,107,101,100,99,1, @@ -2000,7 +2000,7 @@ 106,0,0,0,114,3,1,0,0,114,103,0,0,0,114,177, 0,0,0,114,67,0,0,0,114,6,1,0,0,41,1,114, 71,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,176,0,0,0,186,4,0,0,115,6,0,0, + 0,0,0,114,176,0,0,0,185,4,0,0,115,6,0,0, 0,0,9,10,1,19,1,122,17,95,83,112,101,99,77,101, 116,104,111,100,115,46,108,111,97,100,78,41,13,114,57,0, 0,0,114,56,0,0,0,114,58,0,0,0,114,59,0,0, @@ -2008,7 +2008,7 @@ 114,0,1,0,0,114,2,1,0,0,114,175,0,0,0,114, 5,1,0,0,114,6,1,0,0,114,176,0,0,0,114,4, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,174,0,0,0,226,3,0,0,115,20,0,0,0, + 0,0,114,174,0,0,0,225,3,0,0,115,20,0,0,0, 12,3,6,4,12,3,12,16,24,80,12,23,12,10,12,24, 12,30,12,23,114,174,0,0,0,99,0,0,0,0,0,0, 0,0,0,0,0,0,5,0,0,0,64,0,0,0,115,181, @@ -2047,7 +2047,7 @@ 60,109,111,100,117,108,101,32,123,33,114,125,32,40,98,117, 105,108,116,45,105,110,41,62,41,2,114,47,0,0,0,114, 57,0,0,0,41,1,114,179,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,205,0,0,0,211, + 114,4,0,0,0,114,5,0,0,0,114,205,0,0,0,210, 4,0,0,115,2,0,0,0,0,7,122,27,66,117,105,108, 116,105,110,73,109,112,111,114,116,101,114,46,109,111,100,117, 108,101,95,114,101,112,114,78,99,4,0,0,0,0,0,0, @@ -2061,7 +2061,7 @@ 110,114,173,0,0,0,41,4,218,3,99,108,115,114,158,0, 0,0,114,35,0,0,0,218,6,116,97,114,103,101,116,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,9, - 102,105,110,100,95,115,112,101,99,220,4,0,0,115,10,0, + 102,105,110,100,95,115,112,101,99,219,4,0,0,115,10,0, 0,0,0,2,12,1,4,1,15,1,19,2,122,25,66,117, 105,108,116,105,110,73,109,112,111,114,116,101,114,46,102,105, 110,100,95,115,112,101,99,99,3,0,0,0,0,0,0,0, @@ -2083,7 +2083,7 @@ 114,10,1,0,0,114,169,0,0,0,41,4,114,8,1,0, 0,114,158,0,0,0,114,35,0,0,0,114,177,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218, - 11,102,105,110,100,95,109,111,100,117,108,101,229,4,0,0, + 11,102,105,110,100,95,109,111,100,117,108,101,228,4,0,0, 115,4,0,0,0,0,9,18,1,122,27,66,117,105,108,116, 105,110,73,109,112,111,114,116,101,114,46,102,105,110,100,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,3, @@ -2098,7 +2098,7 @@ 110,105,116,95,98,117,105,108,116,105,110,114,204,0,0,0, 114,250,0,0,0,41,3,114,8,1,0,0,114,158,0,0, 0,114,179,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,4,1,0,0,241,4,0,0,115,10, + 114,5,0,0,0,114,4,1,0,0,240,4,0,0,115,10, 0,0,0,0,6,13,1,24,1,9,1,9,1,122,27,66, 117,105,108,116,105,110,73,109,112,111,114,116,101,114,46,108, 111,97,100,95,109,111,100,117,108,101,99,2,0,0,0,0, @@ -2110,7 +2110,7 @@ 101,99,116,115,46,78,114,4,0,0,0,41,2,114,8,1, 0,0,114,158,0,0,0,114,4,0,0,0,114,4,0,0, 0,114,5,0,0,0,218,8,103,101,116,95,99,111,100,101, - 253,4,0,0,115,2,0,0,0,0,4,122,24,66,117,105, + 252,4,0,0,115,2,0,0,0,0,4,122,24,66,117,105, 108,116,105,110,73,109,112,111,114,116,101,114,46,103,101,116, 95,99,111,100,101,99,2,0,0,0,0,0,0,0,2,0, 0,0,1,0,0,0,67,0,0,0,115,4,0,0,0,100, @@ -2120,7 +2120,7 @@ 118,101,32,115,111,117,114,99,101,32,99,111,100,101,46,78, 114,4,0,0,0,41,2,114,8,1,0,0,114,158,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 218,10,103,101,116,95,115,111,117,114,99,101,3,5,0,0, + 218,10,103,101,116,95,115,111,117,114,99,101,2,5,0,0, 115,2,0,0,0,0,4,122,26,66,117,105,108,116,105,110, 73,109,112,111,114,116,101,114,46,103,101,116,95,115,111,117, 114,99,101,99,2,0,0,0,0,0,0,0,2,0,0,0, @@ -2130,7 +2130,7 @@ 100,117,108,101,115,32,97,114,101,32,110,101,118,101,114,32, 112,97,99,107,97,103,101,115,46,70,114,4,0,0,0,41, 2,114,8,1,0,0,114,158,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,219,0,0,0,9, + 114,4,0,0,0,114,5,0,0,0,114,219,0,0,0,8, 5,0,0,115,2,0,0,0,0,4,122,26,66,117,105,108, 116,105,110,73,109,112,111,114,116,101,114,46,105,115,95,112, 97,99,107,97,103,101,41,14,114,57,0,0,0,114,56,0, @@ -2140,7 +2140,7 @@ 0,114,11,1,0,0,114,161,0,0,0,114,4,1,0,0, 114,12,1,0,0,114,13,1,0,0,114,219,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,7,1,0,0,202,4,0,0,115,28,0,0, + 0,0,0,114,7,1,0,0,201,4,0,0,115,28,0,0, 0,12,7,6,2,18,9,3,1,21,8,3,1,18,11,3, 1,21,11,3,1,21,5,3,1,21,5,3,1,114,7,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,5, @@ -2180,7 +2180,7 @@ 122,22,60,109,111,100,117,108,101,32,123,33,114,125,32,40, 102,114,111,122,101,110,41,62,41,2,114,47,0,0,0,114, 57,0,0,0,41,1,218,1,109,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,205,0,0,0,25,5,0, + 0,0,0,114,5,0,0,0,114,205,0,0,0,24,5,0, 0,115,2,0,0,0,0,7,122,26,70,114,111,122,101,110, 73,109,112,111,114,116,101,114,46,109,111,100,117,108,101,95, 114,101,112,114,78,99,4,0,0,0,0,0,0,0,4,0, @@ -2192,7 +2192,7 @@ 114,162,0,0,0,114,173,0,0,0,41,4,114,8,1,0, 0,114,158,0,0,0,114,35,0,0,0,114,9,1,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 10,1,0,0,34,5,0,0,115,6,0,0,0,0,2,15, + 10,1,0,0,33,5,0,0,115,6,0,0,0,0,2,15, 1,19,2,122,24,70,114,111,122,101,110,73,109,112,111,114, 116,101,114,46,102,105,110,100,95,115,112,101,99,99,3,0, 0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,0, @@ -2207,7 +2207,7 @@ 41,2,114,106,0,0,0,114,162,0,0,0,41,3,114,8, 1,0,0,114,158,0,0,0,114,35,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,11,1,0, - 0,41,5,0,0,115,2,0,0,0,0,7,122,26,70,114, + 0,40,5,0,0,115,2,0,0,0,0,7,122,26,70,114, 111,122,101,110,73,109,112,111,114,116,101,114,46,102,105,110, 100,95,109,111,100,117,108,101,99,1,0,0,0,0,0,0, 0,3,0,0,0,4,0,0,0,67,0,0,0,115,95,0, @@ -2225,7 +2225,7 @@ 95,102,114,111,122,101,110,95,111,98,106,101,99,116,114,175, 0,0,0,114,63,0,0,0,41,3,114,179,0,0,0,114, 67,0,0,0,114,194,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,1,1,0,0,50,5,0, + 0,0,0,114,5,0,0,0,114,1,1,0,0,49,5,0, 0,115,12,0,0,0,0,2,12,1,15,1,18,1,12,1, 18,1,122,26,70,114,111,122,101,110,73,109,112,111,114,116, 101,114,46,101,120,101,99,95,109,111,100,117,108,101,99,2, @@ -2239,7 +2239,7 @@ 117,108,101,40,41,32,105,110,115,116,101,97,100,46,10,10, 32,32,32,32,32,32,32,32,41,1,114,180,0,0,0,41, 2,114,8,1,0,0,114,158,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,4,1,0,0,59, + 114,4,0,0,0,114,5,0,0,0,114,4,1,0,0,58, 5,0,0,115,2,0,0,0,0,7,122,26,70,114,111,122, 101,110,73,109,112,111,114,116,101,114,46,108,111,97,100,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,2, @@ -2250,7 +2250,7 @@ 102,114,111,122,101,110,32,109,111,100,117,108,101,46,41,2, 114,106,0,0,0,114,18,1,0,0,41,2,114,8,1,0, 0,114,158,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,12,1,0,0,68,5,0,0,115,2, + 114,5,0,0,0,114,12,1,0,0,67,5,0,0,115,2, 0,0,0,0,4,122,23,70,114,111,122,101,110,73,109,112, 111,114,116,101,114,46,103,101,116,95,99,111,100,101,99,2, 0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,67, @@ -2260,7 +2260,7 @@ 32,110,111,116,32,104,97,118,101,32,115,111,117,114,99,101, 32,99,111,100,101,46,78,114,4,0,0,0,41,2,114,8, 1,0,0,114,158,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,114,13,1,0,0,74,5,0,0, + 0,0,114,5,0,0,0,114,13,1,0,0,73,5,0,0, 115,2,0,0,0,0,4,122,25,70,114,111,122,101,110,73, 109,112,111,114,116,101,114,46,103,101,116,95,115,111,117,114, 99,101,99,2,0,0,0,0,0,0,0,2,0,0,0,2, @@ -2272,7 +2272,7 @@ 0,0,90,17,105,115,95,102,114,111,122,101,110,95,112,97, 99,107,97,103,101,41,2,114,8,1,0,0,114,158,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,219,0,0,0,80,5,0,0,115,2,0,0,0,0,4, + 114,219,0,0,0,79,5,0,0,115,2,0,0,0,0,4, 122,25,70,114,111,122,101,110,73,109,112,111,114,116,101,114, 46,105,115,95,112,97,99,107,97,103,101,41,15,114,57,0, 0,0,114,56,0,0,0,114,58,0,0,0,114,59,0,0, @@ -2281,7 +2281,7 @@ 4,1,0,0,114,164,0,0,0,114,12,1,0,0,114,13, 1,0,0,114,219,0,0,0,114,4,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,16,1,0, - 0,16,5,0,0,115,28,0,0,0,12,7,6,2,18,9, + 0,15,5,0,0,115,28,0,0,0,12,7,6,2,18,9, 3,1,21,6,3,1,18,8,18,9,18,9,3,1,21,5, 3,1,21,5,3,1,114,16,1,0,0,99,0,0,0,0, 0,0,0,0,0,0,0,0,5,0,0,0,64,0,0,0, @@ -2319,7 +2319,7 @@ 95,77,65,67,72,73,78,69,41,2,114,8,1,0,0,218, 3,107,101,121,114,4,0,0,0,114,4,0,0,0,114,5, 0,0,0,218,14,95,111,112,101,110,95,114,101,103,105,115, - 116,114,121,99,5,0,0,115,8,0,0,0,0,2,3,1, + 116,114,121,98,5,0,0,115,8,0,0,0,0,2,3,1, 23,1,13,1,122,36,87,105,110,100,111,119,115,82,101,103, 105,115,116,114,121,70,105,110,100,101,114,46,95,111,112,101, 110,95,114,101,103,105,115,116,114,121,99,2,0,0,0,0, @@ -2346,7 +2346,7 @@ 4,104,107,101,121,218,8,102,105,108,101,112,97,116,104,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,16, 95,115,101,97,114,99,104,95,114,101,103,105,115,116,114,121, - 106,5,0,0,115,22,0,0,0,0,2,9,1,12,2,9, + 105,5,0,0,115,22,0,0,0,0,2,9,1,12,2,9, 1,15,1,22,1,3,1,18,1,28,1,13,1,9,1,122, 38,87,105,110,100,111,119,115,82,101,103,105,115,116,114,121, 70,105,110,100,101,114,46,95,115,101,97,114,99,104,95,114, @@ -2368,7 +2368,7 @@ 0,114,158,0,0,0,114,35,0,0,0,114,9,1,0,0, 114,27,1,0,0,114,169,0,0,0,114,127,0,0,0,114, 177,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,10,1,0,0,121,5,0,0,115,24,0,0, + 0,0,0,114,10,1,0,0,120,5,0,0,115,24,0,0, 0,0,2,15,1,12,1,4,1,3,1,14,1,13,1,9, 1,22,1,21,1,21,1,9,1,122,31,87,105,110,100,111, 119,115,82,101,103,105,115,116,114,121,70,105,110,100,101,114, @@ -2387,7 +2387,7 @@ 32,78,41,2,114,10,1,0,0,114,169,0,0,0,41,4, 114,8,1,0,0,114,158,0,0,0,114,35,0,0,0,114, 177,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,11,1,0,0,136,5,0,0,115,8,0,0, + 0,0,0,114,11,1,0,0,135,5,0,0,115,8,0,0, 0,0,7,18,1,12,1,7,2,122,33,87,105,110,100,111, 119,115,82,101,103,105,115,116,114,121,70,105,110,100,101,114, 46,102,105,110,100,95,109,111,100,117,108,101,41,12,114,57, @@ -2396,7 +2396,7 @@ 0,114,15,1,0,0,114,22,1,0,0,114,28,1,0,0, 114,10,1,0,0,114,11,1,0,0,114,4,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,19, - 1,0,0,87,5,0,0,115,20,0,0,0,12,2,6,3, + 1,0,0,86,5,0,0,115,20,0,0,0,12,2,6,3, 6,3,6,2,6,2,18,7,18,15,3,1,21,14,3,1, 114,19,1,0,0,99,0,0,0,0,0,0,0,0,0,0, 0,0,2,0,0,0,64,0,0,0,115,52,0,0,0,101, @@ -2432,7 +2432,7 @@ 0,0,114,158,0,0,0,114,131,0,0,0,90,13,102,105, 108,101,110,97,109,101,95,98,97,115,101,90,9,116,97,105, 108,95,110,97,109,101,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,219,0,0,0,155,5,0,0,115,8, + 114,5,0,0,0,114,219,0,0,0,154,5,0,0,115,8, 0,0,0,0,3,25,1,22,1,19,1,122,24,95,76,111, 97,100,101,114,66,97,115,105,99,115,46,105,115,95,112,97, 99,107,97,103,101,99,2,0,0,0,0,0,0,0,3,0, @@ -2451,14 +2451,14 @@ 0,0,0,114,114,0,0,0,114,175,0,0,0,114,63,0, 0,0,41,3,114,71,0,0,0,114,179,0,0,0,114,194, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,1,1,0,0,163,5,0,0,115,10,0,0,0, + 0,0,114,1,1,0,0,162,5,0,0,115,10,0,0,0, 0,2,18,1,12,1,3,1,24,1,122,25,95,76,111,97, 100,101,114,66,97,115,105,99,115,46,101,120,101,99,95,109, 111,100,117,108,101,78,41,8,114,57,0,0,0,114,56,0, 0,0,114,58,0,0,0,114,59,0,0,0,114,219,0,0, 0,114,1,1,0,0,114,180,0,0,0,114,4,1,0,0, 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,29,1,0,0,150,5,0,0,115,8,0, + 5,0,0,0,114,29,1,0,0,149,5,0,0,115,8,0, 0,0,12,3,6,2,12,8,12,8,114,29,1,0,0,99, 0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0, 64,0,0,0,115,106,0,0,0,101,0,0,90,1,0,100, @@ -2486,7 +2486,7 @@ 218,7,73,79,69,114,114,111,114,41,2,114,71,0,0,0, 114,35,0,0,0,114,4,0,0,0,114,4,0,0,0,114, 5,0,0,0,218,10,112,97,116,104,95,109,116,105,109,101, - 176,5,0,0,115,2,0,0,0,0,6,122,23,83,111,117, + 175,5,0,0,115,2,0,0,0,0,6,122,23,83,111,117, 114,99,101,76,111,97,100,101,114,46,112,97,116,104,95,109, 116,105,109,101,99,2,0,0,0,0,0,0,0,2,0,0, 0,3,0,0,0,67,0,0,0,115,20,0,0,0,105,1, @@ -2521,7 +2521,7 @@ 32,32,32,114,183,0,0,0,41,1,114,32,1,0,0,41, 2,114,71,0,0,0,114,35,0,0,0,114,4,0,0,0, 114,4,0,0,0,114,5,0,0,0,218,10,112,97,116,104, - 95,115,116,97,116,115,184,5,0,0,115,2,0,0,0,0, + 95,115,116,97,116,115,183,5,0,0,115,2,0,0,0,0, 11,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 112,97,116,104,95,115,116,97,116,115,99,4,0,0,0,0, 0,0,0,4,0,0,0,3,0,0,0,67,0,0,0,115, @@ -2545,7 +2545,7 @@ 141,0,0,0,90,10,99,97,99,104,101,95,112,97,116,104, 114,53,0,0,0,114,4,0,0,0,114,4,0,0,0,114, 5,0,0,0,218,15,95,99,97,99,104,101,95,98,121,116, - 101,99,111,100,101,197,5,0,0,115,2,0,0,0,0,8, + 101,99,111,100,101,196,5,0,0,115,2,0,0,0,0,8, 122,28,83,111,117,114,99,101,76,111,97,100,101,114,46,95, 99,97,99,104,101,95,98,121,116,101,99,111,100,101,99,3, 0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,67, @@ -2562,7 +2562,7 @@ 32,32,32,32,32,32,78,114,4,0,0,0,41,3,114,71, 0,0,0,114,35,0,0,0,114,53,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,34,1,0, - 0,207,5,0,0,115,0,0,0,0,122,21,83,111,117,114, + 0,206,5,0,0,115,0,0,0,0,122,21,83,111,117,114, 99,101,76,111,97,100,101,114,46,115,101,116,95,100,97,116, 97,99,2,0,0,0,0,0,0,0,5,0,0,0,16,0, 0,0,67,0,0,0,115,105,0,0,0,124,0,0,106,0, @@ -2583,7 +2583,7 @@ 0,114,153,0,0,0,114,203,0,0,0,41,5,114,71,0, 0,0,114,158,0,0,0,114,35,0,0,0,114,201,0,0, 0,218,3,101,120,99,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,13,1,0,0,214,5,0,0,115,14, + 114,5,0,0,0,114,13,1,0,0,213,5,0,0,115,14, 0,0,0,0,2,15,1,3,1,19,1,18,1,9,1,31, 1,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 103,101,116,95,115,111,117,114,99,101,218,9,95,111,112,116, @@ -2605,7 +2605,7 @@ 108,101,41,4,114,71,0,0,0,114,53,0,0,0,114,35, 0,0,0,114,38,1,0,0,114,4,0,0,0,114,4,0, 0,0,114,5,0,0,0,218,14,115,111,117,114,99,101,95, - 116,111,95,99,111,100,101,224,5,0,0,115,4,0,0,0, + 116,111,95,99,111,100,101,223,5,0,0,115,4,0,0,0, 0,5,18,1,122,27,83,111,117,114,99,101,76,111,97,100, 101,114,46,115,111,117,114,99,101,95,116,111,95,99,111,100, 101,99,2,0,0,0,0,0,0,0,10,0,0,0,45,0, @@ -2666,7 +2666,7 @@ 0,0,218,10,98,121,116,101,115,95,100,97,116,97,114,201, 0,0,0,90,11,99,111,100,101,95,111,98,106,101,99,116, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 12,1,0,0,232,5,0,0,115,78,0,0,0,0,7,15, + 12,1,0,0,231,5,0,0,115,78,0,0,0,0,7,15, 1,6,1,3,1,16,1,13,1,11,2,3,1,19,1,13, 1,5,2,16,1,3,1,19,1,13,1,5,2,3,1,9, 1,12,1,13,1,19,1,5,2,9,1,7,1,15,1,6, @@ -2678,7 +2678,7 @@ 1,0,0,114,35,1,0,0,114,34,1,0,0,114,13,1, 0,0,114,41,1,0,0,114,12,1,0,0,114,4,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,30,1,0,0,174,5,0,0,115,14,0,0,0,12,2, + 114,30,1,0,0,173,5,0,0,115,14,0,0,0,12,2, 12,8,12,13,12,10,12,7,12,10,18,8,114,30,1,0, 0,99,0,0,0,0,0,0,0,0,0,0,0,0,4,0, 0,0,0,0,0,0,115,112,0,0,0,101,0,0,90,1, @@ -2707,7 +2707,7 @@ 46,78,41,2,114,67,0,0,0,114,35,0,0,0,41,3, 114,71,0,0,0,114,158,0,0,0,114,35,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,72, - 0,0,0,33,6,0,0,115,4,0,0,0,0,3,9,1, + 0,0,0,32,6,0,0,115,4,0,0,0,0,3,9,1, 122,19,70,105,108,101,76,111,97,100,101,114,46,95,95,105, 110,105,116,95,95,99,2,0,0,0,0,0,0,0,2,0, 0,0,3,0,0,0,67,0,0,0,115,34,0,0,0,124, @@ -2716,7 +2716,7 @@ 83,41,1,78,41,2,114,224,0,0,0,114,63,0,0,0, 41,2,114,71,0,0,0,114,227,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,229,0,0,0, - 39,6,0,0,115,4,0,0,0,0,1,18,1,122,17,70, + 38,6,0,0,115,4,0,0,0,0,1,18,1,122,17,70, 105,108,101,76,111,97,100,101,114,46,95,95,101,113,95,95, 99,1,0,0,0,0,0,0,0,1,0,0,0,3,0,0, 0,67,0,0,0,115,26,0,0,0,116,0,0,124,0,0, @@ -2724,7 +2724,7 @@ 1,0,65,83,41,1,78,41,3,218,4,104,97,115,104,114, 67,0,0,0,114,35,0,0,0,41,1,114,71,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218, - 8,95,95,104,97,115,104,95,95,43,6,0,0,115,2,0, + 8,95,95,104,97,115,104,95,95,42,6,0,0,115,2,0, 0,0,0,1,122,19,70,105,108,101,76,111,97,100,101,114, 46,95,95,104,97,115,104,95,95,99,2,0,0,0,0,0, 0,0,2,0,0,0,3,0,0,0,3,0,0,0,115,22, @@ -2739,7 +2739,7 @@ 32,41,3,218,5,115,117,112,101,114,114,45,1,0,0,114, 4,1,0,0,41,2,114,71,0,0,0,114,158,0,0,0, 41,1,114,224,0,0,0,114,4,0,0,0,114,5,0,0, - 0,114,4,1,0,0,46,6,0,0,115,2,0,0,0,0, + 0,114,4,1,0,0,45,6,0,0,115,2,0,0,0,0, 10,122,22,70,105,108,101,76,111,97,100,101,114,46,108,111, 97,100,95,109,111,100,117,108,101,99,2,0,0,0,0,0, 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,7, @@ -2749,7 +2749,7 @@ 32,97,115,32,102,111,117,110,100,32,98,121,32,116,104,101, 32,102,105,110,100,101,114,46,41,1,114,35,0,0,0,41, 2,114,71,0,0,0,114,158,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,238,0,0,0,58, + 114,4,0,0,0,114,5,0,0,0,114,238,0,0,0,57, 6,0,0,115,2,0,0,0,0,3,122,23,70,105,108,101, 76,111,97,100,101,114,46,103,101,116,95,102,105,108,101,110, 97,109,101,99,2,0,0,0,0,0,0,0,3,0,0,0, @@ -2762,7 +2762,7 @@ 46,218,1,114,78,41,3,114,49,0,0,0,114,50,0,0, 0,90,4,114,101,97,100,41,3,114,71,0,0,0,114,35, 0,0,0,114,54,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,114,36,1,0,0,63,6,0,0, + 0,0,114,5,0,0,0,114,36,1,0,0,62,6,0,0, 115,4,0,0,0,0,2,21,1,122,19,70,105,108,101,76, 111,97,100,101,114,46,103,101,116,95,100,97,116,97,41,11, 114,57,0,0,0,114,56,0,0,0,114,58,0,0,0,114, @@ -2770,7 +2770,7 @@ 1,0,0,114,156,0,0,0,114,4,1,0,0,114,238,0, 0,0,114,36,1,0,0,114,4,0,0,0,114,4,0,0, 0,41,1,114,224,0,0,0,114,5,0,0,0,114,45,1, - 0,0,28,6,0,0,115,14,0,0,0,12,3,6,2,12, + 0,0,27,6,0,0,115,14,0,0,0,12,3,6,2,12, 6,12,4,12,3,24,12,18,5,114,45,1,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,64, 0,0,0,115,64,0,0,0,101,0,0,90,1,0,100,0, @@ -2793,7 +2793,7 @@ 218,8,115,116,95,109,116,105,109,101,90,7,115,116,95,115, 105,122,101,41,3,114,71,0,0,0,114,35,0,0,0,114, 43,1,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,33,1,0,0,73,6,0,0,115,4,0,0, + 0,0,0,114,33,1,0,0,72,6,0,0,115,4,0,0, 0,0,2,12,1,122,27,83,111,117,114,99,101,70,105,108, 101,76,111,97,100,101,114,46,112,97,116,104,95,115,116,97, 116,115,99,4,0,0,0,0,0,0,0,5,0,0,0,5, @@ -2804,7 +2804,7 @@ 34,1,0,0,41,5,114,71,0,0,0,114,141,0,0,0, 114,140,0,0,0,114,53,0,0,0,114,42,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,35, - 1,0,0,78,6,0,0,115,4,0,0,0,0,2,12,1, + 1,0,0,77,6,0,0,115,4,0,0,0,0,2,12,1, 122,32,83,111,117,114,99,101,70,105,108,101,76,111,97,100, 101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,111, 100,101,114,52,1,0,0,105,182,1,0,0,99,3,0,0, @@ -2842,7 +2842,7 @@ 1,0,0,114,233,0,0,0,114,131,0,0,0,114,27,0, 0,0,114,23,0,0,0,114,37,1,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,34,1,0,0, - 83,6,0,0,115,38,0,0,0,0,2,18,1,6,2,22, + 82,6,0,0,115,38,0,0,0,0,2,18,1,6,2,22, 1,18,1,17,2,19,1,15,1,3,1,17,1,13,2,7, 1,18,3,16,1,27,1,3,1,16,1,17,1,18,2,122, 25,83,111,117,114,99,101,70,105,108,101,76,111,97,100,101, @@ -2850,7 +2850,7 @@ 0,0,114,56,0,0,0,114,58,0,0,0,114,59,0,0, 0,114,33,1,0,0,114,35,1,0,0,114,34,1,0,0, 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,50,1,0,0,69,6,0,0,115,8,0, + 5,0,0,0,114,50,1,0,0,68,6,0,0,115,8,0, 0,0,12,2,6,2,12,5,12,5,114,50,1,0,0,99, 0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, 64,0,0,0,115,46,0,0,0,101,0,0,90,1,0,100, @@ -2872,7 +2872,7 @@ 0,0,114,190,0,0,0,114,195,0,0,0,41,5,114,71, 0,0,0,114,158,0,0,0,114,35,0,0,0,114,53,0, 0,0,114,44,1,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,12,1,0,0,116,6,0,0,115, + 0,114,5,0,0,0,114,12,1,0,0,115,6,0,0,115, 8,0,0,0,0,1,15,1,15,1,24,1,122,29,83,111, 117,114,99,101,108,101,115,115,70,105,108,101,76,111,97,100, 101,114,46,103,101,116,95,99,111,100,101,99,2,0,0,0, @@ -2882,14 +2882,14 @@ 101,32,105,115,32,110,111,32,115,111,117,114,99,101,32,99, 111,100,101,46,78,114,4,0,0,0,41,2,114,71,0,0, 0,114,158,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,13,1,0,0,122,6,0,0,115,2, + 114,5,0,0,0,114,13,1,0,0,121,6,0,0,115,2, 0,0,0,0,2,122,31,83,111,117,114,99,101,108,101,115, 115,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95, 115,111,117,114,99,101,78,41,6,114,57,0,0,0,114,56, 0,0,0,114,58,0,0,0,114,59,0,0,0,114,12,1, 0,0,114,13,1,0,0,114,4,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,54,1,0,0, - 112,6,0,0,115,6,0,0,0,12,2,6,2,12,6,114, + 111,6,0,0,115,6,0,0,0,12,2,6,2,12,6,114, 54,1,0,0,99,0,0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,64,0,0,0,115,130,0,0,0,101,0, 0,90,1,0,100,0,0,90,2,0,100,1,0,90,3,0, @@ -2913,7 +2913,7 @@ 1,0,100,0,0,83,41,1,78,41,2,114,67,0,0,0, 114,35,0,0,0,41,3,114,71,0,0,0,114,67,0,0, 0,114,35,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,72,0,0,0,139,6,0,0,115,4, + 114,5,0,0,0,114,72,0,0,0,138,6,0,0,115,4, 0,0,0,0,1,9,1,122,28,69,120,116,101,110,115,105, 111,110,70,105,108,101,76,111,97,100,101,114,46,95,95,105, 110,105,116,95,95,99,2,0,0,0,0,0,0,0,2,0, @@ -2923,7 +2923,7 @@ 83,41,1,78,41,2,114,224,0,0,0,114,63,0,0,0, 41,2,114,71,0,0,0,114,227,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,229,0,0,0, - 143,6,0,0,115,4,0,0,0,0,1,18,1,122,26,69, + 142,6,0,0,115,4,0,0,0,0,1,18,1,122,26,69, 120,116,101,110,115,105,111,110,70,105,108,101,76,111,97,100, 101,114,46,95,95,101,113,95,95,99,1,0,0,0,0,0, 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,26, @@ -2931,7 +2931,7 @@ 0,0,124,0,0,106,2,0,131,1,0,65,83,41,1,78, 41,3,114,46,1,0,0,114,67,0,0,0,114,35,0,0, 0,41,1,114,71,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,114,47,1,0,0,147,6,0,0, + 0,0,114,5,0,0,0,114,47,1,0,0,146,6,0,0, 115,2,0,0,0,0,1,122,28,69,120,116,101,110,115,105, 111,110,70,105,108,101,76,111,97,100,101,114,46,95,95,104, 97,115,104,95,95,99,2,0,0,0,0,0,0,0,4,0, @@ -2960,7 +2960,7 @@ 0,0,114,32,0,0,0,41,4,114,71,0,0,0,114,158, 0,0,0,114,179,0,0,0,114,219,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,4,1,0, - 0,150,6,0,0,115,24,0,0,0,0,5,13,1,9,1, + 0,149,6,0,0,115,24,0,0,0,0,5,13,1,9,1, 21,1,16,1,15,1,22,1,28,1,9,1,12,1,6,1, 28,1,122,31,69,120,116,101,110,115,105,111,110,70,105,108, 101,76,111,97,100,101,114,46,108,111,97,100,95,109,111,100, @@ -2979,7 +2979,7 @@ 41,2,114,72,0,0,0,78,114,4,0,0,0,41,2,114, 22,0,0,0,218,6,115,117,102,102,105,120,41,1,218,9, 102,105,108,101,95,110,97,109,101,114,4,0,0,0,114,5, - 0,0,0,114,77,0,0,0,171,6,0,0,115,2,0,0, + 0,0,0,114,77,0,0,0,170,6,0,0,115,2,0,0, 0,6,1,122,49,69,120,116,101,110,115,105,111,110,70,105, 108,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, 97,103,101,46,60,108,111,99,97,108,115,62,46,60,103,101, @@ -2987,7 +2987,7 @@ 0,0,114,78,0,0,0,218,18,69,88,84,69,78,83,73, 79,78,95,83,85,70,70,73,88,69,83,41,2,114,71,0, 0,0,114,158,0,0,0,114,4,0,0,0,41,1,114,57, - 1,0,0,114,5,0,0,0,114,219,0,0,0,168,6,0, + 1,0,0,114,5,0,0,0,114,219,0,0,0,167,6,0, 0,115,6,0,0,0,0,2,19,1,18,1,122,30,69,120, 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, 114,46,105,115,95,112,97,99,107,97,103,101,99,2,0,0, @@ -2999,7 +2999,7 @@ 32,99,111,100,101,32,111,98,106,101,99,116,46,78,114,4, 0,0,0,41,2,114,71,0,0,0,114,158,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,12, - 1,0,0,174,6,0,0,115,2,0,0,0,0,2,122,28, + 1,0,0,173,6,0,0,115,2,0,0,0,0,2,122,28, 69,120,116,101,110,115,105,111,110,70,105,108,101,76,111,97, 100,101,114,46,103,101,116,95,99,111,100,101,99,2,0,0, 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0, @@ -3009,7 +3009,7 @@ 97,118,101,32,110,111,32,115,111,117,114,99,101,32,99,111, 100,101,46,78,114,4,0,0,0,41,2,114,71,0,0,0, 114,158,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,13,1,0,0,178,6,0,0,115,2,0, + 5,0,0,0,114,13,1,0,0,177,6,0,0,115,2,0, 0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111, 117,114,99,101,99,2,0,0,0,0,0,0,0,2,0,0, @@ -3020,7 +3020,7 @@ 111,117,110,100,32,98,121,32,116,104,101,32,102,105,110,100, 101,114,46,41,1,114,35,0,0,0,41,2,114,71,0,0, 0,114,158,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,238,0,0,0,182,6,0,0,115,2, + 114,5,0,0,0,114,238,0,0,0,181,6,0,0,115,2, 0,0,0,0,3,122,32,69,120,116,101,110,115,105,111,110, 70,105,108,101,76,111,97,100,101,114,46,103,101,116,95,102, 105,108,101,110,97,109,101,78,41,13,114,57,0,0,0,114, @@ -3029,7 +3029,7 @@ 0,0,114,4,1,0,0,114,219,0,0,0,114,12,1,0, 0,114,13,1,0,0,114,238,0,0,0,114,4,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 55,1,0,0,131,6,0,0,115,18,0,0,0,12,6,6, + 55,1,0,0,130,6,0,0,115,18,0,0,0,12,6,6, 2,12,4,12,4,12,3,18,18,12,6,12,4,12,4,114, 55,1,0,0,99,0,0,0,0,0,0,0,0,0,0,0, 0,2,0,0,0,64,0,0,0,115,130,0,0,0,101,0, @@ -3073,7 +3073,7 @@ 101,114,41,4,114,71,0,0,0,114,67,0,0,0,114,35, 0,0,0,218,11,112,97,116,104,95,102,105,110,100,101,114, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 72,0,0,0,195,6,0,0,115,8,0,0,0,0,1,9, + 72,0,0,0,194,6,0,0,115,8,0,0,0,0,1,9, 1,9,1,21,1,122,23,95,78,97,109,101,115,112,97,99, 101,80,97,116,104,46,95,95,105,110,105,116,95,95,99,1, 0,0,0,0,0,0,0,4,0,0,0,3,0,0,0,67, @@ -3091,7 +3091,7 @@ 0,41,4,114,71,0,0,0,114,233,0,0,0,218,3,100, 111,116,114,94,0,0,0,114,4,0,0,0,114,4,0,0, 0,114,5,0,0,0,218,23,95,102,105,110,100,95,112,97, - 114,101,110,116,95,112,97,116,104,95,110,97,109,101,115,201, + 114,101,110,116,95,112,97,116,104,95,110,97,109,101,115,200, 6,0,0,115,8,0,0,0,0,2,27,1,12,2,4,3, 122,38,95,78,97,109,101,115,112,97,99,101,80,97,116,104, 46,95,102,105,110,100,95,112,97,114,101,110,116,95,112,97, @@ -3105,7 +3105,7 @@ 95,109,111,100,117,108,101,95,110,97,109,101,90,14,112,97, 116,104,95,97,116,116,114,95,110,97,109,101,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,60,1,0,0, - 211,6,0,0,115,4,0,0,0,0,1,18,1,122,31,95, + 210,6,0,0,115,4,0,0,0,0,1,18,1,122,31,95, 78,97,109,101,115,112,97,99,101,80,97,116,104,46,95,103, 101,116,95,112,97,114,101,110,116,95,112,97,116,104,99,1, 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67, @@ -3123,7 +3123,7 @@ 253,0,0,0,41,3,114,71,0,0,0,90,11,112,97,114, 101,110,116,95,112,97,116,104,114,177,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,218,12,95,114, - 101,99,97,108,99,117,108,97,116,101,215,6,0,0,115,16, + 101,99,97,108,99,117,108,97,116,101,214,6,0,0,115,16, 0,0,0,0,2,18,1,15,1,21,3,27,1,9,1,18, 1,12,1,122,27,95,78,97,109,101,115,112,97,99,101,80, 97,116,104,46,95,114,101,99,97,108,99,117,108,97,116,101, @@ -3132,7 +3132,7 @@ 106,1,0,131,0,0,131,1,0,83,41,1,78,41,2,218, 4,105,116,101,114,114,66,1,0,0,41,1,114,71,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 218,8,95,95,105,116,101,114,95,95,228,6,0,0,115,2, + 218,8,95,95,105,116,101,114,95,95,227,6,0,0,115,2, 0,0,0,0,1,122,23,95,78,97,109,101,115,112,97,99, 101,80,97,116,104,46,95,95,105,116,101,114,95,95,99,1, 0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,67, @@ -3140,7 +3140,7 @@ 0,131,0,0,131,1,0,83,41,1,78,41,2,114,31,0, 0,0,114,66,1,0,0,41,1,114,71,0,0,0,114,4, 0,0,0,114,4,0,0,0,114,5,0,0,0,218,7,95, - 95,108,101,110,95,95,231,6,0,0,115,2,0,0,0,0, + 95,108,101,110,95,95,230,6,0,0,115,2,0,0,0,0, 1,122,22,95,78,97,109,101,115,112,97,99,101,80,97,116, 104,46,95,95,108,101,110,95,95,99,1,0,0,0,0,0, 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,16, @@ -3149,7 +3149,7 @@ 99,101,80,97,116,104,40,123,33,114,125,41,41,2,114,47, 0,0,0,114,253,0,0,0,41,1,114,71,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,101, - 0,0,0,234,6,0,0,115,2,0,0,0,0,1,122,23, + 0,0,0,233,6,0,0,115,2,0,0,0,0,1,122,23, 95,78,97,109,101,115,112,97,99,101,80,97,116,104,46,95, 95,114,101,112,114,95,95,99,2,0,0,0,0,0,0,0, 2,0,0,0,2,0,0,0,67,0,0,0,115,16,0,0, @@ -3157,7 +3157,7 @@ 83,41,1,78,41,1,114,66,1,0,0,41,2,114,71,0, 0,0,218,4,105,116,101,109,114,4,0,0,0,114,4,0, 0,0,114,5,0,0,0,218,12,95,95,99,111,110,116,97, - 105,110,115,95,95,237,6,0,0,115,2,0,0,0,0,1, + 105,110,115,95,95,236,6,0,0,115,2,0,0,0,0,1, 122,27,95,78,97,109,101,115,112,97,99,101,80,97,116,104, 46,95,95,99,111,110,116,97,105,110,115,95,95,99,2,0, 0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,0, @@ -3165,7 +3165,7 @@ 124,1,0,131,1,0,1,100,0,0,83,41,1,78,41,2, 114,253,0,0,0,114,223,0,0,0,41,2,114,71,0,0, 0,114,70,1,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,223,0,0,0,240,6,0,0,115,2, + 114,5,0,0,0,114,223,0,0,0,239,6,0,0,115,2, 0,0,0,0,1,122,21,95,78,97,109,101,115,112,97,99, 101,80,97,116,104,46,97,112,112,101,110,100,78,41,13,114, 57,0,0,0,114,56,0,0,0,114,58,0,0,0,114,59, @@ -3173,7 +3173,7 @@ 0,0,114,66,1,0,0,114,68,1,0,0,114,69,1,0, 0,114,101,0,0,0,114,71,1,0,0,114,223,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,59,1,0,0,188,6,0,0,115,20,0, + 5,0,0,0,114,59,1,0,0,187,6,0,0,115,20,0, 0,0,12,5,6,2,12,6,12,10,12,4,12,13,12,3, 12,3,12,3,12,3,114,59,1,0,0,99,0,0,0,0, 0,0,0,0,0,0,0,0,3,0,0,0,64,0,0,0, @@ -3191,7 +3191,7 @@ 1,0,0,114,253,0,0,0,41,4,114,71,0,0,0,114, 67,0,0,0,114,35,0,0,0,114,63,1,0,0,114,4, 0,0,0,114,4,0,0,0,114,5,0,0,0,114,72,0, - 0,0,246,6,0,0,115,2,0,0,0,0,1,122,25,95, + 0,0,245,6,0,0,115,2,0,0,0,0,1,122,25,95, 78,97,109,101,115,112,97,99,101,76,111,97,100,101,114,46, 95,95,105,110,105,116,95,95,99,2,0,0,0,0,0,0, 0,2,0,0,0,2,0,0,0,67,0,0,0,115,16,0, @@ -3208,21 +3208,21 @@ 99,101,41,62,41,2,114,47,0,0,0,114,57,0,0,0, 41,2,114,8,1,0,0,114,179,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,205,0,0,0, - 249,6,0,0,115,2,0,0,0,0,7,122,28,95,78,97, + 248,6,0,0,115,2,0,0,0,0,7,122,28,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,109,111, 100,117,108,101,95,114,101,112,114,99,2,0,0,0,0,0, 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,4, 0,0,0,100,1,0,83,41,2,78,84,114,4,0,0,0, 41,2,114,71,0,0,0,114,158,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,114,219,0,0,0, - 2,7,0,0,115,2,0,0,0,0,1,122,27,95,78,97, + 1,7,0,0,115,2,0,0,0,0,1,122,27,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,105,115, 95,112,97,99,107,97,103,101,99,2,0,0,0,0,0,0, 0,2,0,0,0,1,0,0,0,67,0,0,0,115,4,0, 0,0,100,1,0,83,41,2,78,114,30,0,0,0,114,4, 0,0,0,41,2,114,71,0,0,0,114,158,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,13, - 1,0,0,5,7,0,0,115,2,0,0,0,0,1,122,27, + 1,0,0,4,7,0,0,115,2,0,0,0,0,1,122,27, 95,78,97,109,101,115,112,97,99,101,76,111,97,100,101,114, 46,103,101,116,95,115,111,117,114,99,101,99,2,0,0,0, 0,0,0,0,2,0,0,0,6,0,0,0,67,0,0,0, @@ -3231,14 +3231,14 @@ 0,0,0,122,8,60,115,116,114,105,110,103,62,114,175,0, 0,0,114,39,1,0,0,84,41,1,114,40,1,0,0,41, 2,114,71,0,0,0,114,158,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,12,1,0,0,8, + 114,4,0,0,0,114,5,0,0,0,114,12,1,0,0,7, 7,0,0,115,2,0,0,0,0,1,122,25,95,78,97,109, 101,115,112,97,99,101,76,111,97,100,101,114,46,103,101,116, 95,99,111,100,101,99,2,0,0,0,0,0,0,0,2,0, 0,0,1,0,0,0,67,0,0,0,115,4,0,0,0,100, 0,0,83,41,1,78,114,4,0,0,0,41,2,114,71,0, 0,0,114,179,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,1,1,0,0,11,7,0,0,115, + 0,114,5,0,0,0,114,1,1,0,0,10,7,0,0,115, 2,0,0,0,0,1,122,28,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,2,0,0, @@ -3256,7 +3256,7 @@ 112,97,116,104,32,123,33,114,125,41,3,114,152,0,0,0, 114,253,0,0,0,114,180,0,0,0,41,2,114,71,0,0, 0,114,158,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,4,1,0,0,14,7,0,0,115,4, + 114,5,0,0,0,114,4,1,0,0,13,7,0,0,115,4, 0,0,0,0,7,16,1,122,28,95,78,97,109,101,115,112, 97,99,101,76,111,97,100,101,114,46,108,111,97,100,95,109, 111,100,117,108,101,78,41,11,114,57,0,0,0,114,56,0, @@ -3264,7 +3264,7 @@ 0,114,205,0,0,0,114,219,0,0,0,114,13,1,0,0, 114,12,1,0,0,114,1,1,0,0,114,4,1,0,0,114, 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,251,0,0,0,245,6,0,0,115,14,0,0, + 0,0,0,114,251,0,0,0,244,6,0,0,115,14,0,0, 0,12,1,12,3,18,9,12,3,12,3,12,3,12,3,114, 251,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0, 0,5,0,0,0,64,0,0,0,115,160,0,0,0,101,0, @@ -3302,7 +3302,7 @@ 101,218,6,118,97,108,117,101,115,114,60,0,0,0,114,73, 1,0,0,41,2,114,8,1,0,0,218,6,102,105,110,100, 101,114,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,114,73,1,0,0,31,7,0,0,115,6,0,0,0,0, + 0,114,73,1,0,0,30,7,0,0,115,6,0,0,0,0, 4,22,1,15,1,122,28,80,97,116,104,70,105,110,100,101, 114,46,105,110,118,97,108,105,100,97,116,101,95,99,97,99, 104,101,115,99,2,0,0,0,0,0,0,0,3,0,0,0, @@ -3326,7 +3326,7 @@ 0,0,114,167,0,0,0,114,168,0,0,0,114,153,0,0, 0,41,3,114,8,1,0,0,114,35,0,0,0,90,4,104, 111,111,107,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,218,11,95,112,97,116,104,95,104,111,111,107,115,39, + 0,0,218,11,95,112,97,116,104,95,104,111,111,107,115,38, 7,0,0,115,16,0,0,0,0,7,9,1,19,1,16,1, 3,1,14,1,13,1,12,2,122,22,80,97,116,104,70,105, 110,100,101,114,46,95,112,97,116,104,95,104,111,111,107,115, @@ -3356,7 +3356,7 @@ 0,114,78,1,0,0,41,3,114,8,1,0,0,114,35,0, 0,0,114,76,1,0,0,114,4,0,0,0,114,4,0,0, 0,114,5,0,0,0,218,20,95,112,97,116,104,95,105,109, - 112,111,114,116,101,114,95,99,97,99,104,101,56,7,0,0, + 112,111,114,116,101,114,95,99,97,99,104,101,55,7,0,0, 115,16,0,0,0,0,8,12,1,15,1,3,1,17,1,13, 1,15,1,18,1,122,31,80,97,116,104,70,105,110,100,101, 114,46,95,112,97,116,104,95,105,109,112,111,114,116,101,114, @@ -3375,7 +3375,7 @@ 114,158,0,0,0,114,76,1,0,0,114,169,0,0,0,114, 170,0,0,0,114,177,0,0,0,114,4,0,0,0,114,4, 0,0,0,114,5,0,0,0,218,16,95,108,101,103,97,99, - 121,95,103,101,116,95,115,112,101,99,73,7,0,0,115,18, + 121,95,103,101,116,95,115,112,101,99,72,7,0,0,115,18, 0,0,0,0,4,15,1,24,2,15,1,6,1,12,1,13, 1,15,1,9,1,122,27,80,97,116,104,70,105,110,100,101, 114,46,95,108,101,103,97,99,121,95,103,101,116,95,115,112, @@ -3411,7 +3411,7 @@ 97,109,101,115,112,97,99,101,95,112,97,116,104,90,5,101, 110,116,114,121,114,76,1,0,0,114,177,0,0,0,114,170, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,218,9,95,103,101,116,95,115,112,101,99,88,7,0, + 0,0,218,9,95,103,101,116,95,115,112,101,99,87,7,0, 0,115,40,0,0,0,0,5,6,1,13,1,21,1,6,1, 15,1,12,1,15,1,21,2,18,1,12,1,6,1,15,1, 4,1,9,1,12,1,15,5,20,2,15,1,9,1,122,20, @@ -3439,7 +3439,7 @@ 59,1,0,0,41,6,114,8,1,0,0,114,158,0,0,0, 114,35,0,0,0,114,9,1,0,0,114,177,0,0,0,114, 83,1,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,10,1,0,0,120,7,0,0,115,26,0,0, + 0,0,0,114,10,1,0,0,119,7,0,0,115,26,0,0, 0,0,4,12,1,12,1,21,1,12,1,4,1,15,1,9, 1,6,3,9,1,24,1,4,2,7,2,122,20,80,97,116, 104,70,105,110,100,101,114,46,102,105,110,100,95,115,112,101, @@ -3461,7 +3461,7 @@ 32,32,78,41,2,114,10,1,0,0,114,169,0,0,0,41, 4,114,8,1,0,0,114,158,0,0,0,114,35,0,0,0, 114,177,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,11,1,0,0,142,7,0,0,115,8,0, + 5,0,0,0,114,11,1,0,0,141,7,0,0,115,8,0, 0,0,0,8,18,1,12,1,4,1,122,22,80,97,116,104, 70,105,110,100,101,114,46,102,105,110,100,95,109,111,100,117, 108,101,41,12,114,57,0,0,0,114,56,0,0,0,114,58, @@ -3469,7 +3469,7 @@ 0,0,114,78,1,0,0,114,79,1,0,0,114,80,1,0, 0,114,84,1,0,0,114,10,1,0,0,114,11,1,0,0, 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,72,1,0,0,27,7,0,0,115,22,0, + 5,0,0,0,114,72,1,0,0,26,7,0,0,115,22,0, 0,0,12,2,6,2,18,8,18,17,18,17,18,15,3,1, 18,31,3,1,21,21,3,1,114,72,1,0,0,99,0,0, 0,0,0,0,0,0,0,0,0,0,3,0,0,0,64,0, @@ -3518,7 +3518,7 @@ 136,0,0,102,2,0,86,1,113,3,0,100,0,0,83,41, 1,78,114,4,0,0,0,41,2,114,22,0,0,0,114,56, 1,0,0,41,1,114,169,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,77,0,0,0,171,7,0,0,115,2,0, + 5,0,0,0,114,77,0,0,0,170,7,0,0,115,2,0, 0,0,6,0,122,38,70,105,108,101,70,105,110,100,101,114, 46,95,95,105,110,105,116,95,95,46,60,108,111,99,97,108, 115,62,46,60,103,101,110,101,120,112,114,62,114,116,0,0, @@ -3531,7 +3531,7 @@ 0,0,218,14,108,111,97,100,101,114,95,100,101,116,97,105, 108,115,90,7,108,111,97,100,101,114,115,114,127,0,0,0, 114,4,0,0,0,41,1,114,169,0,0,0,114,5,0,0, - 0,114,72,0,0,0,165,7,0,0,115,16,0,0,0,0, + 0,114,72,0,0,0,164,7,0,0,115,16,0,0,0,0, 4,6,1,19,1,36,1,9,2,15,1,9,1,12,1,122, 19,70,105,108,101,70,105,110,100,101,114,46,95,95,105,110, 105,116,95,95,99,1,0,0,0,0,0,0,0,1,0,0, @@ -3541,7 +3541,7 @@ 114,101,99,116,111,114,121,32,109,116,105,109,101,46,114,29, 0,0,0,78,114,138,0,0,0,41,1,114,87,1,0,0, 41,1,114,71,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,73,1,0,0,179,7,0,0,115, + 0,114,5,0,0,0,114,73,1,0,0,178,7,0,0,115, 2,0,0,0,0,2,122,28,70,105,108,101,70,105,110,100, 101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,97, 99,104,101,115,99,2,0,0,0,0,0,0,0,3,0,0, @@ -3565,7 +3565,7 @@ 32,32,78,41,3,114,10,1,0,0,114,169,0,0,0,114, 220,0,0,0,41,3,114,71,0,0,0,114,158,0,0,0, 114,177,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,165,0,0,0,185,7,0,0,115,8,0, + 5,0,0,0,114,165,0,0,0,184,7,0,0,115,8,0, 0,0,0,7,15,1,12,1,10,1,122,22,70,105,108,101, 70,105,110,100,101,114,46,102,105,110,100,95,108,111,97,100, 101,114,99,6,0,0,0,0,0,0,0,7,0,0,0,7, @@ -3577,7 +3577,7 @@ 243,0,0,0,114,158,0,0,0,114,35,0,0,0,114,228, 0,0,0,114,9,1,0,0,114,169,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,84,1,0, - 0,197,7,0,0,115,6,0,0,0,0,1,15,1,18,1, + 0,196,7,0,0,115,6,0,0,0,0,1,15,1,18,1, 122,20,70,105,108,101,70,105,110,100,101,114,46,95,103,101, 116,95,115,112,101,99,78,99,3,0,0,0,0,0,0,0, 14,0,0,0,15,0,0,0,67,0,0,0,115,240,1,0, @@ -3640,7 +3640,7 @@ 104,114,56,1,0,0,114,243,0,0,0,90,13,105,110,105, 116,95,102,105,108,101,110,97,109,101,90,9,102,117,108,108, 95,112,97,116,104,114,177,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,10,1,0,0,202,7, + 4,0,0,0,114,5,0,0,0,114,10,1,0,0,201,7, 0,0,115,68,0,0,0,0,3,6,1,19,1,3,1,34, 1,13,1,11,1,15,1,10,1,12,2,9,1,9,1,15, 2,9,1,6,2,12,1,18,1,22,1,10,1,15,1,12, @@ -3677,7 +3677,7 @@ 0,146,2,0,113,6,0,83,114,4,0,0,0,41,1,114, 139,0,0,0,41,2,114,22,0,0,0,90,2,102,110,114, 4,0,0,0,114,4,0,0,0,114,5,0,0,0,250,9, - 60,115,101,116,99,111,109,112,62,20,8,0,0,115,2,0, + 60,115,101,116,99,111,109,112,62,19,8,0,0,115,2,0, 0,0,9,0,122,41,70,105,108,101,70,105,110,100,101,114, 46,95,102,105,108,108,95,99,97,99,104,101,46,60,108,111, 99,97,108,115,62,46,60,115,101,116,99,111,109,112,62,78, @@ -3695,7 +3695,7 @@ 110,116,101,110,116,115,114,70,1,0,0,114,67,0,0,0, 114,64,1,0,0,114,56,1,0,0,90,8,110,101,119,95, 110,97,109,101,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,92,1,0,0,247,7,0,0,115,34,0,0, + 0,0,0,114,92,1,0,0,246,7,0,0,115,34,0,0, 0,0,2,9,1,3,1,31,1,22,3,11,3,18,1,18, 7,9,1,13,1,24,1,6,1,27,2,6,1,17,1,9, 1,18,1,122,22,70,105,108,101,70,105,110,100,101,114,46, @@ -3734,7 +3734,7 @@ 0,0,0,41,1,114,35,0,0,0,41,2,114,8,1,0, 0,114,91,1,0,0,114,4,0,0,0,114,5,0,0,0, 218,24,112,97,116,104,95,104,111,111,107,95,102,111,114,95, - 70,105,108,101,70,105,110,100,101,114,32,8,0,0,115,6, + 70,105,108,101,70,105,110,100,101,114,31,8,0,0,115,6, 0,0,0,0,2,12,1,21,1,122,54,70,105,108,101,70, 105,110,100,101,114,46,112,97,116,104,95,104,111,111,107,46, 60,108,111,99,97,108,115,62,46,112,97,116,104,95,104,111, @@ -3742,7 +3742,7 @@ 114,114,4,0,0,0,41,3,114,8,1,0,0,114,91,1, 0,0,114,98,1,0,0,114,4,0,0,0,41,2,114,8, 1,0,0,114,91,1,0,0,114,5,0,0,0,218,9,112, - 97,116,104,95,104,111,111,107,22,8,0,0,115,4,0,0, + 97,116,104,95,104,111,111,107,21,8,0,0,115,4,0,0, 0,0,10,21,6,122,20,70,105,108,101,70,105,110,100,101, 114,46,112,97,116,104,95,104,111,111,107,99,1,0,0,0, 0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,0, @@ -3751,7 +3751,7 @@ 110,100,101,114,40,123,33,114,125,41,41,2,114,47,0,0, 0,114,35,0,0,0,41,1,114,71,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,114,101,0,0, - 0,40,8,0,0,115,2,0,0,0,0,1,122,19,70,105, + 0,39,8,0,0,115,2,0,0,0,0,1,122,19,70,105, 108,101,70,105,110,100,101,114,46,95,95,114,101,112,114,95, 95,41,15,114,57,0,0,0,114,56,0,0,0,114,58,0, 0,0,114,59,0,0,0,114,72,0,0,0,114,73,1,0, @@ -3759,7 +3759,7 @@ 114,84,1,0,0,114,10,1,0,0,114,92,1,0,0,114, 15,1,0,0,114,99,1,0,0,114,101,0,0,0,114,4, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,85,1,0,0,156,7,0,0,115,20,0,0,0, + 0,0,114,85,1,0,0,155,7,0,0,115,20,0,0,0, 12,7,6,2,12,14,12,4,6,2,12,12,12,5,15,45, 12,31,18,18,114,85,1,0,0,99,0,0,0,0,0,0, 0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,46, @@ -3776,7 +3776,7 @@ 32,116,104,101,32,105,109,112,111,114,116,32,108,111,99,107, 46,78,41,2,114,106,0,0,0,114,3,1,0,0,41,1, 114,71,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,75,0,0,0,50,8,0,0,115,2,0, + 5,0,0,0,114,75,0,0,0,49,8,0,0,115,2,0, 0,0,0,2,122,28,95,73,109,112,111,114,116,76,111,99, 107,67,111,110,116,101,120,116,46,95,95,101,110,116,101,114, 95,95,99,4,0,0,0,0,0,0,0,4,0,0,0,1, @@ -3790,13 +3790,13 @@ 101,120,99,95,116,121,112,101,90,9,101,120,99,95,118,97, 108,117,101,90,13,101,120,99,95,116,114,97,99,101,98,97, 99,107,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,114,81,0,0,0,54,8,0,0,115,2,0,0,0,0, + 0,114,81,0,0,0,53,8,0,0,115,2,0,0,0,0, 2,122,27,95,73,109,112,111,114,116,76,111,99,107,67,111, 110,116,101,120,116,46,95,95,101,120,105,116,95,95,78,41, 6,114,57,0,0,0,114,56,0,0,0,114,58,0,0,0, 114,59,0,0,0,114,75,0,0,0,114,81,0,0,0,114, 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,100,1,0,0,46,8,0,0,115,6,0,0, + 0,0,0,114,100,1,0,0,45,8,0,0,115,6,0,0, 0,12,2,6,2,12,4,114,100,1,0,0,99,3,0,0, 0,0,0,0,0,5,0,0,0,4,0,0,0,67,0,0, 0,115,91,0,0,0,124,1,0,106,0,0,100,1,0,124, @@ -3818,7 +3818,7 @@ 112,97,99,107,97,103,101,218,5,108,101,118,101,108,90,4, 98,105,116,115,90,4,98,97,115,101,114,4,0,0,0,114, 4,0,0,0,114,5,0,0,0,218,13,95,114,101,115,111, - 108,118,101,95,110,97,109,101,59,8,0,0,115,10,0,0, + 108,118,101,95,110,97,109,101,58,8,0,0,115,10,0,0, 0,0,2,22,1,18,1,15,1,10,1,114,103,1,0,0, 99,3,0,0,0,0,0,0,0,4,0,0,0,3,0,0, 0,67,0,0,0,115,47,0,0,0,124,0,0,106,0,0, @@ -3829,7 +3829,7 @@ 67,0,0,0,114,35,0,0,0,114,169,0,0,0,114,4, 0,0,0,114,4,0,0,0,114,5,0,0,0,218,17,95, 102,105,110,100,95,115,112,101,99,95,108,101,103,97,99,121, - 68,8,0,0,115,8,0,0,0,0,3,18,1,12,1,4, + 67,8,0,0,115,8,0,0,0,0,3,18,1,12,1,4, 1,114,104,1,0,0,99,3,0,0,0,0,0,0,0,9, 0,0,0,27,0,0,0,67,0,0,0,115,34,1,0,0, 116,0,0,106,1,0,115,28,0,116,2,0,106,3,0,100, @@ -3862,7 +3862,7 @@ 100,114,76,1,0,0,114,10,1,0,0,114,177,0,0,0, 114,179,0,0,0,114,208,0,0,0,114,4,0,0,0,114, 4,0,0,0,114,5,0,0,0,218,10,95,102,105,110,100, - 95,115,112,101,99,77,8,0,0,115,48,0,0,0,0,2, + 95,115,112,101,99,76,8,0,0,115,48,0,0,0,0,2, 9,1,19,4,15,1,16,1,10,1,3,1,13,1,13,1, 18,1,12,1,11,2,24,1,12,2,22,1,13,1,3,1, 13,1,13,4,9,2,12,1,4,2,7,2,11,2,114,106, @@ -3899,7 +3899,7 @@ 121,115,116,101,109,69,114,114,111,114,41,4,114,67,0,0, 0,114,101,1,0,0,114,102,1,0,0,114,171,0,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218, - 13,95,115,97,110,105,116,121,95,99,104,101,99,107,117,8, + 13,95,115,97,110,105,116,121,95,99,104,101,99,107,116,8, 0,0,115,24,0,0,0,0,2,15,1,30,1,12,1,15, 1,6,1,15,1,15,1,15,1,6,2,27,1,19,1,114, 109,1,0,0,122,16,78,111,32,109,111,100,117,108,101,32, @@ -3938,7 +3938,7 @@ 114,177,0,0,0,114,179,0,0,0,114,4,0,0,0,114, 4,0,0,0,114,5,0,0,0,218,23,95,102,105,110,100, 95,97,110,100,95,108,111,97,100,95,117,110,108,111,99,107, - 101,100,137,8,0,0,115,42,0,0,0,0,1,6,1,19, + 101,100,136,8,0,0,115,42,0,0,0,0,1,6,1,19, 1,6,1,15,1,16,2,15,1,11,1,13,1,3,1,13, 1,13,1,22,1,26,1,15,1,12,1,30,2,18,1,6, 2,13,1,32,1,114,112,1,0,0,99,2,0,0,0,0, @@ -3952,7 +3952,7 @@ 107,46,78,41,2,114,103,0,0,0,114,112,1,0,0,41, 2,114,67,0,0,0,114,111,1,0,0,114,4,0,0,0, 114,4,0,0,0,114,5,0,0,0,218,14,95,102,105,110, - 100,95,97,110,100,95,108,111,97,100,164,8,0,0,115,4, + 100,95,97,110,100,95,108,111,97,100,163,8,0,0,115,4, 0,0,0,0,2,13,1,114,113,1,0,0,99,3,0,0, 0,0,0,0,0,5,0,0,0,4,0,0,0,67,0,0, 0,115,172,0,0,0,116,0,0,124,0,0,124,1,0,124, @@ -3996,7 +3996,7 @@ 0,114,112,0,0,0,41,5,114,67,0,0,0,114,101,1, 0,0,114,102,1,0,0,114,179,0,0,0,114,151,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,114,1,0,0,170,8,0,0,115,26,0,0,0,0,9, + 114,114,1,0,0,169,8,0,0,115,26,0,0,0,0,9, 16,1,12,1,21,1,10,1,15,1,13,1,13,1,12,1, 10,2,15,1,21,1,10,1,114,114,1,0,0,99,3,0, 0,0,0,0,0,0,6,0,0,0,17,0,0,0,67,0, @@ -4043,7 +4043,7 @@ 90,9,102,114,111,109,95,110,97,109,101,114,37,1,0,0, 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218, 16,95,104,97,110,100,108,101,95,102,114,111,109,108,105,115, - 116,194,8,0,0,115,34,0,0,0,0,10,15,1,12,1, + 116,193,8,0,0,115,34,0,0,0,0,10,15,1,12,1, 12,1,13,1,15,1,22,1,13,1,15,1,21,1,3,1, 17,1,18,4,21,1,15,1,9,1,32,1,114,120,1,0, 0,99,1,0,0,0,0,0,0,0,2,0,0,0,2,0, @@ -4068,7 +4068,7 @@ 114,93,0,0,0,114,32,0,0,0,41,2,218,7,103,108, 111,98,97,108,115,114,101,1,0,0,114,4,0,0,0,114, 4,0,0,0,114,5,0,0,0,218,17,95,99,97,108,99, - 95,95,95,112,97,99,107,97,103,101,95,95,226,8,0,0, + 95,95,95,112,97,99,107,97,103,101,95,95,225,8,0,0, 115,12,0,0,0,0,7,15,1,12,1,10,1,12,1,25, 1,114,122,1,0,0,99,0,0,0,0,0,0,0,0,3, 0,0,0,3,0,0,0,67,0,0,0,115,55,0,0,0, @@ -4088,7 +4088,7 @@ 90,10,101,120,116,101,110,115,105,111,110,115,90,6,115,111, 117,114,99,101,90,8,98,121,116,101,99,111,100,101,114,4, 0,0,0,114,4,0,0,0,114,5,0,0,0,114,240,0, - 0,0,241,8,0,0,115,8,0,0,0,0,5,18,1,12, + 0,0,240,8,0,0,115,8,0,0,0,0,5,18,1,12, 1,12,1,114,240,0,0,0,99,5,0,0,0,0,0,0, 0,9,0,0,0,5,0,0,0,67,0,0,0,115,227,0, 0,0,124,4,0,100,1,0,107,2,0,114,27,0,116,0, @@ -4143,7 +4143,7 @@ 114,102,1,0,0,114,179,0,0,0,90,8,103,108,111,98, 97,108,115,95,114,101,1,0,0,90,7,99,117,116,95,111, 102,102,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,10,95,95,105,109,112,111,114,116,95,95,252,8,0, + 0,218,10,95,95,105,109,112,111,114,116,95,95,251,8,0, 0,115,26,0,0,0,0,11,12,1,15,2,24,1,12,1, 18,1,6,3,12,1,23,1,6,1,4,4,35,3,40,2, 114,125,1,0,0,99,1,0,0,0,0,0,0,0,3,0, @@ -4159,7 +4159,7 @@ 0,0,0,114,177,0,0,0,114,178,0,0,0,114,4,0, 0,0,114,4,0,0,0,114,5,0,0,0,218,18,95,98, 117,105,108,116,105,110,95,102,114,111,109,95,110,97,109,101, - 31,9,0,0,115,10,0,0,0,0,1,15,1,12,1,19, + 30,9,0,0,115,10,0,0,0,0,1,15,1,12,1,19, 1,12,1,114,126,1,0,0,99,2,0,0,0,0,0,0, 0,19,0,0,0,12,0,0,0,67,0,0,0,115,232,2, 0,0,124,1,0,97,0,0,124,0,0,97,1,0,116,1, @@ -4233,7 +4233,7 @@ 0,107,2,0,86,1,113,3,0,100,1,0,83,41,2,114, 29,0,0,0,78,41,1,114,31,0,0,0,41,2,114,22, 0,0,0,114,130,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,114,77,0,0,0,83,9,0,0, + 0,0,114,5,0,0,0,114,77,0,0,0,82,9,0,0, 115,2,0,0,0,6,0,122,25,95,115,101,116,117,112,46, 60,108,111,99,97,108,115,62,46,60,103,101,110,101,120,112, 114,62,114,84,0,0,0,122,30,105,109,112,111,114,116,108, @@ -4269,7 +4269,7 @@ 101,97,107,114,101,102,95,109,111,100,117,108,101,90,13,119, 105,110,114,101,103,95,109,111,100,117,108,101,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,6,95,115,101, - 116,117,112,39,9,0,0,115,108,0,0,0,0,9,6,1, + 116,117,112,38,9,0,0,115,108,0,0,0,0,9,6,1, 6,2,12,1,9,2,6,3,12,1,28,1,15,1,15,1, 9,1,15,1,9,2,3,1,15,1,12,1,20,3,13,1, 13,1,15,1,15,2,13,1,20,3,33,1,19,2,31,1, @@ -4299,7 +4299,7 @@ 134,1,0,0,90,17,115,117,112,112,111,114,116,101,100,95, 108,111,97,100,101,114,115,114,4,0,0,0,114,4,0,0, 0,114,5,0,0,0,218,8,95,105,110,115,116,97,108,108, - 126,9,0,0,115,16,0,0,0,0,2,13,1,9,1,28, + 125,9,0,0,115,16,0,0,0,0,2,13,1,9,1,28, 1,16,1,16,1,15,1,19,1,114,136,1,0,0,41,3, 122,3,119,105,110,114,1,0,0,0,114,2,0,0,0,41, 91,114,59,0,0,0,114,10,0,0,0,114,11,0,0,0, @@ -4337,7 +4337,7 @@ 115,168,0,0,0,6,17,6,3,12,12,12,5,12,5,12, 6,12,12,12,10,12,9,12,5,12,7,15,22,12,8,12, 4,15,4,19,20,6,2,6,3,22,4,19,68,19,21,19, - 19,12,19,12,20,12,115,22,1,18,2,6,2,9,2,9, + 19,12,19,12,20,12,114,22,1,18,2,6,2,9,2,9, 1,9,2,15,27,12,23,12,19,12,12,18,8,12,18,12, 11,12,11,12,17,12,16,21,55,21,12,18,10,12,14,12, 36,19,27,19,106,24,22,9,3,12,1,15,63,18,45,19, diff -r ce070040e1a6 -r d7f128afe9db Python/opcode_targets.h --- a/Python/opcode_targets.h Sat May 10 13:24:58 2014 -0400 +++ b/Python/opcode_targets.h Sun Mar 23 09:44:28 2014 +0100 @@ -15,8 +15,8 @@ &&_unknown_opcode, &&_unknown_opcode, &&TARGET_UNARY_INVERT, - &&TARGET_BINARY_MATRIX_MULTIPLY, - &&TARGET_INPLACE_MATRIX_MULTIPLY, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&TARGET_BINARY_POWER, &&TARGET_BINARY_MULTIPLY, diff -r ce070040e1a6 -r d7f128afe9db Python/pythonrun.c --- a/Python/pythonrun.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/pythonrun.c Sun Mar 23 09:44:28 2014 +0100 @@ -35,10 +35,6 @@ #define PATH_MAX MAXPATHLEN #endif -#ifdef __gnu_hurd__ -#define PATH_MAX MAXPATHLEN -#endif - _Py_IDENTIFIER(builtins); _Py_IDENTIFIER(excepthook); _Py_IDENTIFIER(flush); diff -r ce070040e1a6 -r d7f128afe9db Python/random.c --- a/Python/random.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/random.c Sun Mar 23 09:44:28 2014 +0100 @@ -3,9 +3,6 @@ #include #else #include -#ifdef HAVE_SYS_STAT_H -#include -#endif #endif #ifdef Py_DEBUG @@ -15,6 +12,8 @@ #endif #ifdef MS_WINDOWS +/* This handle is never explicitly released. Instead, the operating + system will release it when the process terminates. */ static HCRYPTPROV hCryptProv = 0; static int @@ -70,11 +69,7 @@ #ifndef MS_WINDOWS -static struct { - int fd; - dev_t st_dev; - ino_t st_ino; -} urandom_cache = { -1 }; +static int urandom_fd = -1; /* Read size bytes from /dev/urandom into buffer. Call Py_FatalError() on error. */ @@ -114,24 +109,12 @@ { int fd; Py_ssize_t n; - struct stat st; if (size <= 0) return 0; - if (urandom_cache.fd >= 0) { - /* Does the fd point to the same thing as before? (issue #21207) */ - if (fstat(urandom_cache.fd, &st) - || st.st_dev != urandom_cache.st_dev - || st.st_ino != urandom_cache.st_ino) { - /* Something changed: forget the cached fd (but don't close it, - since it probably points to something important for some - third-party code). */ - urandom_cache.fd = -1; - } - } - if (urandom_cache.fd >= 0) - fd = urandom_cache.fd; + if (urandom_fd >= 0) + fd = urandom_fd; else { Py_BEGIN_ALLOW_THREADS fd = _Py_open("/dev/urandom", O_RDONLY); @@ -146,24 +129,14 @@ PyErr_SetFromErrno(PyExc_OSError); return -1; } - if (urandom_cache.fd >= 0) { + if (urandom_fd >= 0) { /* urandom_fd was initialized by another thread while we were not holding the GIL, keep it. */ close(fd); - fd = urandom_cache.fd; + fd = urandom_fd; } - else { - if (fstat(fd, &st)) { - PyErr_SetFromErrno(PyExc_OSError); - close(fd); - return -1; - } - else { - urandom_cache.fd = fd; - urandom_cache.st_dev = st.st_dev; - urandom_cache.st_ino = st.st_ino; - } - } + else + urandom_fd = fd; } Py_BEGIN_ALLOW_THREADS @@ -195,9 +168,9 @@ static void dev_urandom_close(void) { - if (urandom_cache.fd >= 0) { - close(urandom_cache.fd); - urandom_cache.fd = -1; + if (urandom_fd >= 0) { + close(urandom_fd); + urandom_fd = -1; } } @@ -296,12 +269,7 @@ void _PyRandom_Fini(void) { -#ifdef MS_WINDOWS - if (hCryptProv) { - CryptReleaseContext(hCryptProv, 0); - hCryptProv = 0; - } -#else +#ifndef MS_WINDOWS dev_urandom_close(); #endif } diff -r ce070040e1a6 -r d7f128afe9db Python/sysmodule.c --- a/Python/sysmodule.c Sat May 10 13:24:58 2014 -0400 +++ b/Python/sysmodule.c Sun Mar 23 09:44:28 2014 +0100 @@ -1622,7 +1622,6 @@ _PySys_Init(void) { PyObject *m, *sysdict, *version_info; - int res; m = PyModule_Create(&sysmodule); if (m == NULL) @@ -1630,6 +1629,7 @@ sysdict = PyModule_GetDict(m); #define SET_SYS_FROM_STRING_BORROW(key, value) \ do { \ + int res; \ PyObject *v = (value); \ if (v == NULL) \ return NULL; \ @@ -1640,6 +1640,7 @@ } while (0) #define SET_SYS_FROM_STRING(key, value) \ do { \ + int res; \ PyObject *v = (value); \ if (v == NULL) \ return NULL; \ @@ -1758,9 +1759,6 @@ /* prevent user from creating new instances */ VersionInfoType.tp_init = NULL; VersionInfoType.tp_new = NULL; - res = PyDict_DelItemString(VersionInfoType.tp_dict, "__new__"); - if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) - PyErr_Clear(); /* implementation */ SET_SYS_FROM_STRING("implementation", make_impl_info(version_info)); @@ -1774,9 +1772,7 @@ /* prevent user from creating new instances */ FlagsType.tp_init = NULL; FlagsType.tp_new = NULL; - res = PyDict_DelItemString(FlagsType.tp_dict, "__new__"); - if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) - PyErr_Clear(); + #if defined(MS_WINDOWS) /* getwindowsversion */ @@ -1787,9 +1783,6 @@ /* prevent user from creating new instances */ WindowsVersionType.tp_init = NULL; WindowsVersionType.tp_new = NULL; - res = PyDict_DelItemString(WindowsVersionType.tp_dict, "__new__"); - if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) - PyErr_Clear(); #endif /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */ @@ -1806,7 +1799,6 @@ #endif #undef SET_SYS_FROM_STRING -#undef SET_SYS_FROM_STRING_BORROW if (PyErr_Occurred()) return NULL; return m; diff -r ce070040e1a6 -r d7f128afe9db Python/thread_foobar.h --- a/Python/thread_foobar.h Sat May 10 13:24:58 2014 -0400 +++ b/Python/thread_foobar.h Sun Mar 23 09:44:28 2014 +0100 @@ -1,3 +1,4 @@ + /* * Initialization. */ @@ -60,18 +61,10 @@ int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) { - return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, 0); -} - -PyLockStatus -PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds, - int intr_flag) -{ int success; - dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n", lock, microseconds, intr_flag)); - dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n", - lock, microseconds, intr_flag, success)); + dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); + dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } @@ -80,53 +73,3 @@ { dprintf(("PyThread_release_lock(%p) called\n", lock)); } - -/* The following are only needed if native TLS support exists */ -#define Py_HAVE_NATIVE_TLS - -#ifdef Py_HAVE_NATIVE_TLS -int -PyThread_create_key(void) -{ - int result; - return result; -} - -void -PyThread_delete_key(int key) -{ - -} - -int -PyThread_set_key_value(int key, void *value) -{ - int ok; - - /* A failure in this case returns -1 */ - if (!ok) - return -1; - return 0; -} - -void * -PyThread_get_key_value(int key) -{ - void *result; - - return result; -} - -void -PyThread_delete_key_value(int key) -{ - -} - -void -PyThread_ReInitTLS(void) -{ - -} - -#endif diff -r ce070040e1a6 -r d7f128afe9db Python/thread_nt.h --- a/Python/thread_nt.h Sat May 10 13:24:58 2014 -0400 +++ b/Python/thread_nt.h Sun Mar 23 09:44:28 2014 +0100 @@ -77,7 +77,7 @@ /* wait at least until the target */ DWORD now, target = GetTickCount() + milliseconds; while (mutex->locked) { - if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, (PY_LONG_LONG)milliseconds*1000) < 0) { + if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, milliseconds*1000) < 0) { result = WAIT_FAILED; break; } diff -r ce070040e1a6 -r d7f128afe9db Tools/buildbot/external-common.bat --- a/Tools/buildbot/external-common.bat Sat May 10 13:24:58 2014 -0400 +++ b/Tools/buildbot/external-common.bat Sun Mar 23 09:44:28 2014 +0100 @@ -14,7 +14,7 @@ @rem if exist tk8.4.16 rd /s/q tk8.4.16 @rem if exist tk-8.4.18.1 rd /s/q tk-8.4.18.1 @rem if exist db-4.4.20 rd /s/q db-4.4.20 -@rem if exist openssl-1.0.1e rd /s/q openssl-1.0.1g +@rem if exist openssl-1.0.1e rd /s/q openssl-1.0.1e @rem if exist sqlite-3.7.12 rd /s/q sqlite-3.7.12 @rem bzip @@ -24,9 +24,9 @@ ) @rem OpenSSL -if not exist openssl-1.0.1g ( - rd /s/q openssl-1.0.1e - svn export http://svn.python.org/projects/external/openssl-1.0.1g +if not exist openssl-1.0.1e ( + rd /s/q openssl-1.0.1d + svn export http://svn.python.org/projects/external/openssl-1.0.1e ) @rem tcl/tk/tix diff -r ce070040e1a6 -r d7f128afe9db Tools/buildbot/test-amd64.bat --- a/Tools/buildbot/test-amd64.bat Sat May 10 13:24:58 2014 -0400 +++ b/Tools/buildbot/test-amd64.bat Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,3 @@ @rem Used by the buildbot "test" step. - -rem The following line should be removed before #20035 is closed -set TCL_LIBRARY=%CD%\..\tcltk64\lib\tcl8.6 cd PCbuild call rt.bat -d -q -x64 -uall -rwW -n --timeout=3600 %1 %2 %3 %4 %5 %6 %7 %8 %9 diff -r ce070040e1a6 -r d7f128afe9db Tools/buildbot/test.bat --- a/Tools/buildbot/test.bat Sat May 10 13:24:58 2014 -0400 +++ b/Tools/buildbot/test.bat Sun Mar 23 09:44:28 2014 +0100 @@ -1,6 +1,3 @@ @rem Used by the buildbot "test" step. - -rem The following line should be removed before #20035 is closed -set TCL_LIBRARY=%CD%\..\tcltk\lib\tcl8.6 cd PCbuild call rt.bat -d -q -uall -rwW -n --timeout=3600 %1 %2 %3 %4 %5 %6 %7 %8 %9 diff -r ce070040e1a6 -r d7f128afe9db Tools/freeze/freeze.py --- a/Tools/freeze/freeze.py Sat May 10 13:24:58 2014 -0400 +++ b/Tools/freeze/freeze.py Sun Mar 23 09:44:28 2014 +0100 @@ -219,7 +219,6 @@ # locations derived from options version = sys.version[:3] - flagged_version = version + sys.abiflags if win: extensions_c = 'frozen_extensions.c' if ishome: @@ -234,11 +233,10 @@ frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') else: binlib = os.path.join(exec_prefix, - 'lib', 'python%s' % version, - 'config-%s' % flagged_version) - incldir = os.path.join(prefix, 'include', 'python%s' % flagged_version) + 'lib', 'python%s' % version, 'config') + incldir = os.path.join(prefix, 'include', 'python%s' % version) config_h_dir = os.path.join(exec_prefix, 'include', - 'python%s' % flagged_version) + 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') @@ -365,10 +363,6 @@ else: mf.load_file(mod) - # Alias "importlib._bootstrap" to "_frozen_importlib" so that the - # import machinery can bootstrap. - mf.modules["_frozen_importlib"] = mf.modules["importlib._bootstrap"] - # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) @@ -461,7 +455,7 @@ cflags = ['$(OPT)'] cppflags = defines + includes - libs = [os.path.join(binlib, '$(LDLIBRARY)')] + libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): diff -r ce070040e1a6 -r d7f128afe9db Tools/freeze/makeconfig.py --- a/Tools/freeze/makeconfig.py Sat May 10 13:24:58 2014 -0400 +++ b/Tools/freeze/makeconfig.py Sun Mar 23 09:44:28 2014 +0100 @@ -3,7 +3,7 @@ # Write the config.c file -never = ['marshal', '_imp', '_ast', '__main__', 'builtins', +never = ['marshal', 'imp', '_ast', '__main__', 'builtins', 'sys', 'gc', '_warnings'] def makeconfig(infp, outfp, modules, with_ifdef=0): diff -r ce070040e1a6 -r d7f128afe9db Tools/freeze/test/Makefile --- a/Tools/freeze/test/Makefile Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -# Makefile to test freeze -# set PYTHON to path of Python interpreter to test -PYTHON=python -# set OUTDIR to the temp directory for freeze -OUTDIR=outdir - -test: - $(PYTHON) ../freeze.py -o $(OUTDIR) ok.py - make -C $(OUTDIR) - $(OUTDIR)/ok - diff -r ce070040e1a6 -r d7f128afe9db Tools/freeze/test/ok.py --- a/Tools/freeze/test/ok.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -import sys -sys.exit(0) diff -r ce070040e1a6 -r d7f128afe9db Tools/msi/msi.py --- a/Tools/msi/msi.py Sat May 10 13:24:58 2014 -0400 +++ b/Tools/msi/msi.py Sun Mar 23 09:44:28 2014 +0100 @@ -925,8 +925,8 @@ shutil.copyfileobj(open("crtlicense.txt"), out) for name, pat, file in (("bzip2","bzip2-*", "LICENSE"), ("openssl", "openssl-*", "LICENSE"), - ("Tcl", "tcl-8*", "license.terms"), - ("Tk", "tk-8*", "license.terms"), + ("Tcl", "tcl8*", "license.terms"), + ("Tk", "tk8*", "license.terms"), ("Tix", "tix-*", "license.terms")): out.write("\nThis copy of Python includes a copy of %s, which is licensed under the following terms:\n\n" % name) dirs = glob.glob(srcdir+"/../"+pat) diff -r ce070040e1a6 -r d7f128afe9db Tools/parser/unparse.py --- a/Tools/parser/unparse.py Sat May 10 13:24:58 2014 -0400 +++ b/Tools/parser/unparse.py Sun Mar 23 09:44:28 2014 +0100 @@ -401,7 +401,7 @@ self.dispatch(t.operand) self.write(")") - binop = { "Add":"+", "Sub":"-", "Mult":"*", "MatMult":"@", "Div":"/", "Mod":"%", + binop = { "Add":"+", "Sub":"-", "Mult":"*", "Div":"/", "Mod":"%", "LShift":"<<", "RShift":">>", "BitOr":"|", "BitXor":"^", "BitAnd":"&", "FloorDiv":"//", "Pow": "**"} def _BinOp(self, t): diff -r ce070040e1a6 -r d7f128afe9db Tools/scripts/generate_opcode_h.py --- a/Tools/scripts/generate_opcode_h.py Sat May 10 13:24:58 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -# This script generates the opcode.h header file. - -from __future__ import with_statement - -import sys -header = """/* Auto-generated by Tools/scripts/generate_opcode_h.py */ -#ifndef Py_OPCODE_H -#define Py_OPCODE_H -#ifdef __cplusplus -extern "C" { -#endif - - - /* Instruction opcodes for compiled code */ -""" - -footer = """ -/* EXCEPT_HANDLER is a special, implicit block type which is created when - entering an except handler. It is not an opcode but we define it here - as we want it to be available to both frameobject.c and ceval.c, while - remaining private.*/ -#define EXCEPT_HANDLER 257 - - -enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, - PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, - PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; - -#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OPCODE_H */ -""" - - -def main(opcode_py, outfile='Include/opcode.h'): - opcode = {} - exec(open(opcode_py).read(), opcode) - opmap = opcode['opmap'] - with open(outfile, 'w') as fobj: - fobj.write(header) - for name in opcode['opname']: - if name in opmap: - fobj.write("#define %-20s\t%-3s\n" % (name, opmap[name])) - if name == 'POP_EXCEPT': # Special entry for HAVE_ARGUMENT - fobj.write("#define %-20s\t%-3d\n" % - ('HAVE_ARGUMENT', opcode['HAVE_ARGUMENT'])) - fobj.write(footer) - - -if __name__ == '__main__': - main(sys.argv[1], sys.argv[2]) diff -r ce070040e1a6 -r d7f128afe9db Tools/scripts/run_tests.py --- a/Tools/scripts/run_tests.py Sat May 10 13:24:58 2014 -0400 +++ b/Tools/scripts/run_tests.py Sun Mar 23 09:44:28 2014 +0100 @@ -33,6 +33,8 @@ # Allow user-specified interpreter options to override our defaults. args.extend(test.support.args_from_interpreter_flags()) + # Workaround for issue #20355 + os.environ.pop("PYTHONWARNINGS", None) # Workaround for issue #20361 args.extend(['-W', 'error::BytesWarning']) diff -r ce070040e1a6 -r d7f128afe9db configure --- a/configure Sat May 10 13:24:58 2014 -0400 +++ b/configure Sun Mar 23 09:44:28 2014 +0100 @@ -670,7 +670,6 @@ INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -OPCODEHGEN PYTHON ASDLGEN ac_ct_READELF @@ -796,7 +795,6 @@ enable_profiling with_pydebug with_hash_algorithm -with_address_sanitizer with_libs with_system_expat with_system_ffi @@ -1473,8 +1471,6 @@ --with-pydebug build with Py_DEBUG defined --with-hash-algorithm=[fnv|siphash24] select hash algorithm - --with-address-sanitizer - enable AddressSanitizer --with-libs='lib1 ...' link against additional libs --with-system-expat build pyexpat module using an installed expat library @@ -5609,7 +5605,7 @@ if test "$enable_framework" then LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}} + RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" BLDLIBRARY='' else BLDLIBRARY='$(LDLIBRARY)' @@ -5629,7 +5625,7 @@ SunOS*) LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} INSTSONAME="$LDLIBRARY".$SOVERSION if test "$with_pydebug" != yes then @@ -5639,7 +5635,7 @@ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-L. -lpython$(LDVERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} case $ac_sys_system in FreeBSD*) SOVERSION=`echo $SOVERSION|cut -d "." -f 1` @@ -5661,16 +5657,16 @@ ;; esac BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' - RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} + RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ;; Darwin*) LDLIBRARY='libpython$(LDVERSION).dylib' BLDLIBRARY='-L. -lpython$(LDVERSION)' - RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} + RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' ;; AIX*) LDLIBRARY='libpython$(LDVERSION).so' - RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}} + RUNSHARED=LIBPATH=`pwd`:${LIBPATH} ;; esac @@ -6052,57 +6048,6 @@ fi -for ac_prog in python$PACKAGE_VERSION python3 python -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PYTHON+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PYTHON"; then - ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_PYTHON="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PYTHON=$ac_cv_prog_PYTHON -if test -n "$PYTHON"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 -$as_echo "$PYTHON" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$PYTHON" && break -done -test -n "$PYTHON" || PYTHON="not-found" - -if test "$PYTHON" = not-found; then - OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py" -else - OPCODEHGEN="$PYTHON" -fi - - - case $MACHDEP in bsdos*|hp*|HP*) # install -d does not work on BSDI or HP-UX @@ -7024,9 +6969,11 @@ fi -for ac_header in asm/types.h conio.h direct.h dlfcn.h errno.h \ +ac_save_cppflags="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" +for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ +ieeefp.h io.h langinfo.h libintl.h ncurses.h process.h pthread.h \ sched.h shadow.h signal.h stdint.h stropts.h termios.h \ unistd.h utime.h \ poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ @@ -7050,6 +6997,7 @@ done +CPPFLAGS=$ac_save_cppflags ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` @@ -7286,6 +7234,26 @@ done + +# On Solaris, term.h requires curses.h +for ac_header in term.h +do : + ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " +#ifdef HAVE_CURSES_H +#include +#endif + +" +if test "x$ac_cv_header_term_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_TERM_H 1 +_ACEOF + +fi + +done + + # On Linux, netlink.h requires asm/types.h for ac_header in linux/netlink.h do : @@ -9157,23 +9125,6 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-address-sanitizer" >&5 -$as_echo_n "checking for --with-address-sanitizer... " >&6; } - -# Check whether --with-address_sanitizer was given. -if test "${with_address_sanitizer+set}" = set; then : - withval=$with_address_sanitizer; -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 -$as_echo "$withval" >&6; } -BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" -LDFLAGS="-fsanitize=address $LDFLAGS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for t_open in -lnsl" >&5 $as_echo_n "checking for t_open in -lnsl... " >&6; } @@ -13241,38 +13192,6 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use gcc inline assembler to get and set mc68881 fpcr" >&5 -$as_echo_n "checking whether we can use gcc inline assembler to get and set mc68881 fpcr... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - unsigned int fpcr; - __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr)); - __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr)); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_gcc_asm_for_mc68881=yes -else - have_gcc_asm_for_mc68881=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_asm_for_mc68881" >&5 -$as_echo "$have_gcc_asm_for_mc68881" >&6; } -if test "$have_gcc_asm_for_mc68881" = yes -then - -$as_echo "#define HAVE_GCC_ASM_FOR_MC68881 1" >>confdefs.h - -fi - # Detect whether system arithmetic is subject to x87-style double # rounding issues. The result of this test has little meaning on non # IEEE 754 platforms. On IEEE 754, test should return 1 if rounding @@ -14758,43 +14677,8 @@ fi -# first curses header check ac_save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -for ac_header in curses.h ncurses.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# On Solaris, term.h requires curses.h -for ac_header in term.h -do : - ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " -#ifdef HAVE_CURSES_H -#include -#endif - -" -if test "x$ac_cv_header_term_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_TERM_H 1 -_ACEOF - -fi - -done - - # On HP/UX 11.0, mvwdelch is a block with a return statement { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mvwdelch is an expression" >&5 $as_echo_n "checking whether mvwdelch is an expression... " >&6; } diff -r ce070040e1a6 -r d7f128afe9db configure.ac --- a/configure.ac Sat May 10 13:24:58 2014 -0400 +++ b/configure.ac Sun Mar 23 09:44:28 2014 +0100 @@ -928,7 +928,7 @@ if test "$enable_framework" then LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}} + RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" BLDLIBRARY='' else BLDLIBRARY='$(LDLIBRARY)' @@ -946,7 +946,7 @@ SunOS*) LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} INSTSONAME="$LDLIBRARY".$SOVERSION if test "$with_pydebug" != yes then @@ -956,7 +956,7 @@ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-L. -lpython$(LDVERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} case $ac_sys_system in FreeBSD*) SOVERSION=`echo $SOVERSION|cut -d "." -f 1` @@ -978,16 +978,16 @@ ;; esac BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' - RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} + RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ;; Darwin*) LDLIBRARY='libpython$(LDVERSION).dylib' BLDLIBRARY='-L. -lpython$(LDVERSION)' - RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} + RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' ;; AIX*) LDLIBRARY='libpython$(LDVERSION).so' - RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}} + RUNSHARED=LIBPATH=`pwd`:${LIBPATH} ;; esac @@ -1036,15 +1036,6 @@ ASDLGEN="$PYTHON" fi -AC_SUBST(OPCODEHGEN) -AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found) -if test "$PYTHON" = not-found; then - OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py" -else - OPCODEHGEN="$PYTHON" -fi - - case $MACHDEP in bsdos*|hp*|HP*) @@ -1555,9 +1546,11 @@ # checks for header files AC_HEADER_STDC -AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \ +ac_save_cppflags="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" +AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ +ieeefp.h io.h langinfo.h libintl.h ncurses.h process.h pthread.h \ sched.h shadow.h signal.h stdint.h stropts.h termios.h \ unistd.h utime.h \ poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ @@ -1569,6 +1562,7 @@ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h endian.h \ sys/endian.h) +CPPFLAGS=$ac_save_cppflags AC_HEADER_DIRENT AC_HEADER_MAJOR @@ -1588,6 +1582,14 @@ #endif ]) + +# On Solaris, term.h requires curses.h +AC_CHECK_HEADERS(term.h,,,[ +#ifdef HAVE_CURSES_H +#include +#endif +]) + # On Linux, netlink.h requires asm/types.h AC_CHECK_HEADERS(linux/netlink.h,,,[ #ifdef HAVE_ASM_TYPES_H @@ -2314,17 +2316,6 @@ ], [AC_MSG_RESULT(default)]) -AC_MSG_CHECKING(for --with-address-sanitizer) -AC_ARG_WITH(address_sanitizer, - AS_HELP_STRING([--with-address-sanitizer], - [enable AddressSanitizer]), -[ -AC_MSG_RESULT($withval) -BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" -LDFLAGS="-fsanitize=address $LDFLAGS" -], -[AC_MSG_RESULT(no)]) - # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets @@ -3810,19 +3801,6 @@ [Define if we can use gcc inline assembler to get and set x87 control word]) fi -AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set mc68881 fpcr) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ - unsigned int fpcr; - __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr)); - __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr)); -]])],[have_gcc_asm_for_mc68881=yes],[have_gcc_asm_for_mc68881=no]) -AC_MSG_RESULT($have_gcc_asm_for_mc68881) -if test "$have_gcc_asm_for_mc68881" = yes -then - AC_DEFINE(HAVE_GCC_ASM_FOR_MC68881, 1, - [Define if we can use gcc inline assembler to get and set mc68881 fpcr]) -fi - # Detect whether system arithmetic is subject to x87-style double # rounding issues. The result of this test has little meaning on non # IEEE 754 platforms. On IEEE 754, test should return 1 if rounding @@ -4413,19 +4391,8 @@ [Define if you have struct stat.st_mtimensec]) fi -# first curses header check ac_save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -AC_CHECK_HEADERS(curses.h ncurses.h) - -# On Solaris, term.h requires curses.h -AC_CHECK_HEADERS(term.h,,,[ -#ifdef HAVE_CURSES_H -#include -#endif -]) - # On HP/UX 11.0, mvwdelch is a block with a return statement AC_MSG_CHECKING(whether mvwdelch is an expression) AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, diff -r ce070040e1a6 -r d7f128afe9db pyconfig.h.in --- a/pyconfig.h.in Sat May 10 13:24:58 2014 -0400 +++ b/pyconfig.h.in Sun Mar 23 09:44:28 2014 +0100 @@ -313,9 +313,6 @@ /* Define to 1 if you have the `gamma' function. */ #undef HAVE_GAMMA -/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ -#undef HAVE_GCC_ASM_FOR_MC68881 - /* Define if we can use x64 gcc inline assembler */ #undef HAVE_GCC_ASM_FOR_X64 diff -r ce070040e1a6 -r d7f128afe9db setup.py --- a/setup.py Sat May 10 13:24:58 2014 -0400 +++ b/setup.py Sun Mar 23 09:44:28 2014 +0100 @@ -167,7 +167,6 @@ def __init__(self, dist): build_ext.__init__(self, dist) self.failed = [] - self.failed_on_import = [] def build_extensions(self): @@ -248,9 +247,8 @@ build_ext.build_extensions(self) longest = max([len(e.name) for e in self.extensions]) - if self.failed or self.failed_on_import: - all_failed = self.failed + self.failed_on_import - longest = max(longest, max([len(name) for name in all_failed])) + if self.failed: + longest = max(longest, max([len(name) for name in self.failed])) def print_three_column(lst): lst.sort(key=str.lower) @@ -278,14 +276,6 @@ print_three_column(failed) print() - if self.failed_on_import: - failed = self.failed_on_import[:] - print() - print("Following modules built successfully" - " but were removed because they could not be imported:") - print_three_column(failed) - print() - def build_extension(self, ext): if ext.name == '_ctypes': @@ -344,7 +334,7 @@ try: importlib._bootstrap._SpecMethods(spec).load() except ImportError as why: - self.failed_on_import.append(ext.name) + self.failed.append(ext.name) self.announce('*** WARNING: renaming "%s" since importing it' ' failed: %s' % (ext.name, why), level=3) assert not self.inplace @@ -1032,16 +1022,8 @@ if db_setup_debug: print("bsddb using BerkeleyDB lib:", db_ver, dblib) print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir) + db_incs = [db_incdir] dblibs = [dblib] - # Only add the found library and include directories if they aren't - # already being searched. This avoids an explicit runtime library - # dependency. - if db_incdir in inc_dirs: - db_incs = None - else: - db_incs = [db_incdir] - if dblib_dir[0] in lib_dirs: - dblib_dir = None else: if db_setup_debug: print("db: no appropriate library found") db_incs = None @@ -1152,9 +1134,6 @@ # can end up with a bad search path order. if sqlite_incdir not in self.compiler.include_dirs: include_dirs.append(sqlite_incdir) - # avoid a runtime library path for a system library dir - if sqlite_libdir and sqlite_libdir[0] in lib_dirs: - sqlite_libdir = None exts.append(Extension('_sqlite3', sqlite_srcs, define_macros=sqlite_defines, include_dirs=include_dirs, @@ -1223,7 +1202,7 @@ libraries = gdbm_libs) break elif cand == "bdb": - if dblibs: + if db_incs is not None: if dbm_setup_debug: print("building dbm using bdb") dbmext = Extension('_dbm', ['_dbmmodule.c'], library_dirs=dblib_dir,